You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by dw...@apache.org on 2010/02/15 21:41:14 UTC
svn commit: r910332 - in /openjpa/trunk: ./ openjpa-osgi/ openjpa/
openjpa/src/main/java/ openjpa/src/main/java/org/
openjpa/src/main/java/org/apache/ openjpa/src/main/java/org/apache/openjpa/
openjpa/src/main/java/org/apache/openjpa/osgi/
Author: dwoods
Date: Mon Feb 15 20:41:13 2010
New Revision: 910332
URL: http://svn.apache.org/viewvc?rev=910332&view=rev
Log:
OPENJPA-1512 Include a BundleActivator to register ourselves as a javax.persistence.provider for Apache Aries
Added:
openjpa/trunk/openjpa/src/main/java/
openjpa/trunk/openjpa/src/main/java/org/
openjpa/trunk/openjpa/src/main/java/org/apache/
openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/
openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/
openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java (with props)
Removed:
openjpa/trunk/openjpa-osgi/
Modified:
openjpa/trunk/openjpa/pom.xml
openjpa/trunk/pom.xml
Modified: openjpa/trunk/openjpa/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa/pom.xml?rev=910332&r1=910331&r2=910332&view=diff
==============================================================================
--- openjpa/trunk/openjpa/pom.xml (original)
+++ openjpa/trunk/openjpa/pom.xml Mon Feb 15 20:41:13 2010
@@ -134,14 +134,10 @@
<instructions>
<!-- OSGi Bundle Metadata -->
<Bundle-DocURL>${project.url}</Bundle-DocURL>
+ <Bundle-Activator>org.apache.openjpa.osgi.PersistenceActivator</Bundle-Activator>
<Private-Package />
<Export-Package>org.apache.openjpa.*;version=${pom.version}</Export-Package>
- <Import-Package>com.ibm.*;resolution:=optional,org.postg
-resql.*;resolution:=optional,org.apache.tools.ant.*;resolution:=optional,org.apa
-che.log4j.*;resolution:=optional,javax.activation.xa*;resolution:=optional,javax
-.jms.*;resolution:=optional,javax.transaction.*;resolution:=optional,javax.valid
-ation.*;resolution:=optional,javax.xml.bind.*;resolution:=optional,serp.*;resolu
-tion:=optional,*</Import-Package>
+ <Import-Package>com.ibm.*;resolution:=optional,org.postgresql.*;resolution:=optional,org.apache.tools.ant.*;resolution:=optional,org.apache.log4j.*;resolution:=optional,javax.activation.xa*;resolution:=optional,javax.jms.*;version="[1.1.0,1.2)";resolution:=optional,javax.transaction.*;version="[1.1.0,1.2)";resolution:=optional,javax.validation.*;version="[1.0.0,1.1)";resolution:=optional,javax.xml.bind.*;resolution:=optional,serp.*;resolution:=optional,javax.persistence.*;version="[2.0.0,2.1)",*</Import-Package>
<!-- Eclipse metadata -->
<Eclipse-Autostart>false</Eclipse-Autostart>
<Bundle-ClassPath>.</Bundle-ClassPath>
@@ -240,5 +236,18 @@
<artifactId>openjpa-slice</artifactId>
<version>${pom.version}</version>
</dependency>
+ <!-- for osgi bundle activator code -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.4.0</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.foundation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</project>
Added: openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java?rev=910332&view=auto
==============================================================================
--- openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java (added)
+++ openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java Mon Feb 15 20:41:13 2010
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.osgi;
+
+import java.util.Hashtable;
+
+import javax.persistence.spi.PersistenceProvider;
+
+import org.apache.openjpa.persistence.PersistenceProviderImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * Used to discover/resolve JPA providers in an OSGi environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PersistenceActivator implements BundleActivator {
+ // 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 BundleContext ctx;
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext arg0) throws Exception {
+ ctx = arg0;
+ PersistenceProvider provider = new PersistenceProviderImpl();
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER);
+ ctx.registerService(PERSISTENCE_PROVIDER, provider, props);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext arg0) throws Exception {
+ // no-op
+ }
+
+}
Propchange: openjpa/trunk/openjpa/src/main/java/org/apache/openjpa/osgi/PersistenceActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/pom.xml?rev=910332&r1=910331&r2=910332&view=diff
==============================================================================
--- openjpa/trunk/pom.xml (original)
+++ openjpa/trunk/pom.xml Mon Feb 15 20:41:13 2010
@@ -105,7 +105,6 @@
<module>openjpa-xmlstore</module>
<module>openjpa-slice</module>
<module>openjpa</module>
- <!-- <module>openjpa-osgi</module> -->
<module>openjpa-project</module>
<module>openjpa-examples</module>
<module>openjpa-integration</module>