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
14 public class TaxonomicEditorPlugin
extends AbstractUIPlugin
{
15 private static final Logger logger
= Logger
16 .getLogger(TaxonomicEditorPlugin
.class);
19 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.application";
21 // The shared instance
22 private static TaxonomicEditorPlugin plugin
;
24 private PackageAdmin packageAdmin
;
26 private ServiceReference packageAdminRef
;
28 protected static BundleContext bundleContext
;
31 private ServiceRegistration policyRegistration
;
33 // private CloudPolicy policy;
38 public TaxonomicEditorPlugin() {
43 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
45 public void start(BundleContext context
) throws Exception
{
49 bundleContext
= context
;
51 packageAdminRef
= bundleContext
.getServiceReference(PackageAdmin
.class.getName());
52 packageAdmin
= (PackageAdmin
) bundleContext
.getService(packageAdminRef
);
54 logger
.debug("Taxonomic Editor started.");
57 private Bundle
getBundle(String symbolicName
) {
58 if (packageAdmin
== null)
60 Bundle
[] bundles
= packageAdmin
.getBundles(symbolicName
, null);
63 // Return the first bundle that is not installed or uninstalled
64 for (int i
= 0; i
< bundles
.length
; i
++) {
65 if ((bundles
[i
].getState() & (Bundle
.INSTALLED
| Bundle
.UNINSTALLED
)) == 0) {
74 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
76 public void stop(BundleContext context
) throws Exception
{
79 ApplicationUtil
.info("Taxonomic Editor stopped.");
83 * Returns the shared instance
85 * @return the shared instance
87 public static TaxonomicEditorPlugin
getDefault() {