1 package org.simantics.internal;
\r
4 import java.io.UnsupportedEncodingException;
\r
5 import java.net.MalformedURLException;
\r
7 import java.net.URLDecoder;
\r
9 import org.eclipse.core.runtime.Plugin;
\r
10 import org.osgi.framework.BundleContext;
\r
11 import org.simantics.internal.startup.StartupRegistry;
\r
13 public class Activator extends Plugin {
\r
16 * Name of the log file.
\r
18 public static String LOG_FILE_NAME = "simantics.log";
\r
20 public static final String PLUGIN_ID = "org.simantics";
\r
22 // The shared instance
\r
23 private static Activator plugin;
\r
25 private static BundleContext context;
\r
27 private StartupRegistry startupRegistry;
\r
29 static BundleContext getContext() {
\r
35 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
\r
37 public void start(BundleContext bundleContext) throws Exception {
\r
38 super.start(bundleContext);
\r
39 Activator.context = bundleContext;
\r
42 String prop = System.getProperty("osgi.instance.area", null);
\r
45 URL url = new URL(prop);
\r
46 if ("file".equals(url .getProtocol())) {
\r
48 File path = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
\r
51 if (path.exists() && path.canWrite()) {
\r
52 File logFile = new File(path, LOG_FILE_NAME);
\r
53 if (!logFile.exists() || (logFile.isFile() && logFile.canWrite()))
\r
54 LOG_FILE_NAME = logFile.getAbsolutePath();
\r
57 } catch (UnsupportedEncodingException e) {
\r
58 // Should never happen since UTF-8 is always supported.
\r
61 } catch (MalformedURLException e) {
\r
66 startupRegistry = new StartupRegistry();
\r
71 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
\r
73 public void stop(BundleContext bundleContext) throws Exception {
\r
74 Activator.context = null;
\r
76 super.stop(bundleContext);
\r
80 * @return the context of this bundle.
\r
82 public static BundleContext getBundleContext() {
\r
87 * Returns the shared instance
\r
89 * @return the shared instance
\r
91 public static Activator getDefault() {
\r
98 public StartupRegistry getStartupRegistry() {
\r
99 return startupRegistry;
\r