Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 627723fe40607a1aa4fd5d7db5ec5e61de09c705 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*******************************************************************************
 * Copyright (c) 2007, 2008 IBM Corporation and others. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator.manipulator;

import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.equinox.internal.provisional.configuratormanipulator.ConfiguratorManipulator;
import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
import org.osgi.framework.*;

public class Activator implements BundleActivator {
	final static boolean DEBUG = true;
	private static volatile BundleContext context;
	private ServiceRegistration registration;

	static BundleContext getContext() {
		return context;
	}

	private void registerConfiguratorManipulator() {
		Dictionary props = new Hashtable();
		props.put(ConfiguratorManipulator.SERVICE_PROP_KEY_CONFIGURATOR_BUNDLESYMBOLICNAME, SimpleConfiguratorManipulator.SERVICE_PROP_VALUE_CONFIGURATOR_SYMBOLICNAME);
		props.put(Constants.SERVICE_VENDOR, "Eclipse.org"); //$NON-NLS-1$
		SimpleConfiguratorManipulatorImpl manipulator = new SimpleConfiguratorManipulatorImpl();
		String[] clazzes = new String[] {ConfiguratorManipulator.class.getName(), SimpleConfiguratorManipulator.class.getName()};
		registration = context.registerService(clazzes, manipulator, props);
	}

	public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;
		registerConfiguratorManipulator();
	}

	public void stop(BundleContext bundleContext) throws Exception {
		if (registration != null)
			registration.unregister();
		Activator.context = null;
	}
}

Back to the top