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