/**
* The shared instance
*/
- private static Activator plugin;
+ private static Activator fPlugin;
// ------------------------------------------------------------------------
// Constructors
* The constructor
*/
public Activator() {
+ setDefault(this);
}
// ------------------------------------------------------------------------
* @return the shared instance
*/
public static Activator getDefault() {
- return plugin;
+ return fPlugin;
+ }
+
+ // Sets plug-in instance
+ private static void setDefault(Activator plugin) {
+ fPlugin = plugin;
}
// ------------------------------------------------------------------------
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
- plugin = this;
+ setDefault(this);
}
@Override
public void stop(BundleContext context) throws Exception {
- plugin = null;
+ setDefault(null);
super.stop(context);
}
* @return the specified service or null if it's not registered
*/
public static @Nullable <T> T getService(Class<T> service) {
- BundleContext context = plugin.getBundle().getBundleContext();
+ BundleContext context = fPlugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ((ref != null) ? context.getService(ref) : null);
}