incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r917507 - in /incubator/aries/trunk/jpa: ./ jpa-api/ jpa-container/ jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/ jpa-container/src/main/resources/O...
Date Mon, 01 Mar 2010 13:04:49 GMT
Author: timothyjward
Date: Mon Mar  1 13:04:48 2010
New Revision: 917507

URL: http://svn.apache.org/viewvc?rev=917507&view=rev
Log:
ARIES-202 : Separate JPA injection from managed persistence contexts

Modified:
    incubator/aries/trunk/jpa/jpa-api/pom.xml
    incubator/aries/trunk/jpa/jpa-container/pom.xml
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
    incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java
    incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java
    incubator/aries/trunk/jpa/pom.xml

Modified: incubator/aries/trunk/jpa/jpa-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-api/pom.xml?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-api/pom.xml (original)
+++ incubator/aries/trunk/jpa/jpa-api/pom.xml Mon Mar  1 13:04:48 2010
@@ -26,7 +26,7 @@
     <modelVersion>4.0.0</modelVersion>
     <artifactId>org.apache.aries.jpa.api</artifactId>
     <packaging>bundle</packaging>
-    <name>Aries JPA Container Api</name>
+    <name>Aries JPA Container API</name>
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
@@ -56,13 +56,12 @@
                         <Import-Package>
                             javax.persistence;version="[1.0.0,2.1.0)",
                             javax.persistence.spi;version="[1.0.0,2.1.0)",
-                            javax.persistence.criteria;version="[1.1.0,2.1.0)";resolution:=optional,
-                            javax.persistence.metamodel;version="[1.1.0,2.1.0)";resolution:=optional,
-                            *
+                            org.osgi.framework;version="[1.5.0,2.0.0)",
                         </Import-Package>
                         <Export-Package>
                             org.apache.aries.jpa.container.parsing;version="${pom.version}",
-                            org.apache.aries.jpa.container;version="${pom.version}"
+                            org.apache.aries.jpa.container;version="${pom.version}",
+                            org.apache.aries.jpa.container.context;version="${pom.version}"
                         </Export-Package>
                         <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
                         <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>

Modified: incubator/aries/trunk/jpa/jpa-container/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/pom.xml?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/pom.xml (original)
+++ incubator/aries/trunk/jpa/jpa-container/pom.xml Mon Mar  1 13:04:48 2010
@@ -39,6 +39,10 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <groupId>org.apache.aries.jpa</groupId>
+        </dependency>
+        <dependency>
             <artifactId>org.apache.aries.application.api</artifactId>
             <groupId>org.apache.aries.application</groupId>
         </dependency>
@@ -49,6 +53,7 @@
         <dependency>
             <artifactId>org.apache.aries.util</artifactId>
             <groupId>org.apache.aries</groupId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -90,12 +95,10 @@
                             javax.persistence.spi;version="[1.0.0,2.1.0)",
                             javax.persistence.criteria;version="[1.1.0,2.1.0)";resolution:=optional,
                             javax.persistence.metamodel;version="[1.1.0,2.1.0)";resolution:=optional,
+                            org.apache.aries.jpa.container;version="[1.0.0,1.1.0)",
+                            org.apache.aries.jpa.container.parsing;version="[1.0.0,1.1.0)",
                             *
                         </Import-Package>
-                        <Export-Package>
-                            org.apache.aries.jpa.container.parsing;version="${pom.version}",
-                            org.apache.aries.jpa.container;version="${pom.version}"
-                        </Export-Package>
                         <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
                         <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>
                     </instructions>

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
Mon Mar  1 13:04:48 2010
@@ -83,6 +83,8 @@
   private Collection<EntityManagerFactoryManager> managersAwaitingProviders = new ArrayList<EntityManagerFactoryManager>();
   /** Plug-point for persistence unit providers */
   private ManagedPersistenceUnitInfoFactory persistenceUnitFactory; 
+  /** Parser for persistence descriptors */
+  private PersistenceDescriptorParser parser;
   /** Configuration for this extender */
   private Properties config;
 
@@ -97,6 +99,15 @@
 			  Bundle.ACTIVE | Bundle.STOPPING);
     this.ctx = ctx;
   }
+
+  /**
+   * Provide a parser implementation
+   * @param parser
+   */
+  public void setParser(PersistenceDescriptorParser descriptorParser) {
+    parser = descriptorParser;
+  }
+
   
   @SuppressWarnings("unchecked")
   @Override
@@ -301,7 +312,7 @@
       //Parse each descriptor
       for(PersistenceDescriptor descriptor : persistenceXmls) {
         try {
-          pUnits.addAll(PersistenceDescriptorParser.parse(b, descriptor));
+          pUnits.addAll(parser.parse(b, descriptor));
         } catch (PersistenceDescriptorParserException e) {
           _logger.error("There was an error while parsing the persistence descriptor " 
               + descriptor.getLocation() + " in bundle " + b.getSymbolicName() 

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
Mon Mar  1 13:04:48 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.aries.jpa.container.parsing;
+package org.apache.aries.jpa.container.parsing.impl;
 
 import java.io.BufferedInputStream;
 import java.io.FilterInputStream;
@@ -30,16 +30,17 @@
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.validation.Schema;
 
-import org.apache.aries.jpa.container.parsing.impl.EarlyParserReturn;
-import org.apache.aries.jpa.container.parsing.impl.JPAHandler;
-import org.apache.aries.jpa.container.parsing.impl.SchemaLocatingHandler;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.apache.aries.jpa.container.parsing.PersistenceDescriptor;
+import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParser;
+import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParserException;
 import org.osgi.framework.Bundle;
 
 /**
  * This class may be used to parse JPA persistence descriptors. The parser validates
  * using the relevant version of the persistence schema as defined by the xml file. 
  */
-public class PersistenceDescriptorParser {
+public class PersistenceDescriptorParserImpl implements PersistenceDescriptorParser {
 
   /**
    * This class is used internally to prevent the first pass parse from
@@ -57,16 +58,10 @@
     }
   }
   
-  /**
-   * Parse the supplied {@link PersistenceDescriptor} 
-   * 
-   * @param b  The bundle that contains the persistence descriptor
-   * @param descriptor The descriptor
-   * 
-   * @return A collection of {@link ParsedPersistenceUnit}
-   * @throws PersistenceDescriptorParserException  if any error occurs in parsing
+  /* (non-Javadoc)
+   * @see org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParser#parse(org.osgi.framework.Bundle,
org.apache.aries.jpa.container.parsing.PersistenceDescriptor)
    */
-  public static Collection<ParsedPersistenceUnit> parse(Bundle b, PersistenceDescriptor
descriptor) throws PersistenceDescriptorParserException {
+  public Collection<ParsedPersistenceUnit> parse(Bundle b, PersistenceDescriptor descriptor)
throws PersistenceDescriptorParserException {
     Collection<ParsedPersistenceUnit> persistenceUnits = new ArrayList<ParsedPersistenceUnit>();
     SAXParserFactory parserFactory = SAXParserFactory.newInstance();
     BufferedInputStream is = null;

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
Mon Mar  1 13:04:48 2010
@@ -20,10 +20,15 @@
     <bean id="container"  class="org.apache.aries.jpa.container.impl.PersistenceBundleManager"
init-method="open" destroy-method="close">
       <argument ref="blueprintBundleContext"/>
       <property name="config"><props/></property>
+      <property name="parser" ref="parser"/>
     </bean>
 
+    <bean id="parser" class="org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParserImpl"/>
+
 	<reference-list interface="javax.persistence.spi.PersistenceProvider" availability="optional">
 	  <reference-listener ref="container" bind-method="addingProvider" unbind-method="removingProvider"/>
 	</reference-list>
     
+    <service interface="org.apache.aries.jpa.container.parsing.PersistenceDescriptorParser"
ref="parser"/>
+    
 </blueprint>

Modified: incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java
Mon Mar  1 13:04:48 2010
@@ -46,6 +46,7 @@
 
 import org.apache.aries.jpa.container.impl.EntityManagerFactoryManager;
 import org.apache.aries.jpa.container.impl.PersistenceBundleManager;
+import org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParserImpl;
 import org.apache.aries.jpa.container.util.FakeManagedPersistenceUnitFactory;
 import org.apache.aries.mocks.BundleContextMock;
 import org.apache.aries.mocks.BundleMock;
@@ -109,6 +110,7 @@
 
     extenderBundle = Skeleton.newMock(new BundleMock("extender", new Hashtable<String,
Object>()), Bundle.class);
 //    Skeleton.getSkeleton(extenderBundle).setReturnValue(new MethodCall(Bundle.class, "getResource",
"schemas/persistence_1_0.xsd"), new File("unittest/resources/persistence_1_0.xsd").toURI().toURL());
+    
   }
 
   @After
@@ -128,6 +130,7 @@
     
     mgr = new PersistenceBundleManager(extenderContext);
     mgr.setConfig(new Properties());
+    mgr.setParser(new PersistenceDescriptorParserImpl());
     return extenderContext;
   }
   
@@ -325,6 +328,7 @@
     
     mgr = new PersistenceBundleManager(extenderContext);
     mgr.setConfig(new Properties());
+    mgr.setParser(new PersistenceDescriptorParserImpl());
     mgr.open();
     
     Hashtable<String,String> hash1 = new Hashtable<String, String>();
@@ -516,6 +520,7 @@
     
     mgr = new PersistenceBundleManager(extenderContext);
     mgr.setConfig(new Properties());
+    mgr.setParser(new PersistenceDescriptorParserImpl());
     
     Hashtable<String,String> hash1 = new Hashtable<String, String>();
     hash1.put("javax.persistence.provider", "no.such.Provider");

Modified: incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java
(original)
+++ incubator/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java
Mon Mar  1 13:04:48 2010
@@ -35,6 +35,7 @@
 import java.util.Properties;
 
 import org.apache.aries.jpa.container.impl.PersistenceDescriptorImpl;
+import org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParserImpl;
 import org.apache.aries.unittest.mocks.Skeleton;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
@@ -57,7 +58,7 @@
       
       Bundle b = Skeleton.newMock(Bundle.class);
       
-      Collection<ParsedPersistenceUnit> parsedUnits = PersistenceDescriptorParser.parse(b,
descriptor);
+      Collection<ParsedPersistenceUnit> parsedUnits = new PersistenceDescriptorParserImpl().parse(b,
descriptor);
       assertEquals("An incorrect number of persistence units has been returned.", 4, parsedUnits.size());
       
       List<ParsedPersistenceUnit> units = getList(parsedUnits);
@@ -207,7 +208,7 @@
 
       Bundle b = Skeleton.newMock(Bundle.class);
       
-      Collection<ParsedPersistenceUnit> parsedUnits = PersistenceDescriptorParser.parse(b,
descriptor);
+      Collection<ParsedPersistenceUnit> parsedUnits = new PersistenceDescriptorParserImpl().parse(b,
descriptor);
       assertEquals("An incorrect number of persistence units has been returned.", 0, parsedUnits.size());
     } finally {
       if(is != null)
@@ -227,7 +228,7 @@
       
       Bundle b = Skeleton.newMock(Bundle.class);
       
-      Collection<ParsedPersistenceUnit> parsedUnits = PersistenceDescriptorParser.parse(b,
descriptor);
+      Collection<ParsedPersistenceUnit> parsedUnits = new PersistenceDescriptorParserImpl().parse(b,
descriptor);
 
       fail("Parsing should not succeed");
     } finally {
@@ -246,7 +247,7 @@
       PersistenceDescriptor descriptor = new PersistenceDescriptorImpl(location, is);
       
       Bundle b = Skeleton.newMock(Bundle.class);
-      List<ParsedPersistenceUnit> parsedUnits = getList(PersistenceDescriptorParser.parse(b,
descriptor));
+      List<ParsedPersistenceUnit> parsedUnits = getList(new PersistenceDescriptorParserImpl().parse(b,
descriptor));
       
       assertEquals(2, parsedUnits.size());
       

Modified: incubator/aries/trunk/jpa/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/pom.xml?rev=917507&r1=917506&r2=917507&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/pom.xml (original)
+++ incubator/aries/trunk/jpa/pom.xml Mon Mar  1 13:04:48 2010
@@ -37,7 +37,11 @@
     </scm>
     <dependencyManagement>
         <dependencies>
-
+            <dependency>
+                <groupId>org.apache.aries.jpa</groupId>
+                <artifactId>org.apache.aries.jpa.api</artifactId>
+                <version>${version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.aries.jpa</groupId>
                 <artifactId>org.apache.aries.jpa.blueprint.aries</artifactId>
@@ -73,11 +77,6 @@
                 <artifactId>org.apache.aries.jpa.container.itest.bundle</artifactId>
                 <version>${version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.apache.aries.jpa</groupId>
-                <artifactId>org.apache.aries.jpa.context.itest</artifactId>
-                <version>${version}</version>
-            </dependency>
 
 
             <dependency>
@@ -125,7 +124,7 @@
             <dependency>
                 <groupId>org.apache.openjpa</groupId>
                 <artifactId>openjpa</artifactId>
-                <version>2.0.0-SNAPSHOT</version>
+                <version>2.0.0-beta2</version>
             </dependency>
             <dependency>
                 <groupId>commons-lang</groupId>
@@ -166,6 +165,7 @@
         </dependencies>
     </dependencyManagement>
     <modules>
+        <module>jpa-api</module>
         <module>jpa-container</module>
         <module>jpa-container-context</module>
         <module>jpa-blueprint-aries</module>



Mime
View raw message