1 /*******************************************************************************
2 * Copyright (c) 2016 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * THTH ry - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.debug.browser.internal;
16 import java.net.URLDecoder;
17 import java.util.Hashtable;
19 import org.eclipse.core.runtime.FileLocator;
20 import org.osgi.framework.BundleActivator;
21 import org.osgi.framework.BundleContext;
22 import org.simantics.debug.browser.content.ResourceBrowserRewriter;
23 import org.simantics.debug.browser.internal.rewriters.BreadcrumbCreator;
24 import org.simantics.debug.browser.internal.rewriters.PageHeaderCreator;
25 import org.simantics.debug.browser.internal.rewriters.RawStatementsCreator;
26 import org.simantics.debug.browser.internal.rewriters.ResourceInfoCreator;
27 import org.simantics.debug.browser.internal.rewriters.ResourceLookupCreator;
28 import org.simantics.debug.browser.internal.rewriters.TypeHierarchyCreator;
30 public class Activator implements BundleActivator {
32 public static final String PLUGIN_ID = "org.simantics.debug.browser";
33 private static BundleContext context;
34 private static Activator plugin;
35 private static String resourcesPath;
36 private DebugBrowserServer server;
41 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
44 @SuppressWarnings({ "unchecked", "rawtypes" })
45 public void start(BundleContext bundleContext) throws Exception {
46 Activator.context = bundleContext;
49 Hashtable properties = new Hashtable();
50 bundleContext.registerService(ResourceBrowserRewriter.class, PageHeaderCreator.INSTANCE, properties);
51 bundleContext.registerService(ResourceBrowserRewriter.class, ResourceLookupCreator.INSTANCE, properties);
52 bundleContext.registerService(ResourceBrowserRewriter.class, RawStatementsCreator.INSTANCE, properties);
53 bundleContext.registerService(ResourceBrowserRewriter.class, BreadcrumbCreator.INSTANCE, properties);
54 bundleContext.registerService(ResourceBrowserRewriter.class, TypeHierarchyCreator.INSTANCE, properties);
55 bundleContext.registerService(ResourceBrowserRewriter.class, ResourceInfoCreator.INSTANCE, properties);
57 URL url = context.getBundle().getEntry("resources");
58 URL fileURL = FileLocator.toFileURL(url);
59 File filePath = new File(URLDecoder.decode(fileURL.getPath(), "UTF-8"));
60 resourcesPath = filePath.getCanonicalPath();
63 public DebugBrowserServer getDebugServer() {
67 public synchronized DebugBrowserServer startDebugServer() throws Exception {
69 server = new DebugBrowserServer(resourcesPath);
75 public synchronized void stopDebugServer() throws Exception {
82 public static BundleContext getContext() {
90 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
92 public void stop(BundleContext bundleContext) throws Exception {
94 Activator.context = null;
98 * Returns the shared instance
100 * @return the shared instance
102 public static Activator getDefault() {