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
;
11 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
14 * The activator class controls the plug-in life cycle
19 public class TaxonomicEditorPlugin
extends AbstractUIPlugin
{
20 private static final Logger logger
= Logger
21 .getLogger(TaxonomicEditorPlugin
.class);
24 /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.application"</code> */
25 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.application";
27 // The shared instance
28 private static TaxonomicEditorPlugin plugin
;
30 private PackageAdmin packageAdmin
;
32 private ServiceReference packageAdminRef
;
34 /** Constant <code>bundleContext</code> */
35 protected static BundleContext bundleContext
;
38 private ServiceRegistration policyRegistration
;
40 // private CloudPolicy policy;
45 public TaxonomicEditorPlugin() {
50 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
53 public void start(BundleContext context
) throws Exception
{
57 bundleContext
= context
;
59 packageAdminRef
= bundleContext
.getServiceReference(PackageAdmin
.class.getName());
60 packageAdmin
= (PackageAdmin
) bundleContext
.getService(packageAdminRef
);
62 logger
.debug("Taxonomic Editor started.");
65 private Bundle
getBundle(String symbolicName
) {
66 if (packageAdmin
== null)
68 Bundle
[] bundles
= packageAdmin
.getBundles(symbolicName
, null);
71 // Return the first bundle that is not installed or uninstalled
72 for (int i
= 0; i
< bundles
.length
; i
++) {
73 if ((bundles
[i
].getState() & (Bundle
.INSTALLED
| Bundle
.UNINSTALLED
)) == 0) {
82 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
85 public void stop(BundleContext context
) throws Exception
{
88 MessagingUtils
.info("Taxonomic Editor stopped.");
92 * Returns the shared instance
94 * @return the shared instance
96 public static TaxonomicEditorPlugin
getDefault() {