01: /*
02: * Copyright (c) 2006 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz DFKI GmbH.
03: * All rights reserved.
04: *
05: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
06: */
07: package org.ontoware.rdf2go.impl.jena24.osgi;
08:
09: import java.util.Hashtable;
10:
11: import org.ontoware.rdf2go.ModelFactory;
12: import org.ontoware.rdf2go.impl.jena24.ModelFactoryImpl;
13: import org.osgi.framework.BundleActivator;
14: import org.osgi.framework.BundleContext;
15: import org.osgi.framework.ServiceReference;
16: import org.osgi.framework.ServiceRegistration;
17:
18: /**
19: * Register the ModelFactory at OSGI
20: * @author sauermann
21: */
22: public class Activator implements BundleActivator {
23:
24: protected static BundleContext bc;
25:
26: private ModelFactory factory;
27:
28: private ServiceReference reference;
29:
30: /**
31: * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
32: */
33: @SuppressWarnings("unchecked")
34: public void start(BundleContext context) throws Exception {
35:
36: bc = context;
37:
38: factory = new ModelFactoryImpl();
39: ServiceRegistration registration = bc.registerService(
40: ModelFactory.class.getName(), factory, new Hashtable());
41: reference = registration.getReference();
42: }
43:
44: /**
45: * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
46: */
47: public void stop(BundleContext context) throws Exception {
48: bc.ungetService(reference);
49: }
50:
51: }
|