1 package eu
.etaxonomy
.taxeditor
;
3 import org
.apache
.log4j
.Logger
;
4 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
5 import org
.osgi
.framework
.Bundle
;
6 import org
.osgi
.framework
.BundleContext
;
7 import org
.osgi
.framework
.ServiceReference
;
8 import org
.osgi
.framework
.ServiceRegistration
;
9 import org
.osgi
.service
.packageadmin
.PackageAdmin
;
12 * The activator class controls the plug-in life cycle
17 public class TaxonomicEditorPlugin
extends AbstractUIPlugin
{
18 private static final Logger logger
= Logger
19 .getLogger(TaxonomicEditorPlugin
.class);
22 /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.application"</code> */
23 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.application";
25 // The shared instance
26 private static TaxonomicEditorPlugin plugin
;
28 private PackageAdmin packageAdmin
;
30 private ServiceReference packageAdminRef
;
32 /** Constant <code>bundleContext</code> */
33 protected static BundleContext bundleContext
;
36 private ServiceRegistration policyRegistration
;
38 // private CloudPolicy policy;
43 public TaxonomicEditorPlugin() {
48 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
51 public void start(BundleContext context
) throws Exception
{
55 bundleContext
= context
;
57 packageAdminRef
= bundleContext
.getServiceReference(PackageAdmin
.class.getName());
58 packageAdmin
= (PackageAdmin
) bundleContext
.getService(packageAdminRef
);
60 logger
.debug("Taxonomic Editor started.");
63 private Bundle
getBundle(String symbolicName
) {
64 if (packageAdmin
== null)
66 Bundle
[] bundles
= packageAdmin
.getBundles(symbolicName
, null);
69 // Return the first bundle that is not installed or uninstalled
70 for (int i
= 0; i
< bundles
.length
; i
++) {
71 if ((bundles
[i
].getState() & (Bundle
.INSTALLED
| Bundle
.UNINSTALLED
)) == 0) {
80 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
83 public void stop(BundleContext context
) throws Exception
{
86 ApplicationUtil
.info("Taxonomic Editor stopped.");
90 * Returns the shared instance
92 * @return the shared instance
94 public static TaxonomicEditorPlugin
getDefault() {