Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-18 05:23:04 +0000
committerEike Stepper2010-10-18 05:23:04 +0000
commitfc496efc6074f6be8ba0b14be5d056d3b3cfa965 (patch)
treeedc2c24ed9cc9f1fac8ca57d86d191e85f2e7413 /plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java
parent89bd55d0c28776519fd64099969024510618d66f (diff)
downloadcdo-fc496efc6074f6be8ba0b14be5d056d3b3cfa965.tar.gz
cdo-fc496efc6074f6be8ba0b14be5d056d3b3cfa965.tar.xz
cdo-fc496efc6074f6be8ba0b14be5d056d3b3cfa965.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/org/eclipse/net4j/util/om/OSGiActivator.java')
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java41
1 files changed, 29 insertions, 12 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 7f6055a80c..6941b78050 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
@@ -12,6 +12,7 @@ package org.eclipse.net4j.util.om;
import org.eclipse.net4j.internal.util.bundle.AbstractBundle;
import org.eclipse.net4j.internal.util.bundle.OM;
+import org.eclipse.net4j.internal.util.om.OSGiBundle;
import org.eclipse.net4j.util.io.IOUtil;
import org.osgi.framework.BundleActivator;
@@ -20,8 +21,10 @@ import org.osgi.framework.BundleContext;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
/**
* @author Eike Stepper
@@ -182,18 +185,36 @@ public abstract class OSGiActivator implements BundleActivator
*/
public static abstract class ConfigHandler
{
- public ConfigHandler()
+ private OSGiBundle bundle;
+
+ public ConfigHandler(OMBundle bundle)
{
+ this.bundle = (OSGiBundle)bundle;
}
- public final void start(File configFile) throws Exception
+ public final void start() throws Exception
{
+ File configFile = bundle.getConfigFile();
+ if (!configFile.exists())
+ {
+ startWithConfig(null);
+ return;
+ }
+
FileInputStream fis = null;
try
{
fis = new FileInputStream(configFile);
- ObjectInputStream ois = new ObjectInputStream(fis);
+ ObjectInputStream ois = new ObjectInputStream(fis)
+ {
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
+ {
+ String className = desc.getName();
+ return bundle.getAccessor().getClassLoader().loadClass(className);
+ }
+ };
Object config = ois.readObject();
IOUtil.close(ois);
@@ -205,7 +226,7 @@ public abstract class OSGiActivator implements BundleActivator
}
}
- public final void stop(File configFile) throws Exception
+ public final void stop() throws Exception
{
FileOutputStream fos = null;
@@ -213,6 +234,7 @@ public abstract class OSGiActivator implements BundleActivator
{
Object config = stopWithConfig();
+ File configFile = bundle.getConfigFile();
fos = new FileOutputStream(configFile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(config);
@@ -235,7 +257,7 @@ public abstract class OSGiActivator implements BundleActivator
*/
public static abstract class WithConfig extends OSGiActivator
{
- private ConfigHandler handler = new ConfigHandler()
+ private ConfigHandler handler = new ConfigHandler(getOMBundle())
{
@Override
protected void startWithConfig(Object config) throws Exception
@@ -258,18 +280,13 @@ public abstract class OSGiActivator implements BundleActivator
@Override
protected final void doStart() throws Exception
{
- File configFile = getOMBundle().getConfigFile();
- if (configFile.exists())
- {
- handler.start(configFile);
- }
+ handler.start();
}
@Override
protected final void doStop() throws Exception
{
- File configFile = getOMBundle().getConfigFile();
- handler.stop(configFile);
+ handler.stop();
}
protected abstract void doStartWithConfig(Object config) throws Exception;

Back to the top