Bundle-ActivationPolicy: lazy
Bundle-Activator: org.argeo.security.ui.SecurityUiPlugin
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
- org.eclipse.core.runtime,\
- org.eclipse.rap.ui;resolution:=optional
-
Import-Package: org.argeo.eclipse.spring,\
- org.apache.log4j;resolution:=optional,\
- org.eclipse.swt.widgets;version="[0,1.0)",\
- org.osgi.framework;version="[1.4,2)",\
- *
-
-Export-Packages: !org.argeo.security.ui.internal.*,\
- org.argeo.security.ui.*
+org.osgi.framework,\
+org.eclipse.swt,\
+org.eclipse.jface.window,\
+org.apache.log4j;resolution:=optional,\
+org.eclipse.ui;resolution:=optional,\
+*
import org.argeo.ArgeoException;
import org.argeo.security.ui.dialogs.DefaultLoginDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
/**
* The activator class controls the plug-in life cycle
*/
-public class SecurityUiPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.argeo.security.ui"; //$NON-NLS-1$
-
- public final static String CONTEXT_KEYRING = "KEYRING";
-
- private CallbackHandler defaultCallbackHandler;
- private ServiceRegistration defaultCallbackHandlerReg;
-
- private static SecurityUiPlugin plugin;
+public class SecurityUiPlugin implements BundleActivator {
private static BundleContext bundleContext;
-
public static InheritableThreadLocal<Display> display = new InheritableThreadLocal<Display>() {
@Override
}
};
+ // The plug-in ID
+ public final static String PLUGIN_ID = "org.argeo.security.ui"; //$NON-NLS-1$
+
+ public final static String CONTEXT_KEYRING = "KEYRING";
+
+ private CallbackHandler defaultCallbackHandler;
+ private ServiceRegistration<CallbackHandler> defaultCallbackHandlerReg;
+
public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
+ if (bundleContext != null)
+ if (!bundleContext.equals(bundleContext))
+ throw new ArgeoException(
+ "Bundle context already set with a different value");
+ else
+ return;
+
bundleContext = context;
defaultCallbackHandler = new DefaultCallbackHandler();
defaultCallbackHandlerReg = context.registerService(
- CallbackHandler.class.getName(), defaultCallbackHandler, null);
+ CallbackHandler.class, defaultCallbackHandler, null);
}
public void stop(BundleContext context) throws Exception {
- plugin = null;
bundleContext = null;
defaultCallbackHandlerReg.unregister();
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static SecurityUiPlugin getDefault() {
- return plugin;
}
public static BundleContext getBundleContext() {
return bundleContext;
}
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
protected class DefaultCallbackHandler implements CallbackHandler {
public void handle(final Callback[] callbacks) throws IOException,
UnsupportedCallbackException {