1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.project.internal;
\r
14 import java.util.Hashtable;
\r
16 import org.eclipse.core.runtime.Plugin;
\r
17 import org.osgi.framework.BundleContext;
\r
18 import org.osgi.framework.ServiceRegistration;
\r
19 import org.simantics.project.features.registry.IProjectFeatureRegistry;
\r
22 * @author Tuukka Lehtonen
\r
24 public class Activator extends Plugin {
\r
27 public static final String PLUGIN_ID = "org.simantics.project";
\r
29 // The shared instance
\r
30 private static Activator plugin;
\r
32 private BundleContext bundleContext;
\r
34 private ProjectFeatureRegistry projectFeatureRegistryService = null;
\r
35 @SuppressWarnings("rawtypes")
\r
36 private ServiceRegistration projectFeatureRegistry = null;
\r
41 public Activator() {
\r
46 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
\r
48 @SuppressWarnings({ "unchecked", "rawtypes" })
\r
50 public void start(BundleContext context) throws Exception {
\r
51 super.start(context);
\r
52 this.bundleContext = context;
\r
55 projectFeatureRegistryService = new ProjectFeatureRegistry();
\r
56 projectFeatureRegistry = bundleContext.registerService(IProjectFeatureRegistry.class.getName(), projectFeatureRegistryService, new Hashtable());
\r
61 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
\r
64 public void stop(BundleContext context) throws Exception {
\r
65 if (projectFeatureRegistry != null) {
\r
66 projectFeatureRegistry.unregister();
\r
67 projectFeatureRegistry = null;
\r
70 this.bundleContext = null;
\r
72 super.stop(context);
\r
76 * Returns the shared instance
\r
78 * @return the shared instance
\r
80 public static Activator getDefault() {
\r
87 public IProjectFeatureRegistry getProjectFeatureRegistry() {
\r
88 return projectFeatureRegistryService;
\r
91 public BundleContext getContext() {
\r
92 return bundleContext;
\r