diff options
author | Eike Stepper | 2010-10-17 07:42:20 +0000 |
---|---|---|
committer | Eike Stepper | 2010-10-17 07:42:20 +0000 |
commit | 2f15752f0778140797f6b6e37852f41febfd19fc (patch) | |
tree | efb96754a50776f455cce347205c1f7e6956d93b /plugins/org.eclipse.net4j.util/src | |
parent | cc1e1367fce0021c92e69f441bfa341230aef1a5 (diff) | |
download | cdo-2f15752f0778140797f6b6e37852f41febfd19fc.tar.gz cdo-2f15752f0778140797f6b6e37852f41febfd19fc.tar.xz cdo-2f15752f0778140797f6b6e37852f41febfd19fc.zip |
[327405] Provide an offline CDOWorkspace with Checkout/Update/Commit workflows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327405
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src')
-rw-r--r-- | plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java | 86 |
1 files changed, 59 insertions, 27 deletions
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 442d8e94e5..7f6055a80c 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 @@ -180,34 +180,24 @@ public abstract class OSGiActivator implements BundleActivator * @author Eike Stepper * @since 3.1 */ - public static abstract class WithConfig extends OSGiActivator + public static abstract class ConfigHandler { - public WithConfig(OMBundle bundle) + public ConfigHandler() { - super(bundle); } - @Override - protected final void doStart() throws Exception + public final void start(File configFile) throws Exception { FileInputStream fis = null; try { - File configFile = OM.BUNDLE.getConfigFile(); - if (configFile.exists()) - { - fis = new FileInputStream(configFile); - ObjectInputStream ois = new ObjectInputStream(fis); - - Object config = ois.readObject(); - IOUtil.close(ois); - doStartWithConfig(config); - } - } - catch (Exception ex) - { - getOMBundle().logger().error(ex); + fis = new FileInputStream(configFile); + ObjectInputStream ois = new ObjectInputStream(fis); + + Object config = ois.readObject(); + IOUtil.close(ois); + startWithConfig(config); } finally { @@ -215,31 +205,73 @@ public abstract class OSGiActivator implements BundleActivator } } - @Override - protected final void doStop() throws Exception + public final void stop(File configFile) throws Exception { FileOutputStream fos = null; try { - Object config = doStopWithConfig(); + Object config = stopWithConfig(); - File configFile = OM.BUNDLE.getConfigFile(); fos = new FileOutputStream(configFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(config); IOUtil.close(oos); } - catch (Exception ex) - { - getOMBundle().logger().error(ex); - } finally { IOUtil.close(fos); } } + protected abstract void startWithConfig(Object config) throws Exception; + + protected abstract Object stopWithConfig() throws Exception; + } + + /** + * @author Eike Stepper + * @since 3.1 + */ + public static abstract class WithConfig extends OSGiActivator + { + private ConfigHandler handler = new ConfigHandler() + { + @Override + protected void startWithConfig(Object config) throws Exception + { + doStartWithConfig(config); + } + + @Override + protected Object stopWithConfig() throws Exception + { + return doStopWithConfig(); + } + }; + + public WithConfig(OMBundle bundle) + { + super(bundle); + } + + @Override + protected final void doStart() throws Exception + { + File configFile = getOMBundle().getConfigFile(); + if (configFile.exists()) + { + handler.start(configFile); + } + } + + @Override + protected final void doStop() throws Exception + { + File configFile = getOMBundle().getConfigFile(); + handler.stop(configFile); + } + protected abstract void doStartWithConfig(Object config) throws Exception; protected abstract Object doStopWithConfig() throws Exception; |