Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d0e87e9503b691fad2a41ed962ea2372ef95a6c2 (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
/*******************************************************************************
 * Copyright (c) 2010, 2013 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.coordinator;

import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.coordinator.Coordinator;

public class Activator implements BundleActivator {
	private CoordinatorServiceFactory factory;
	private ServiceRegistration<Coordinator> registration;

	public void start(BundleContext bundleContext) throws Exception {
		factory = new CoordinatorServiceFactory(bundleContext);
		Dictionary<String, Object> properties = new Hashtable<String, Object>();
		@SuppressWarnings({"unchecked"})
		// Use local variable to avoid suppressing unchecked warnings at method level.
		ServiceRegistration<Coordinator> reg = (ServiceRegistration<Coordinator>) bundleContext.registerService(Coordinator.class.getName(), factory, properties);
		this.registration = reg;
	}

	public void stop(BundleContext bundleContext) throws Exception {
		registration.unregister();
		factory.shutdown();
		CoordinationWeakReference.processOrphanedCoordinations();
	}
}

Back to the top