mirror of https://github.com/apache/openjpa.git
OPENJPA-1512 minor updates to BundleActivator support
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@911684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e512e15ba0
commit
9ec42334e9
|
@ -23,6 +23,7 @@ import javax.persistence.spi.PersistenceProvider;
|
||||||
import org.apache.openjpa.persistence.PersistenceProviderImpl;
|
import org.apache.openjpa.persistence.PersistenceProviderImpl;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,24 +37,26 @@ public class PersistenceActivator implements BundleActivator {
|
||||||
// following would be set by Aries to expose their OSGi enabled provider
|
// following would be set by Aries to expose their OSGi enabled provider
|
||||||
public static final String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
|
public static final String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
|
||||||
public static final String OSGI_PERSISTENCE_PROVIDER = PersistenceProviderImpl.class.getName();
|
public static final String OSGI_PERSISTENCE_PROVIDER = PersistenceProviderImpl.class.getName();
|
||||||
private static BundleContext ctx;
|
private ServiceRegistration svcReg = null;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
public void start(BundleContext arg0) throws Exception {
|
public void start(BundleContext ctx) throws Exception {
|
||||||
ctx = arg0;
|
|
||||||
PersistenceProvider provider = new PersistenceProviderImpl();
|
PersistenceProvider provider = new PersistenceProviderImpl();
|
||||||
Hashtable<String, String> props = new Hashtable<String, String>();
|
Hashtable<String, String> props = new Hashtable<String, String>();
|
||||||
props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
|
props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
|
||||||
ctx.registerService(PERSISTENCE_PROVIDER, provider, props);
|
svcReg = ctx.registerService(PERSISTENCE_PROVIDER, provider, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
public void stop(BundleContext arg0) throws Exception {
|
public void stop(BundleContext ctx) throws Exception {
|
||||||
// no-op
|
if (svcReg != null) {
|
||||||
|
svcReg.unregister();
|
||||||
|
svcReg = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue