diff options
3 files changed, 45 insertions, 3 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java index 66e0023907..37798ae4ac 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java @@ -36,6 +36,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; */ public abstract class AbstractPlatform implements OMPlatform { + public static final String SYSTEM_PROPERTY_OSGI_STATE = "osgi.instance.area"; //$NON-NLS-1$ + + public static final String SYSTEM_PROPERTY_NET4J_STATE = "net4j.state"; //$NON-NLS-1$ + public static final String SYSTEM_PROPERTY_NET4J_CONFIG = "net4j.config"; //$NON-NLS-1$ static Object systemContext; @@ -102,6 +106,41 @@ public abstract class AbstractPlatform implements OMPlatform this.debugging = debugging; } + public File getStateFolder() + { + String state = System.getProperty(SYSTEM_PROPERTY_NET4J_STATE); + if (state == null) + { + state = System.getProperty(SYSTEM_PROPERTY_OSGI_STATE); + if (state == null) + { + state = "state"; + } + else + { + state += ".metadata"; + } + } + + File stateFolder = new File(state); + if (!stateFolder.exists()) + { + if (!stateFolder.mkdirs()) + { + OM.LOG.error("State folder " + stateFolder.getAbsolutePath() + " could not be created"); + return null; + } + } + + if (!stateFolder.isDirectory()) + { + OM.LOG.error("State folder " + stateFolder.getAbsolutePath() + " is not a directoy"); + return null; + } + + return stateFolder; + } + public File getConfigFolder() { String config = System.getProperty(SYSTEM_PROPERTY_NET4J_CONFIG, "config"); @@ -110,14 +149,14 @@ public abstract class AbstractPlatform implements OMPlatform { if (!configFolder.mkdirs()) { - OM.LOG.error("Config folder " + config + " could not be created"); + OM.LOG.error("Config folder " + configFolder.getAbsolutePath() + " could not be created"); return null; } } if (!configFolder.isDirectory()) { - OM.LOG.error("Config folder " + config + " is not a directoy"); + OM.LOG.error("Config folder " + configFolder.getAbsolutePath() + " is not a directoy"); return null; } diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java index 14cd66398c..07b4de07f5 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java @@ -16,6 +16,7 @@ import org.eclipse.net4j.util.ReflectUtil; import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.io.IOUtil; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -48,7 +49,7 @@ public class LegacyBundle extends AbstractBundle public String getStateLocation() { - throw new UnsupportedOperationException(); + return new File(getPlatform().getStateFolder(), ".plugins/" + getBundleID()).getAbsolutePath(); } public URL getBaseURL() diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java index ff38f9672c..2a3e9d3a79 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java @@ -39,6 +39,8 @@ public interface OMPlatform public void removeTraceHandler(OMTraceHandler traceHandler); + public File getStateFolder(); + public File getConfigFolder(); public File getConfigFile(String name); |