Author: iocanel
Date: Mon Sep 5 20:34:31 2011
New Revision: 1165412
URL: http://svn.apache.org/viewvc?rev=1165412&view=rev
Log:
[SMX4-909] Changed OpenJpa bundle activator to export the
javax.persistence.spi.PersistenceProvider service.
Modified:
servicemix/smx4/bundles/trunk/openjpa-1.2.1/src/main/java/org/apache/servicemix/bundles/openjpa/Activator.java
servicemix/smx4/bundles/trunk/pom.xml
Modified:
servicemix/smx4/bundles/trunk/openjpa-1.2.1/src/main/java/org/apache/servicemix/bundles/openjpa/Activator.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/bundles/trunk/openjpa-1.2.1/src/main/java/org/apache/servicemix/bundles/openjpa/Activator.java?rev=1165412&r1=1165411&r2=1165412&view=diff
==============================================================================
---
servicemix/smx4/bundles/trunk/openjpa-1.2.1/src/main/java/org/apache/servicemix/bundles/openjpa/Activator.java
(original)
+++
servicemix/smx4/bundles/trunk/openjpa-1.2.1/src/main/java/org/apache/servicemix/bundles/openjpa/Activator.java
Mon Sep 5 20:34:31 2011
@@ -18,19 +18,20 @@
*/
package org.apache.servicemix.bundles.openjpa;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import javax.persistence.spi.PersistenceProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.openjpa.persistence.PersistenceProductDerivation;
+import org.apache.openjpa.persistence.PersistenceProviderImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
/**
@@ -38,12 +39,23 @@ import org.osgi.framework.BundleContext;
* persistent configuration file
*/
public class Activator extends org.apache.servicemix.specs.locator.Activator {
+ // following is so Aries can find and extend us for OSGi RFC 143
+ public static final String PERSISTENCE_PROVIDER_ARIES =
"javax.persistence.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 OSGI_PERSISTENCE_PROVIDER =
PersistenceProviderImpl.class.getName();
+ private static ServiceRegistration svcReg = null;
+
private static final transient Log LOG =
LogFactory.getLog(Activator.class);
private Map<Long, URL> persistenceFiles = new ConcurrentHashMap<Long,
URL>();
-
+
@Override
public void start(BundleContext bundleContext) throws Exception {
super.start(bundleContext);
+ PersistenceProvider provider = new PersistenceProviderImpl();
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
+ svcReg = bundleContext.registerService(PERSISTENCE_PROVIDER, provider,
props);
LOG.info("OpenJPA activator starting");
}
@@ -51,6 +63,7 @@ public class Activator extends org.apach
public void stop(BundleContext bundleContext) throws Exception {
super.stop(bundleContext);
PersistenceProductDerivation.setDefaultPersistenceFiles(null);
+ svcReg.unregister();
LOG.info("OpenJPA activator stopping");
}
Modified: servicemix/smx4/bundles/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/bundles/trunk/pom.xml?rev=1165412&r1=1165411&r2=1165412&view=diff
==============================================================================
--- servicemix/smx4/bundles/trunk/pom.xml (original)
+++ servicemix/smx4/bundles/trunk/pom.xml Mon Sep 5 20:34:31 2011
@@ -45,6 +45,7 @@
<module>jzlib-1.0.7</module>
<module>scala-library-2.9.1</module>
<module>scala-compiler-2.9.1</module>
+ <module>openjpa-1.2.1</module>
</modules>
</project>