diff options
author | Eike Stepper | 2008-08-02 09:25:48 +0000 |
---|---|---|
committer | Eike Stepper | 2008-08-02 09:25:48 +0000 |
commit | ff0a4c7ec6b1e6bcd57a0bfa4f80da256deed1a0 (patch) | |
tree | df5b6a4870c2e9479e0be63c21da17a24d9d1c42 | |
parent | fbd6765453d74f2e95b0738bf017c698a596ace1 (diff) | |
download | cdo-ff0a4c7ec6b1e6bcd57a0bfa4f80da256deed1a0.tar.gz cdo-ff0a4c7ec6b1e6bcd57a0bfa4f80da256deed1a0.tar.xz cdo-ff0a4c7ec6b1e6bcd57a0bfa4f80da256deed1a0.zip |
[241121] Develop POP Process Tooling
https://bugs.eclipse.org/bugs/show_bug.cgi?id=241121
11 files changed, 251 insertions, 133 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java index 2e7bcb590c..69ac54f46e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java @@ -56,16 +56,70 @@ public final class Activator extends EMFPlugin @Override public void start(BundleContext context) throws Exception { - super.start(context); - OSGiActivator.startBundle(context, OM.BUNDLE); + OSGiActivator.traceStart(context); + if (OM.BUNDLE == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + super.start(context); + OM.BUNDLE.setBundleContext(context); + doStart(); + } + catch (Error error) + { + OM.BUNDLE.logger().error(error); + throw error; + } + catch (Exception ex) + { + OM.BUNDLE.logger().error(ex); + throw ex; + } } @Override public void stop(BundleContext context) throws Exception { plugin = null; - OSGiActivator.stopBundle(context, OM.BUNDLE); - super.stop(context); + OSGiActivator.traceStop(context); + if (OM.BUNDLE == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + doStop(); + OM.BUNDLE.setBundleContext(null); + super.stop(context); + } + catch (Error error) + { + OM.BUNDLE.logger().error(error); + throw error; + } + catch (Exception ex) + { + OM.BUNDLE.logger().error(ex); + throw ex; + } + } + + /** + * @since 2.0 + */ + protected void doStart() throws Exception + { + } + + /** + * @since 2.0 + */ + protected void doStop() throws Exception + { } } } diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java index 958c2c1ac9..4b06f1b759 100644 --- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java +++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java @@ -46,11 +46,6 @@ public abstract class OM public static final OMLogger LOG = BUNDLE.logger(); - static void stop() throws Exception - { - BuddyAdmin.INSTANCE.deactivate(); - } - /** * @author Eike Stepper */ @@ -60,5 +55,11 @@ public abstract class OM { super(BUNDLE); } + + @Override + protected void doStop() throws Exception + { + BuddyAdmin.INSTANCE.deactivate(); + } } } diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java index ed7dc8ba80..db47731e97 100644 --- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java +++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java @@ -34,27 +34,26 @@ public abstract class OM public static final OMLogger LOG = BUNDLE.logger(); - static void start() throws Exception - { - SessionManager.INSTANCE.activate(); - } - - static void stop() throws Exception - { - SessionManager.INSTANCE.deactivate(); - } - /** * @author Eike Stepper */ public static final class Activator extends UIActivator { - public static Activator INSTANCE; - public Activator() { super(BUNDLE); - INSTANCE = this; + } + + @Override + protected void doStart() throws Exception + { + SessionManager.INSTANCE.activate(); + } + + @Override + protected void doStop() throws Exception + { + SessionManager.INSTANCE.deactivate(); } } } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/bundle/OM.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/bundle/OM.java index 946f08cc02..f76c34179d 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/bundle/OM.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/bundle/OM.java @@ -24,8 +24,6 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; -import org.osgi.framework.BundleContext; - /** * The <em>Operations & Maintenance</em> class of this bundle. * @@ -56,9 +54,8 @@ public abstract class OM } @Override - public void start(BundleContext context) throws Exception + protected void doStart() throws Exception { - super.start(context); initDBAdapterRegistry(); } diff --git a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java index 8e528476f1..a0f7888d97 100644 --- a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java +++ b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/OM.java @@ -59,12 +59,9 @@ public abstract class OM */ public static final class Activator extends UIActivator { - public static Activator INSTANCE; - public Activator() { super(BUNDLE); - INSTANCE = this; } } } diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java index a4a0d6b52c..d3f167e60d 100644 --- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIActivator.java @@ -24,6 +24,11 @@ public class UIActivator extends AbstractUIPlugin { private OMBundle omBundle; + /** + * @since 2.0 + */ + protected BundleContext bundleContext; + public UIActivator(OMBundle omBundle) { this.omBundle = omBundle; @@ -35,16 +40,71 @@ public class UIActivator extends AbstractUIPlugin } @Override - public void start(BundleContext context) throws Exception + public final void start(BundleContext context) throws Exception { - OSGiActivator.startBundle(context, getOMBundle()); - super.start(context); + bundleContext = context; + OSGiActivator.traceStart(context); + if (omBundle == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + super.start(context); + omBundle.setBundleContext(context); + doStart(); + } + catch (Error error) + { + omBundle.logger().error(error); + throw error; + } + catch (Exception ex) + { + omBundle.logger().error(ex); + throw ex; + } } @Override - public void stop(BundleContext context) throws Exception + public final void stop(BundleContext context) throws Exception + { + OSGiActivator.traceStop(context); + if (omBundle == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + doStop(); + omBundle.setBundleContext(null); + super.stop(context); + } + catch (Error error) + { + omBundle.logger().error(error); + throw error; + } + catch (Exception ex) + { + omBundle.logger().error(ex); + throw ex; + } + } + + /** + * @since 2.0 + */ + protected void doStart() throws Exception + { + } + + /** + * @since 2.0 + */ + protected void doStop() throws Exception { - super.stop(context); - OSGiActivator.stopBundle(context, getOMBundle()); } } diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java index 59fb769c8f..a9dc8c34e6 100644 --- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java @@ -13,7 +13,6 @@ package org.eclipse.net4j.util.ui.views; import org.eclipse.net4j.util.container.IContainer; import org.eclipse.net4j.util.internal.ui.SharedIcons; import org.eclipse.net4j.util.internal.ui.actions.IntrospectAction; -import org.eclipse.net4j.util.internal.ui.bundle.OM; import org.eclipse.net4j.util.ui.UIUtil; import org.eclipse.net4j.util.ui.actions.SafeAction; @@ -126,28 +125,15 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar @Override public final void createPartControl(Composite parent) { - try - { - shell = parent.getShell(); - Composite composite = UIUtil.createGridComposite(parent, 1); + shell = parent.getShell(); + Composite composite = UIUtil.createGridComposite(parent, 1); - Control control = createUI(composite); - control.setLayoutData(UIUtil.createGridData()); + Control control = createUI(composite); + control.setLayoutData(UIUtil.createGridData()); - hookContextMenu(); - hookDoubleClick(); - contributeToActionBars(); - } - catch (Error ex) - { - OM.LOG.error(ex); - throw ex; - } - catch (RuntimeException ex) - { - OM.LOG.error(ex); - throw ex; - } + hookContextMenu(); + hookDoubleClick(); + contributeToActionBars(); } protected Control createUI(Composite parent) diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF index 8cda754d35..8c6e9c65a3 100644 --- a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF @@ -14,7 +14,7 @@ Import-Package: org.eclipse.osgi.service.debug;version="[1.0.0,2.0.0)";resolutio org.osgi.framework;version="[1.3.0,2.0.0)";resolution:=optional, org.osgi.service.log;version="[1.3.0,2.0.0)";resolution:=optional, org.osgi.util.tracker;version="[1.3.0,2.0.0)";resolution:=optional -Export-Package: org.eclipse.net4j.internal.util.bundle;version="2.0.0";x-internal:=true, +Export-Package: org.eclipse.net4j.internal.util.bundle;version="2.0.0";x-friends:="org.eclipse.net4j.util.ui", org.eclipse.net4j.internal.util.container;version="2.0.0";x-internal:=true, org.eclipse.net4j.internal.util.factory;version="2.0.0";x-internal:=true, org.eclipse.net4j.internal.util.om;version="2.0.0";x-internal:=true, diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java index ff7c61ce5e..79a343a084 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java @@ -15,6 +15,7 @@ import org.eclipse.net4j.internal.util.om.OSGiBundle; import org.eclipse.net4j.util.container.IPluginContainer; import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; import org.eclipse.net4j.util.om.log.EclipseLoggingBridge; import org.eclipse.net4j.util.om.log.OMLogger; import org.eclipse.net4j.util.om.log.PrintLogHandler; @@ -50,12 +51,7 @@ public abstract class OM public static final OMLogger LOG = BUNDLE.logger(); - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OM, OM.class); - - static void stop() throws Exception - { - PluginContainer.dispose(); - } + public static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OM, OM.class); /** * @author Eike Stepper @@ -77,49 +73,25 @@ public abstract class OM { AbstractPlatform.INSTANCE.addLogHandler(EclipseLoggingBridge.INSTANCE); } - catch (Exception ignore) + catch (Throwable ignore) { } - traceStart(context); + OSGiActivator.traceStart(context); IPluginContainer container = IPluginContainer.INSTANCE; - if (TRACER.isEnabled()) TRACER.format("Plugin container created: {0}", container); + if (TRACER.isEnabled()) + { + TRACER.format("Plugin container created: {0}", container); + } } public void stop(BundleContext context) throws Exception { - traceStop(context); + OSGiActivator.traceStop(context); ((OSGiBundle)OM.BUNDLE).stop(); + PluginContainer.dispose(); OM.BUNDLE.setBundleContext(null); AbstractPlatform.systemContext = null; } - - public static void traceStart(BundleContext context) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Starting bundle {0}", context.getBundle().getSymbolicName()); - } - } - catch (RuntimeException ignore) - { - } - } - - public static void traceStop(BundleContext context) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Stopping bundle {0}", context.getBundle().getSymbolicName()); - } - } - catch (RuntimeException ignore) - { - } - } } } diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java index 5cd57ccc7f..5df2f274d9 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java @@ -318,7 +318,13 @@ public final class ReflectUtil return null; } - return object.getClass().getSimpleName() + "@" + getID(object); //$NON-NLS-1$ + String name = object.getClass().getSimpleName(); + if (name.length() == 0) + { + name = "anonymous"; + } + + return name + "@" + getID(object); //$NON-NLS-1$ } public static void dump(Object object) diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java index f162c34efc..4390d2732f 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java @@ -23,6 +23,11 @@ public abstract class OSGiActivator implements BundleActivator { private OMBundle omBundle; + /** + * @since 2.0 + */ + protected BundleContext bundleContext; + public OSGiActivator(OMBundle omBundle) { this.omBundle = omBundle; @@ -33,14 +38,57 @@ public abstract class OSGiActivator implements BundleActivator return omBundle; } - public void start(BundleContext context) throws Exception + public final void start(BundleContext context) throws Exception { - startBundle(context, getOMBundle()); + bundleContext = context; + OSGiActivator.traceStart(context); + if (omBundle == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + omBundle.setBundleContext(context); + ((AbstractBundle)omBundle).start(); + doStart(); + } + catch (Error error) + { + omBundle.logger().error(error); + throw error; + } + catch (Exception ex) + { + omBundle.logger().error(ex); + throw ex; + } } - public void stop(BundleContext context) throws Exception + public final void stop(BundleContext context) throws Exception { - stopBundle(context, getOMBundle()); + OSGiActivator.traceStop(context); + if (omBundle == null) + { + throw new IllegalStateException("bundle == null"); + } + + try + { + doStop(); + ((AbstractBundle)omBundle).stop(); + omBundle.setBundleContext(null); + } + catch (Error error) + { + omBundle.logger().error(error); + throw error; + } + catch (Exception ex) + { + omBundle.logger().error(ex); + throw ex; + } } @Override @@ -73,53 +121,51 @@ public abstract class OSGiActivator implements BundleActivator super.finalize(); } - public static void startBundle(BundleContext context, OMBundle bundle) throws Error, Exception + /** + * @since 2.0 + */ + protected void doStart() throws Exception { - OM.Activator.traceStart(context); - if (bundle == null) - { - throw new IllegalStateException("bundle == null"); - } + } + /** + * @since 2.0 + */ + protected void doStop() throws Exception + { + } + + /** + * @since 2.0 + */ + public static void traceStart(BundleContext context) + { try { - bundle.setBundleContext(context); - ((AbstractBundle)bundle).start(); + if (OM.TRACER.isEnabled()) + { + OM.TRACER.format("Starting bundle {0}", context.getBundle().getSymbolicName()); + } } - catch (Error error) + catch (RuntimeException ignore) { - bundle.logger().error(error); - throw error; - } - catch (Exception ex) - { - bundle.logger().error(ex); - throw ex; } } - public static void stopBundle(BundleContext context, OMBundle bundle) throws Error, Exception + /** + * @since 2.0 + */ + public static void traceStop(BundleContext context) { - OM.Activator.traceStop(context); - if (bundle == null) - { - throw new IllegalStateException("bundle == null"); - } - try { - ((AbstractBundle)bundle).stop(); - bundle.setBundleContext(null); + if (OM.TRACER.isEnabled()) + { + OM.TRACER.format("Stopping bundle {0}", context.getBundle().getSymbolicName()); + } } - catch (Error error) - { - bundle.logger().error(error); - throw error; - } - catch (Exception ex) + catch (RuntimeException ignore) { - bundle.logger().error(ex); - throw ex; } } } |