X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Finternal%2FActivator.java;h=82f6812ec05326ccc89366f871181d727fa8805d;hb=25e3207c8a1aad3cbe72202750f67f0483ccb1a2;hp=3feff3341a99f4ee3feb534f4928224e7b2cfa7e;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/internal/Activator.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/internal/Activator.java index 3feff3341..82f6812ec 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/internal/Activator.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/internal/Activator.java @@ -1,85 +1,85 @@ -package org.simantics.db.common.internal; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLDecoder; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.simantics.db.common.internal.config.InternalClientConfig; - -/** - * @author Tuukka Lehtonen - * - */ -public class Activator implements BundleActivator { - - // The plug-in ID - public static final String BUNDLE_ID = "org.simantics.db.common"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - plugin = this; - - String prop = System.getProperty("osgi.instance.area", null); - if (prop != null) { - try { - URL url = new URL(prop); - if ("file".equals(url .getProtocol())) { - try { - File path = new File(URLDecoder.decode(url.getPath(), "UTF-8")); - if (!path.exists()) - path.mkdirs(); - if (path.exists() && path.canWrite()) { - File logFile = new File(path, InternalClientConfig.DB_CLIENT_LOG_FILE_NAME); - if (!logFile.exists() || (logFile.isFile() && logFile.canWrite())) - InternalClientConfig.DB_CLIENT_LOG_FILE = logFile.getAbsolutePath(); - - File tempDir = new File(path, InternalClientConfig.DB_CLIENT_TEMP_DIR_NAME); - if (!tempDir.exists() || (tempDir.isDirectory() && tempDir.canWrite())) - InternalClientConfig.DB_CLIENT_TEMP_DIR = tempDir; - } - } catch (UnsupportedEncodingException e) { - // Should never happen since UTF-8 is always supported. - } - } - } catch (MalformedURLException e) { - // Ignore. - } - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - +package org.simantics.db.common.internal; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.simantics.db.common.internal.config.InternalClientConfig; + +/** + * @author Tuukka Lehtonen + * + */ +public class Activator implements BundleActivator { + + // The plug-in ID + public static final String BUNDLE_ID = "org.simantics.db.common"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + plugin = this; + + String prop = System.getProperty("osgi.instance.area", null); + if (prop != null) { + try { + URL url = new URL(prop); + if ("file".equals(url .getProtocol())) { + try { + File path = new File(URLDecoder.decode(url.getPath(), "UTF-8")); + if (!path.exists()) + path.mkdirs(); + if (path.exists() && path.canWrite()) { + File logFile = new File(path, InternalClientConfig.DB_CLIENT_LOG_FILE_NAME); + if (!logFile.exists() || (logFile.isFile() && logFile.canWrite())) + InternalClientConfig.DB_CLIENT_LOG_FILE = logFile.getAbsolutePath(); + + File tempDir = new File(path, InternalClientConfig.DB_CLIENT_TEMP_DIR_NAME); + if (!tempDir.exists() || (tempDir.isDirectory() && tempDir.canWrite())) + InternalClientConfig.DB_CLIENT_TEMP_DIR = tempDir; + } + } catch (UnsupportedEncodingException e) { + // Should never happen since UTF-8 is always supported. + } + } + } catch (MalformedURLException e) { + // Ignore. + } + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + } \ No newline at end of file