X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics%2Fsrc%2Forg%2Fsimantics%2Finternal%2FActivator.java;h=4830bd8cfe5021de8dc952877403d82a4d23060a;hb=refs%2Fchanges%2F38%2F238%2F2;hp=74c9900397f02cc56f1f10d9815d16fb8f53232f;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics/src/org/simantics/internal/Activator.java b/bundles/org.simantics/src/org/simantics/internal/Activator.java index 74c990039..4830bd8cf 100644 --- a/bundles/org.simantics/src/org/simantics/internal/Activator.java +++ b/bundles/org.simantics/src/org/simantics/internal/Activator.java @@ -1,102 +1,102 @@ -package org.simantics.internal; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLDecoder; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; -import org.simantics.internal.startup.StartupRegistry; - -public class Activator extends Plugin { - - /** - * Name of the log file. - */ - public static String LOG_FILE_NAME = "simantics.log"; - - public static final String PLUGIN_ID = "org.simantics"; - - // The shared instance - private static Activator plugin; - - private static BundleContext context; - - private StartupRegistry startupRegistry; - - static BundleContext getContext() { - return context; - } - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext bundleContext) throws Exception { - super.start(bundleContext); - Activator.context = bundleContext; - 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, LOG_FILE_NAME); - if (!logFile.exists() || (logFile.isFile() && logFile.canWrite())) - LOG_FILE_NAME = logFile.getAbsolutePath(); - - } - } catch (UnsupportedEncodingException e) { - // Should never happen since UTF-8 is always supported. - } - } - } catch (MalformedURLException e) { - // Ignore. - } - } - - startupRegistry = new StartupRegistry(); - } - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext bundleContext) throws Exception { - Activator.context = null; - plugin = null; - super.stop(bundleContext); - } - - /** - * @return the context of this bundle. - */ - public static BundleContext getBundleContext() { - return context; - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * @return - */ - public StartupRegistry getStartupRegistry() { - return startupRegistry; - } - -} +package org.simantics.internal; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; +import org.simantics.internal.startup.StartupRegistry; + +public class Activator extends Plugin { + + /** + * Name of the log file. + */ + public static String LOG_FILE_NAME = "simantics.log"; + + public static final String PLUGIN_ID = "org.simantics"; + + // The shared instance + private static Activator plugin; + + private static BundleContext context; + + private StartupRegistry startupRegistry; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + super.start(bundleContext); + Activator.context = bundleContext; + 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, LOG_FILE_NAME); + if (!logFile.exists() || (logFile.isFile() && logFile.canWrite())) + LOG_FILE_NAME = logFile.getAbsolutePath(); + + } + } catch (UnsupportedEncodingException e) { + // Should never happen since UTF-8 is always supported. + } + } + } catch (MalformedURLException e) { + // Ignore. + } + } + + startupRegistry = new StartupRegistry(); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + plugin = null; + super.stop(bundleContext); + } + + /** + * @return the context of this bundle. + */ + public static BundleContext getBundleContext() { + return context; + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * @return + */ + public StartupRegistry getStartupRegistry() { + return startupRegistry; + } + +}