+ initSystemProperties();
+ }
+
+ protected void initSystemProperties() {
+ String osgiInstanceArea = System.getProperty("osgi.instance.area");
+ String osgiInstanceAreaDefault = System
+ .getProperty("osgi.instance.area.default");
+ String tempDir = System.getProperty("java.io.tmpdir");
+
+ File dataDir = null;
+ if (osgiInstanceArea != null) {
+ // within OSGi with -data specified
+ osgiInstanceArea = removeFilePrefix(osgiInstanceArea);
+ dataDir = new File(osgiInstanceArea);
+ } else if (osgiInstanceAreaDefault != null) {
+ // within OSGi without -data specified
+ osgiInstanceAreaDefault = removeFilePrefix(osgiInstanceAreaDefault);
+ dataDir = new File(osgiInstanceAreaDefault);
+ } else {// outside OSGi
+ dataDir = new File(tempDir + File.separator + "argeoOsgiData");
+ }
+
+ System.setProperty(PROP_ARGEO_OSGI_DATA_DIR, dataDir.getAbsolutePath());
+ }
+
+ public static String removeFilePrefix(String url) {
+ if (url.startsWith("file:"))
+ return url.substring("file:".length());
+ else if (url.startsWith("reference:file:"))
+ return url.substring("reference:file:".length());
+ else
+ return url;