]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/internal/Activator.java
Merge commit '728147df5d63a3333daff3d8c0e9bfd4f5597e3a'
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / internal / Activator.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.project.internal;\r
13 \r
14 import java.util.Hashtable;\r
15 \r
16 import org.eclipse.core.runtime.Plugin;\r
17 import org.osgi.framework.BundleContext;\r
18 import org.osgi.framework.ServiceRegistration;\r
19 import org.simantics.project.features.registry.IProjectFeatureRegistry;\r
20 \r
21 /**\r
22  * @author Tuukka Lehtonen\r
23  */\r
24 public class Activator extends Plugin {\r
25 \r
26     // The plug-in ID\r
27     public static final String     PLUGIN_ID                     = "org.simantics.project";\r
28 \r
29     // The shared instance\r
30     private static Activator       plugin;\r
31 \r
32     private BundleContext          bundleContext;\r
33 \r
34     private ProjectFeatureRegistry projectFeatureRegistryService = null;\r
35     @SuppressWarnings("rawtypes")\r
36     private ServiceRegistration    projectFeatureRegistry        = null;\r
37 \r
38     /**\r
39      * The constructor\r
40      */\r
41     public Activator() {\r
42     }\r
43 \r
44     /*\r
45      * (non-Javadoc)\r
46      * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)\r
47      */\r
48     @SuppressWarnings({ "unchecked", "rawtypes" })\r
49     @Override\r
50     public void start(BundleContext context) throws Exception {\r
51         super.start(context);\r
52         this.bundleContext = context;\r
53         plugin = this;\r
54 \r
55         projectFeatureRegistryService = new ProjectFeatureRegistry();\r
56         projectFeatureRegistry = bundleContext.registerService(IProjectFeatureRegistry.class.getName(), projectFeatureRegistryService, new Hashtable());\r
57     }\r
58 \r
59     /*\r
60      * (non-Javadoc)\r
61      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)\r
62      */\r
63     @Override\r
64     public void stop(BundleContext context) throws Exception {\r
65         if (projectFeatureRegistry != null) {\r
66             projectFeatureRegistry.unregister();\r
67             projectFeatureRegistry = null;\r
68         }\r
69 \r
70         this.bundleContext = null;\r
71         plugin = null;\r
72         super.stop(context);\r
73     }\r
74 \r
75     /**\r
76      * Returns the shared instance\r
77      *\r
78      * @return the shared instance\r
79      */\r
80     public static Activator getDefault() {\r
81         return plugin;\r
82     }\r
83 \r
84     /**\r
85      * @return\r
86      */\r
87     public IProjectFeatureRegistry getProjectFeatureRegistry() {\r
88         return projectFeatureRegistryService;\r
89     }\r
90 \r
91     public BundleContext getContext() {\r
92         return bundleContext;\r
93     }\r
94 \r
95 }\r