1 package org.simantics.db.common.internal;
4 import java.io.UnsupportedEncodingException;
5 import java.net.MalformedURLException;
7 import java.net.URLDecoder;
9 import org.osgi.framework.BundleActivator;
10 import org.osgi.framework.BundleContext;
11 import org.simantics.db.common.internal.config.InternalClientConfig;
14 * @author Tuukka Lehtonen
17 public class Activator implements BundleActivator {
20 public static final String BUNDLE_ID = "org.simantics.db.common"; //$NON-NLS-1$
22 // The shared instance
23 private static Activator plugin;
33 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
36 public void start(BundleContext context) throws Exception {
39 String prop = System.getProperty("osgi.instance.area", null);
42 URL url = new URL(prop);
43 if ("file".equals(url .getProtocol())) {
45 File path = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
48 if (path.exists() && path.canWrite()) {
49 File logFile = new File(path, InternalClientConfig.DB_CLIENT_LOG_FILE_NAME);
50 if (!logFile.exists() || (logFile.isFile() && logFile.canWrite()))
51 InternalClientConfig.DB_CLIENT_LOG_FILE = logFile.getAbsolutePath();
53 File tempDir = new File(path, InternalClientConfig.DB_CLIENT_TEMP_DIR_NAME);
54 if (!tempDir.exists() || (tempDir.isDirectory() && tempDir.canWrite()))
55 InternalClientConfig.DB_CLIENT_TEMP_DIR = tempDir;
57 } catch (UnsupportedEncodingException e) {
58 // Should never happen since UTF-8 is always supported.
61 } catch (MalformedURLException e) {
69 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
72 public void stop(BundleContext context) throws Exception {
77 * Returns the shared instance
79 * @return the shared instance
81 public static Activator getDefault() {