geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r534748 [1/2] - in /geronimo/server/trunk: assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/ configs/j2ee-security/src/plan/ configs/j2ee-server/src/plan/ configs/jetty6-deployer/src/plan/ configs/openejb-deployer/src/plan...
Date Thu, 03 May 2007 08:07:12 GMT
Author: djencks
Date: Thu May  3 01:07:09 2007
New Revision: 534748

URL: http://svn.apache.org/viewvc?view=rev&rev=534748
Log:
GERONIMO-3131 GERONIMO-3132 GERONIMO-3133 GERONIMO-3134  Defaults for persistence units. Supply locations of jars with persistent classes to the PersistenceUnitInfo. Match a ref with not persistence unit specified to a unique match. Allow wars to have jndi references pointing to the war module, not just the ear

Modified:
    geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/server-log4j.properties
    geronimo/server/trunk/configs/j2ee-security/src/plan/plan.xml
    geronimo/server/trunk/configs/j2ee-server/src/plan/plan.xml
    geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/openejb-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/persistence-jpa10-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/tomcat6-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/webconsole-tomcat/pom.xml
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaRefBuilder.java
    geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java
    geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/proxy/CORBAProxyReference.java
    geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/ApplicationInfo.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
    geronimo/server/trunk/modules/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
    geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ConfigurationAwareReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/GBeanReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/HandleDelegateReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ORBReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceUnitReference.java
    geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ResourceReference.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/schema/geronimo-openejb-2.0.xsd
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbReference.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
    geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/server-log4j.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/server-log4j.properties?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/server-log4j.properties (original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/resources/var/log/server-log4j.properties Thu May  3 01:07:09 2007
@@ -134,3 +134,7 @@
 #log4j.logger.httpclient.wire.header=DEBUG
 #log4j.logger.org.apache.commons.httpclient=DEBUG
 
+#log4j.logger.openjpa.Runtime=TRACE
+#log4j.logger.openjpa.Enhance=TRACE
+#log4j.logger.openjpa.SQL=TRACE
+log4j.logger.openjpa=TRACE
\ No newline at end of file

Modified: geronimo/server/trunk/configs/j2ee-security/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/j2ee-security/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/j2ee-security/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/j2ee-security/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -83,7 +83,7 @@
         <reference name="ServerInfo"><name>ServerInfo</name></reference>
         <reference name="LoginService"><name>JaasLoginService</name></reference>
     </gbean>
-    
+
     <gbean name="properties-login" class="org.apache.geronimo.security.jaas.JaasLoginModuleUse">
          <attribute name="controlFlag">REQUIRED</attribute>
          <reference name="LoginModule">

Modified: geronimo/server/trunk/configs/j2ee-server/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/j2ee-server/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/j2ee-server/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/j2ee-server/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -94,6 +94,8 @@
            javax.xml.soap.MetaFactory=org.apache.geronimo.webservices.saaj.GeronimoMetaFactory
 
            org.apache.cxf.jaxws.checkPublishEndpointPermission=true
+
+             
          </attribute>
     </gbean>
 

Modified: geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -87,9 +87,6 @@
             <pattern>
                 <name>GBeanBuilder</name>
             </pattern>
-            <pattern>
-                <name>PersistenceUnitBuilder</name>
-            </pattern>
         </references>
         <references name="WebServiceBuilder">
             <pattern>
@@ -112,6 +109,9 @@
             <name>JettyClusteringBuilder</name>
         </reference>
         <references name="ModuleBuilderExtensions">
+            <pattern>
+                <name>PersistenceUnitBuilder</name>
+            </pattern>
             <pattern>
                 <name>MyFacesModuleBuilderExtension</name>
             </pattern>

Modified: geronimo/server/trunk/configs/openejb-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb-deployer/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/openejb-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/openejb-deployer/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -25,18 +25,21 @@
             <name>OpenEjbSystem</name>
         </reference>
         <references name="ModuleBuilderExtensions">
-          <pattern>
-            <name>CXFModuleBuilderExtension</name>
-          </pattern>
-          <pattern>
-            <name>Axis2ModuleBuilderExtension</name>
-          </pattern>        
-          <pattern>
-            <name>AxisModuleBuilderExtension</name>
-          </pattern>       
-          <pattern>
-            <name>CorbaModuleBuilderExtension</name>
-          </pattern>          
+            <pattern>
+                <name>PersistenceUnitBuilder</name>
+            </pattern>
+            <pattern>
+                <name>CXFModuleBuilderExtension</name>
+            </pattern>
+            <pattern>
+                <name>Axis2ModuleBuilderExtension</name>
+            </pattern>
+            <pattern>
+                <name>AxisModuleBuilderExtension</name>
+            </pattern>
+            <pattern>
+                <name>CorbaModuleBuilderExtension</name>
+            </pattern>
         </references>
         <reference name="SecurityBuilders">
             <name>SecurityBuilder</name>

Modified: geronimo/server/trunk/configs/persistence-jpa10-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/persistence-jpa10-deployer/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/persistence-jpa10-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/persistence-jpa10-deployer/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -21,6 +21,14 @@
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
 
     <gbean name="PersistenceUnitBuilder" class="org.apache.geronimo.persistence.builder.PersistenceUnitBuilder">
+        <attribute name="defaultPersistenceProviderClassName">org.apache.openjpa.persistence.PersistenceProviderImpl</attribute>
+        <attribute name="defaultPersistenceUnitProperties">
+            openjpa.Log=commons
+            openjpa.ClassTransformerOptions=ScanDevPath=true
+            openjpa.jdbc.DBDictionary=org.apache.openjpa.jdbc.sql.DerbyDictionary
+            openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true,SchemaAction='add,deleteTableContents')
+            openjpa.Sequence=table(Table=OPENJPASEQ, Increment=100)
+        </attribute>
         <xml-attribute name="defaultEnvironment">
             <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
                 <dependencies>
@@ -62,6 +70,14 @@
     </gbean>
 
     <gbean name="ClientPersistenceUnitBuilder" class="org.apache.geronimo.persistence.builder.PersistenceUnitBuilder">
+        <attribute name="defaultPersistenceProviderClassName">org.apache.openjpa.persistence.PersistenceProviderImpl</attribute>
+        <attribute name="defaultPersistenceUnitProperties">
+            openjpa.Log=commons
+            openjpa.ClassTransformerOptions=ScanDevPath=true;
+            openjpa.jdbc.DBDictionary=org.apache.openjpa.jdbc.sql.DerbyDictionary
+            openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true,SchemaAction='add,deleteTableContents')
+            openjpa.Sequence=table(Table=OPENJPASEQ, Increment=100)
+        </attribute>
         <xml-attribute name="defaultEnvironment">
             <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
                 <dependencies>

Modified: geronimo/server/trunk/configs/tomcat6-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/tomcat6-deployer/src/plan/plan.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/tomcat6-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/tomcat6-deployer/src/plan/plan.xml Thu May  3 01:07:09 2007
@@ -29,9 +29,6 @@
             <pattern>
                 <name>GBeanBuilder</name>
             </pattern>
-            <pattern>
-                <name>PersistenceUnitBuilder</name>
-            </pattern>
         </references>
         <references name="WebServiceBuilder">
             <pattern>
@@ -51,6 +48,9 @@
             <name>NamingBuilders</name>
         </reference>
         <references name="ModuleBuilderExtensions">
+            <pattern>
+                <name>PersistenceUnitBuilder</name>
+            </pattern>
             <pattern>
                 <name>MyFacesModuleBuilderExtension</name>
             </pattern>

Modified: geronimo/server/trunk/configs/webconsole-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/webconsole-tomcat/pom.xml?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/configs/webconsole-tomcat/pom.xml (original)
+++ geronimo/server/trunk/configs/webconsole-tomcat/pom.xml Thu May  3 01:07:09 2007
@@ -78,7 +78,6 @@
             <artifactId>tomcat6-deployer</artifactId>
             <version>${version}</version>
             <type>car</type>
-            <scope>provided</scope>
         </dependency>
 
         <dependency>
@@ -201,6 +200,13 @@
             <artifactId>xercesImpl</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>tomcat6-deployer</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     
     <build>

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java Thu May  3 01:07:09 2007
@@ -147,7 +147,7 @@
                     getJndiContextMap(componentContext).put(ENV + name, linkRef);
                 } else {
                     AbstractNameQuery containerId = getAdminObjectContainerId(name, gerResourceEnvRef);
-                    Reference ref = buildAdminObjectReference(localConfiguration, containerId, iface);
+                    Reference ref = buildAdminObjectReference(localConfiguration, remoteConfiguration, containerId, iface);
                     getJndiContextMap(componentContext).put(ENV + name, ref);
                 }
             } catch (UnresolvedReferenceException e) {
@@ -206,7 +206,7 @@
             //try to resolve ref based only matching resource-ref-name
             //throws exception if it can't locate ref.
             AbstractNameQuery containerId = buildAbstractNameQuery(null, moduleURI, linkName, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
-            Reference ref = buildAdminObjectReference(localConfiguration, containerId, iface);
+            Reference ref = buildAdminObjectReference(localConfiguration, remoteConfiguration, containerId, iface);
             getJndiContextMap(componentContext).put(ENV + name, ref);
 
         }
@@ -245,13 +245,13 @@
     }
 
 
-    private Reference buildAdminObjectReference(Configuration localConfiguration, AbstractNameQuery containerId, Class iface) throws DeploymentException {
+    private Reference buildAdminObjectReference(Configuration localConfiguration, Configuration remoteConfiguration, AbstractNameQuery containerId, Class iface) throws DeploymentException {
         try {
             localConfiguration.findGBean(containerId);
         } catch (GBeanNotFoundException e) {
             throw new DeploymentException("Can not resolve admin object ref " + containerId + " in configuration " + localConfiguration.getId());
         }
-        return new ResourceReference(localConfiguration.getId(), containerId, iface);
+        return new ResourceReference(getConfigId(localConfiguration, remoteConfiguration), containerId, iface);
     }
 
     private static AbstractNameQuery getAdminObjectContainerId(String name, GerResourceEnvRefType gerResourceEnvRef) {

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java Thu May  3 01:07:09 2007
@@ -147,7 +147,7 @@
 
                     localConfiguration.findGBean(containerId);
 
-                    Reference ref = new ResourceReference(localConfiguration.getId(), containerId, iface);
+                    Reference ref = new ResourceReference(getConfigId(localConfiguration, remoteConfiguration), containerId, iface);
                     getJndiContextMap(componentContext).put(ENV + name, ref);
                 } catch (GBeanNotFoundException e) {
 

Modified: geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaRefBuilder.java Thu May  3 01:07:09 2007
@@ -62,7 +62,7 @@
             if (corbaGBeanNameSource != null) {
                 AbstractNameQuery corbaName = corbaGBeanNameSource.getCorbaGBeanName();
                 if (corbaName != null) {
-                    Artifact moduleId = localConfiguration.getId();
+                    Artifact[] moduleId = getConfigId(localConfiguration, remoteConfiguration);
                     Map context = getJndiContextMap(componentContext);
                     context.put("ORB", new ORBReference(moduleId, corbaName));
                     context.put("HandleDelegate", new HandleDelegateReference(moduleId, corbaName));

Modified: geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java Thu May  3 01:07:09 2007
@@ -33,6 +33,7 @@
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.openejb.deployment.EjbRefBuilder;
 import org.apache.geronimo.schema.NamespaceElementConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefDocument;
@@ -105,14 +106,14 @@
             addInjections(ejbRefName, ejbRef.getInjectionTargetArray(), componentContext);
             GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
 
-            Reference ejbReference = addEJBRef(localConfiguration, module.getModuleURI(), ejbRef, remoteRef, cl);
+            Reference ejbReference = addEJBRef(localConfiguration, remoteConfiguration, module.getModuleURI(), ejbRef, remoteRef, cl);
             if (ejbReference != null) {
                 getJndiContextMap(componentContext).put(ENV + ejbRefName, ejbReference);
             }
         }
     }
 
-    private Reference addEJBRef(Configuration earContext, URI moduleURI, EjbRefType ejbRef, GerEjbRefType remoteRef, ClassLoader cl) throws DeploymentException {
+    private Reference addEJBRef(Configuration localConfiguration, Configuration earConfiguration, URI moduleURI, EjbRefType ejbRef, GerEjbRefType remoteRef, ClassLoader cl) throws DeploymentException {
         Reference ejbReference = null;
         if (remoteRef != null && remoteRef.isSetNsCorbaloc()) {
             String refName = getStringValue(ejbRef.getEjbRefName());
@@ -134,13 +135,13 @@
 
                 // verify the cssBean query is valid
                 try {
-                    earContext.findGBean(cssBean);
+                    localConfiguration.findGBean(cssBean);
                 } catch (GBeanNotFoundException e) {
-                    throw new DeploymentException("Could not find css bean matching " + cssBean + " from configuration " + earContext.getId());
+                    throw new DeploymentException("Could not find css bean matching " + cssBean + " from configuration " + localConfiguration.getId());
                 }
 
                 // create ref
-                ejbReference = new CORBAProxyReference(earContext.getId(), cssBean, new URI(remoteRef.getNsCorbaloc().trim()), remoteRef.getName().trim(), home);
+                ejbReference = new CORBAProxyReference(getConfigId(localConfiguration, earConfiguration), cssBean, new URI(remoteRef.getNsCorbaloc().trim()), remoteRef.getName().trim(), home);
             } catch (URISyntaxException e) {
                 throw new DeploymentException("Could not construct CORBA NameServer URI: " + remoteRef.getNsCorbaloc(), e);
             }

Modified: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/proxy/CORBAProxyReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/proxy/CORBAProxyReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/proxy/CORBAProxyReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/proxy/CORBAProxyReference.java Thu May  3 01:07:09 2007
@@ -40,7 +40,7 @@
     private final String objectName;
     private final String home;
 
-    public CORBAProxyReference(Artifact configId, AbstractNameQuery abstractNameQuery, URI nsCorbaloc, String objectName, String home) {
+    public CORBAProxyReference(Artifact[] configId, AbstractNameQuery abstractNameQuery, URI nsCorbaloc, String objectName, String home) {
         super(configId, abstractNameQuery);
         this.nsCorbaloc = nsCorbaloc;
         this.objectName = objectName;

Modified: geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java Thu May  3 01:07:09 2007
@@ -28,6 +28,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -36,7 +37,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.Collections;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -49,8 +49,8 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Naming;
@@ -252,6 +252,61 @@
      */
     public void addInclude(URI targetPath, File source) throws IOException {
         resourceContext.addInclude(targetPath, source);
+    }
+
+    /**
+     * Recursively construct the complete set of paths in the ear for the manifest classpath of the supplied modulefile.
+     * Used only in PersistenceUnitBuilder to figure out if a persistence.xml relates to the starting module.  Having a classloader for
+     * each ejb module would eliminate the need for this and be more elegant.
+     */
+    public void getCompleteManifestClassPath(JarFile moduleFile, URI moduleBaseUri, LinkedHashSet<String> classpath) throws DeploymentException {
+        Manifest manifest;
+        try {
+            manifest = moduleFile.getManifest();
+        } catch (IOException e) {
+            throw new DeploymentException("Could not read manifest: " + moduleBaseUri);
+        }
+
+        if (manifest == null) {
+            return;
+        }
+        String manifestClassPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+        if (manifestClassPath == null) {
+            return;
+        }
+
+        for (StringTokenizer tokenizer = new StringTokenizer(manifestClassPath, " "); tokenizer.hasMoreTokens();) {
+            String path = tokenizer.nextToken();
+
+            URI pathUri;
+            try {
+                pathUri = new URI(path);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("Invalid manifest classpath entry: module=" + moduleBaseUri + ", path=" + path);
+            }
+
+            if (!pathUri.getPath().endsWith(".jar")) {
+                throw new DeploymentException("Manifest class path entries must end with the .jar extension (J2EE 1.4 Section 8.2): module=" + moduleBaseUri);
+            }
+            if (pathUri.isAbsolute()) {
+                throw new DeploymentException("Manifest class path entries must be relative (J2EE 1.4 Section 8.2): moduel=" + moduleBaseUri);
+            }
+
+            URI targetUri = moduleBaseUri.resolve(pathUri);
+            if (targetUri.getPath().endsWith("/")) {
+                throw new IllegalStateException("target path must not end with a '/' character: " + targetUri);
+            }
+            classpath.add(targetUri.toString());
+            File targetFile = getTargetFile(targetUri);
+            JarFile classPathJarFile;
+            try {
+                classPathJarFile = new JarFile(targetFile);
+            } catch (IOException e) {
+                throw new DeploymentException("Manifest class path entries must be a valid jar file (JAVAEE 5 Section 8.2): jarFile=" + targetFile + ", path=" + path, e);
+            }
+
+            getCompleteManifestClassPath(classPathJarFile, targetUri, classpath);
+        }
     }
 
     /**

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/ApplicationInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/ApplicationInfo.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/ApplicationInfo.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/ApplicationInfo.java Thu May  3 01:07:09 2007
@@ -18,84 +18,39 @@
 
 import java.util.Set;
 import java.util.LinkedHashSet;
+import java.util.jar.JarFile;
 
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.xmlbeans.XmlObject;
 
 /**
  * @version $Revision$ $Date$
  */
-public class ApplicationInfo {
+public class ApplicationInfo extends Module {
     private ConfigurationModuleType type;
-    private Environment environment;
-    private AbstractName baseName;
-    private XmlObject specDD;
-    private XmlObject vendorDD;
     private LinkedHashSet modules;
     private Set moduleLocations;
-    private String originalSpecDD;
 
-    public ApplicationInfo() {
-    }
 
-    public ApplicationInfo(ConfigurationModuleType type, Environment environment, AbstractName baseName, XmlObject specDD, XmlObject vendorDD, LinkedHashSet modules, Set moduleLocations, String originalSpecDD) {
+    public ApplicationInfo(ConfigurationModuleType type, Environment environment, AbstractName baseName, JarFile earFile, XmlObject specDD, XmlObject vendorDD, LinkedHashSet modules, Set moduleLocations, String originalSpecDD) {
+        super(true, baseName, environment, earFile, "", specDD, vendorDD, originalSpecDD, null, null);
         assert type != null;
         assert environment != null;
         assert modules != null;
         assert moduleLocations != null;
 
         this.type = type;
-        this.environment = environment;
-        this.baseName = baseName;
-        this.specDD = specDD;
-        this.vendorDD = vendorDD;
         this.modules = modules;
         this.moduleLocations = moduleLocations;
-        this.originalSpecDD = originalSpecDD;
     }
 
     public ConfigurationModuleType getType() {
         return type;
     }
 
-    public void setType(ConfigurationModuleType type) {
-        this.type = type;
-    }
-
-    public Environment getEnvironment() {
-        return environment;
-    }
-
-    public void setEnvironment(Environment environment) {
-        this.environment = environment;
-    }
-
-    public AbstractName getBaseName() {
-        return baseName;
-    }
-
-    public void setBaseName(AbstractName baseName) {
-        this.baseName = baseName;
-    }
-
-    public XmlObject getVendorDD() {
-        return vendorDD;
-    }
-
-    public void setVendorDD(XmlObject vendorDD) {
-        this.vendorDD = vendorDD;
-    }
-
-    public XmlObject getSpecDD() {
-        return specDD;
-    }
-
-    public void setSpecDD(XmlObject specDD) {
-        this.specDD = specDD;
-    }
-
     public LinkedHashSet getModules() {
         return modules;
     }
@@ -112,11 +67,4 @@
         this.moduleLocations = moduleLocations;
     }
 
-    public String getOriginalSpecDD() {
-        return originalSpecDD;
-    }
-
-    public void setOriginalSpecDD(String originalSpecDD) {
-        this.originalSpecDD = originalSpecDD;
-    }
-}
+}
\ No newline at end of file

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Thu May  3 01:07:09 2007
@@ -91,7 +91,6 @@
 import org.apache.geronimo.xbeans.javaee.ApplicationDocument;
 import org.apache.geronimo.xbeans.javaee.ApplicationType;
 import org.apache.geronimo.xbeans.javaee.ModuleType;
-import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -115,7 +114,7 @@
     private final SingleElementCollection resourceReferenceBuilder;
     private final NamespaceDrivenBuilderCollection securityBuilders;
     private final NamespaceDrivenBuilderCollection serviceBuilders;
-    private final NamespaceDrivenBuilderCollection persistenceUnitBuilders;
+    private final Collection<ModuleBuilderExtension> persistenceUnitBuilders;
 
     private final Environment defaultEnvironment;
     private final AbstractNameQuery serverName;
@@ -141,7 +140,7 @@
             Collection appClientConfigBuilder,
             Collection securityBuilders,
             Collection serviceBuilders,
-            Collection<NamespaceDrivenBuilder> persistenceUnitBuilders,
+            Collection<ModuleBuilderExtension> persistenceUnitBuilders,
             Kernel kernel) {
         this(defaultEnvironment,
                 transactionManagerAbstractName,
@@ -178,7 +177,7 @@
             ModuleBuilder appClientConfigBuilder,
             NamespaceDrivenBuilder securityBuilder,
             NamespaceDrivenBuilder serviceBuilder,
-            NamespaceDrivenBuilder persistenceUnitBuilder,
+            ModuleBuilderExtension persistenceUnitBuilder,
             Naming naming) {
         this(defaultEnvironment,
                 transactionManagerAbstractName,
@@ -216,7 +215,7 @@
             SingleElementCollection appClientConfigBuilder,
             Collection securityBuilders,
             Collection serviceBuilders,
-            Collection<NamespaceDrivenBuilder> persistenceUnitBuilders,
+            Collection<ModuleBuilderExtension> persistenceUnitBuilders,
             Naming naming) {
         this.configurationManager = configurationManager;
         this.repositories = repositories;
@@ -229,7 +228,7 @@
         this.appClientConfigBuilder = appClientConfigBuilder;
         this.securityBuilders = new NamespaceDrivenBuilderCollection(securityBuilders, GerSecurityDocument.type.getDocumentElementName());
         this.serviceBuilders = new NamespaceDrivenBuilderCollection(serviceBuilders, GBeanBuilder.SERVICE_QNAME);
-        this.persistenceUnitBuilders = new NamespaceDrivenBuilderCollection(persistenceUnitBuilders, QName.valueOf("Placeholder-Not-Used"));
+        this.persistenceUnitBuilders = persistenceUnitBuilders;
         
         this.transactionManagerObjectName = transactionManagerAbstractName;
         this.connectionTrackerObjectName = connectionTrackerAbstractName;
@@ -295,6 +294,7 @@
         return new ApplicationInfo(module.getType(),
                 module.getEnvironment(),
                 module.getModuleName(),
+                jarFile,
                 null,
                 null,
                 new LinkedHashSet<Module>(Collections.singleton(module)),
@@ -391,6 +391,7 @@
         return new ApplicationInfo(ConfigurationModuleType.EAR,
                 environment,
                 earName,
+                earFile,
                 application,
                 gerApplication,
                 modules,
@@ -501,16 +502,20 @@
                     configurationManager,
                     repositories,
                     serverName,
-                    applicationInfo.getBaseName(),
+                    applicationInfo.getModuleName(),
                     transactionManagerObjectName,
                     connectionTrackerObjectName,
                     transactionalTimerObjectName,
                     nonTransactionalTimerObjectName,
                     corbaGBeanObjectName
             );
+            applicationInfo.setEarContext(earContext);
+            applicationInfo.setRootEarContext(earContext);
 
             // Copy over all files that are _NOT_ modules (e.g. META-INF and APP-INF files)
             Set moduleLocations = applicationInfo.getModuleLocations();
+            //TODO make LibClassPath a non-inner class and use it for manifestcp.
+            LinkedHashSet<String> manifestcp = new LinkedHashSet<String>();
             if (ConfigurationModuleType.EAR == applicationType && earFile != null) {
                 //get the value of the library-directory element in spec DD
                 ApplicationType specDD = (ApplicationType) applicationInfo.getSpecDD();
@@ -531,6 +536,7 @@
                         NestedJarFile library = new NestedJarFile(earFile, entry.getName());
                         earContext.addIncludeAsPackedJar(URI.create(entry.getName()), library);
                         libClasspath.add(entry.getName());
+                        manifestcp.add(entry.getName());
                     } else if (addEntry) {
                         earContext.addFile(URI.create(entry.getName()), earFile, entry);
                     }
@@ -566,7 +572,10 @@
             
             if (ConfigurationModuleType.EAR == applicationType) {
                 // process persistence unit in EAR library directory
-                persistenceUnitBuilders.build(geronimoApplication, earContext, earContext);
+                earContext.getGeneralData().put("ManifestClassPath", manifestcp);
+                for (ModuleBuilderExtension mbe: persistenceUnitBuilders) {
+                    mbe.initContext(earContext, applicationInfo, earContext.getClassLoader());
+                }
                 
                 // Create the J2EEApplication managed object
                 GBeanData gbeanData = new GBeanData(earContext.getModuleName(), J2EEApplicationImpl.GBEAN_INFO);
@@ -1054,7 +1063,7 @@
         infoBuilder.addReference("AppClientConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("SecurityBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("PersistenceUnitBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
+        infoBuilder.addReference("PersistenceUnitBuilders", ModuleBuilderExtension.class, NameFactory.MODULE_BUILDER);
 
         infoBuilder.addAttribute("kernel", Kernel.class, false);
 

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java Thu May  3 01:07:09 2007
@@ -75,7 +75,7 @@
     
     protected static final NamespaceDrivenBuilder serviceBuilder = null;
 
-    protected static final NamespaceDrivenBuilder persistenceUnitBuilder = null;
+    protected static final ModuleBuilderExtension persistenceUnitBuilder = null;
 
     protected static final Naming naming = new Jsr77Naming();
 

Modified: geronimo/server/trunk/modules/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/modules/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java Thu May  3 01:07:09 2007
@@ -150,7 +150,7 @@
         ClassFinder classFinder = createJspClassFinder(webApp, webModule, listenerNames);
         webModule.setClassFinder(classFinder);
 
-        namingBuilders.buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, webModule, buildingContext);
+        namingBuilders.buildNaming(webApp, jettyWebApp, moduleContext.getConfiguration(), earConfiguration, webModule, buildingContext);
 
         //only try to install it if reference will work.
         //Some users (tomcat?) may have back doors into jasper that make adding this gbean unnecessary.

Modified: geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java Thu May  3 01:07:09 2007
@@ -156,7 +156,7 @@
         ClassFinder classFinder = createMyFacesClassFinder(webApp, webModule);
         webModule.setClassFinder(classFinder);
 
-        namingBuilders.buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, webModule, buildingContext);
+        namingBuilders.buildNaming(webApp, jettyWebApp, moduleContext.getConfiguration(), earConfiguration, webModule, buildingContext);
 
         AbstractName providerName = moduleContext.getNaming().createChildName(moduleName, "jsf-lifecycle", "jsf");
         GBeanData providerData = new GBeanData(providerName, LifecycleProviderGBean.GBEAN_INFO);

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java Thu May  3 01:07:09 2007
@@ -35,7 +35,6 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.annotation.Injection;
-import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -299,6 +298,13 @@
             String targetClassName = injectionTarget.getInjectionTargetClass().getStringValue().trim();
             holder.addInjection(targetClassName, new Injection(targetClassName, targetName, jndiName));
         }
+    }
+
+    protected static Artifact[] getConfigId(Configuration localConfiguration, Configuration earConfiguration) {
+        if (localConfiguration == earConfiguration) {
+            return new Artifact[] {earConfiguration.getId()};
+        }
+        return new Artifact[] {earConfiguration.getId(),localConfiguration.getId()};
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java Thu May  3 01:07:09 2007
@@ -46,7 +46,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public class GBeanRefBuilder implements NamingBuilder {
+public class GBeanRefBuilder extends AbstractNamingBuilder {
     private static final QName GBEAN_REF_QNAME = GerGbeanRefDocument.type.getDocumentElementName();
     private static final QNameSet GBEAN_REF_QNAME_SET = QNameSet.singleton(GBEAN_REF_QNAME);
 
@@ -98,7 +98,7 @@
 
             String refName = gbeanRef.getRefName();
 
-            NamingBuilder.JNDI_KEY.get(componentContext).put(ENV + refName, new GBeanReference(localConfiguration.getId(), queries, gBeanType));
+            NamingBuilder.JNDI_KEY.get(componentContext).put(ENV + refName, new GBeanReference(getConfigId(localConfiguration, remoteConfiguration), queries, gBeanType));
 
         }
     }

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ConfigurationAwareReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ConfigurationAwareReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ConfigurationAwareReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ConfigurationAwareReference.java Thu May  3 01:07:09 2007
@@ -28,6 +28,7 @@
 
 import java.util.Set;
 import java.util.Collections;
+import java.util.List;
 
 /**
  * TODO: document me
@@ -39,15 +40,17 @@
  */
 public abstract class ConfigurationAwareReference extends SimpleAwareReference {
     private static final long serialVersionUID = 283358809226901462L;
-    private final Artifact configId;
-    protected final Set abstractNameQueries;
+    private final Artifact[] configId;
+    protected final Set<AbstractNameQuery> abstractNameQueries;
 
-    protected ConfigurationAwareReference(Artifact configId, AbstractNameQuery abstractNameQuery) {
-        this.configId = configId;
-        this.abstractNameQueries = Collections.singleton(abstractNameQuery);
+    protected ConfigurationAwareReference(Artifact[] configId, AbstractNameQuery abstractNameQuery) {
+        this(configId, Collections.singleton(abstractNameQuery));
     }
 
-    protected ConfigurationAwareReference(Artifact configId, Set abstractNameQueries) {
+    protected ConfigurationAwareReference(Artifact[] configId, Set<AbstractNameQuery> abstractNameQueries) {
+        if (configId == null || configId.length == 0) {
+            throw new NullPointerException("No configId");
+        }
         this.configId = configId;
         this.abstractNameQueries = abstractNameQueries;
     }
@@ -55,7 +58,18 @@
     public Configuration getConfiguration() {
         Kernel kernel = getKernel();
         ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
-        return configurationManager.getConfiguration(configId);
+        Configuration configuration =  configurationManager.getConfiguration(configId[0]);
+        next: for (int i = 1; i < configId.length; i++) {
+            List<Configuration> children = configuration.getChildren();
+            for (Configuration child: children) {
+                if (child.getId().equals(configId[i])) {
+                    configuration = child;
+                    break next;
+                }
+            }
+            throw new IllegalStateException("No configuration found for id: " + configId[i]);
+        }
+        return configuration;
     }
 
     public AbstractName resolveTargetName() throws GBeanNotFoundException {

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/GBeanReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/GBeanReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/GBeanReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/GBeanReference.java Thu May  3 01:07:09 2007
@@ -31,7 +31,7 @@
 public class GBeanReference extends ConfigurationAwareReference {
     private final Class type;
 
-    public GBeanReference(Artifact configId, Set abstractNameQueries, Class type) {
+    public GBeanReference(Artifact[] configId, Set abstractNameQueries, Class type) {
         super(configId, abstractNameQueries);
         this.type = type;
     }

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/HandleDelegateReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/HandleDelegateReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/HandleDelegateReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/HandleDelegateReference.java Thu May  3 01:07:09 2007
@@ -29,7 +29,7 @@
  */
 public class HandleDelegateReference extends ConfigurationAwareReference {
 
-    public HandleDelegateReference(Artifact configId, AbstractNameQuery abstractNameQuery) {
+    public HandleDelegateReference(Artifact[] configId, AbstractNameQuery abstractNameQuery) {
         super(configId, abstractNameQuery);
     }
 

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ORBReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ORBReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ORBReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ORBReference.java Thu May  3 01:07:09 2007
@@ -29,7 +29,7 @@
  */
 public class ORBReference extends ConfigurationAwareReference {
 
-    public ORBReference(Artifact configId, AbstractNameQuery abstractNameQuery) {
+    public ORBReference(Artifact[] configId, AbstractNameQuery abstractNameQuery) {
         super(configId, abstractNameQuery);
     }
 

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceContextReference.java Thu May  3 01:07:09 2007
@@ -35,7 +35,7 @@
     private boolean transactionScoped;
     private Map properties;
 
-    public PersistenceContextReference(Artifact configId, AbstractNameQuery abstractNameQuery, boolean transactionScoped, Map properties) {
+    public PersistenceContextReference(Artifact[] configId, AbstractNameQuery abstractNameQuery, boolean transactionScoped, Map properties) {
         super(configId, abstractNameQuery);
         this.transactionScoped = transactionScoped;
         this.properties = properties;

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceUnitReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceUnitReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceUnitReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/PersistenceUnitReference.java Thu May  3 01:07:09 2007
@@ -30,7 +30,7 @@
 public class PersistenceUnitReference extends ConfigurationAwareReference {
 
 
-    public PersistenceUnitReference(Artifact configId, AbstractNameQuery abstractNameQuery) {
+    public PersistenceUnitReference(Artifact[] configId, AbstractNameQuery abstractNameQuery) {
         super(configId, abstractNameQuery);
     }
 

Modified: geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ResourceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ResourceReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ResourceReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/reference/ResourceReference.java Thu May  3 01:07:09 2007
@@ -37,7 +37,7 @@
      * @param abstractNameQuery query for name of the resource adapter.
      * @param iface
      */
-    public ResourceReference(Artifact configId, AbstractNameQuery abstractNameQuery, Class iface) {
+    public ResourceReference(Artifact[] configId, AbstractNameQuery abstractNameQuery, Class iface) {
         super(configId, abstractNameQuery);
         this.iface = iface;
     }

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java Thu May  3 01:07:09 2007
@@ -29,6 +29,7 @@
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.LinkedHashSet;
 import java.util.jar.JarFile;
 
 import javax.ejb.EntityContext;
@@ -400,6 +401,10 @@
         } catch (IOException e) {
             throw new DeploymentException("Unable to copy ejb module jar into configuration: " + moduleFile.getName());
         }
+        LinkedHashSet<String> manifestcp = new LinkedHashSet<String>();
+        manifestcp.add(module.getTargetPath());
+        earContext.getCompleteManifestClassPath(moduleFile, URI.create(module.getTargetPath()), manifestcp);
+        earContext.getGeneralData().put("ManifestClassPath", manifestcp);
     }
 
     private static final String LINE_SEP = System.getProperty("line.separator");

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java Thu May  3 01:07:09 2007
@@ -177,6 +177,9 @@
         if (value instanceof IntraVmJndiReference) {
             IntraVmJndiReference intraVmJndiReference = (IntraVmJndiReference) value;
             String deploymentId = intraVmJndiReference.getJndiName();
+            if (deploymentId.startsWith("java:openejb/ejb/")) {
+                deploymentId = deploymentId.substring("java:openejb/ejb/".length());
+            }
             if (deploymentId.startsWith("java:openejb/Deployment/")) {
                 deploymentId = deploymentId.substring("java:openejb/Deployment/".length());
             }

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/schema/geronimo-openejb-2.0.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/schema/geronimo-openejb-2.0.xsd?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/schema/geronimo-openejb-2.0.xsd (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/schema/geronimo-openejb-2.0.xsd Thu May  3 01:07:09 2007
@@ -24,6 +24,7 @@
     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
     xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-1.2"
     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
+    xmlns:ee="http://java.sun.com/xml/ns/persistence"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified"
@@ -32,6 +33,7 @@
     <xs:import namespace="http://geronimo.apache.org/xml/ns/naming-1.2" schemaLocation="geronimo-naming-1.2.xsd"/>
     <xs:import namespace="http://geronimo.apache.org/xml/ns/j2ee/application-1.2" schemaLocation="geronimo-application-1.2.xsd"/>
     <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment-1.2" schemaLocation="geronimo-module-1.2.xsd"/>
+    <xs:import namespace="http://java.sun.com/xml/ns/persistence" schemaLocation="persistence-1.0.xsd"/>
 
     <xs:element name="ejb-jar" type="openejb:geronimo-ejb-jarType"/>
 
@@ -55,7 +57,10 @@
             <xs:element ref="app:security" minOccurs="0"/>
 
             <!-- GBeans -->
-            <xs:element ref="sys:service" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:choice minOccurs="0" maxOccurs="unbounded">
+                <xs:element ref="sys:service"/>
+                <xs:element ref="ee:persistence"/>
+            </xs:choice>
         </xs:sequence>
     </xs:complexType>
 

Modified: geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbReference.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbReference.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbReference.java Thu May  3 01:07:09 2007
@@ -27,7 +27,7 @@
 public class EjbReference extends ConfigurationAwareReference {
     private final boolean remote;
 
-    public EjbReference(Artifact artifact, AbstractNameQuery abstractNameQuery, boolean remote) {
+    public EjbReference(Artifact[] artifact, AbstractNameQuery abstractNameQuery, boolean remote) {
         super(artifact, abstractNameQuery);
         this.remote = remote;
     }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java Thu May  3 01:07:09 2007
@@ -20,6 +20,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -27,12 +28,14 @@
 import javax.xml.namespace.QName;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.PersistenceContextAnnotationHelper;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.deployment.annotation.PersistenceContextAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -106,7 +109,7 @@
                     persistenceUnitNameQuery = findPersistenceUnit(gerPersistenceContextRef);
                     addProperties(gerPersistenceContextRef, properties);
                     checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
-                } else if (persistenceContextRef.isSetPersistenceUnitName()) {
+                } else if (persistenceContextRef.isSetPersistenceUnitName() && persistenceContextRef.getPersistenceUnitName().getStringValue().trim().length() > 0) {
                     String persistenceUnitName = persistenceContextRef.getPersistenceUnitName().getStringValue().trim();
                     persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), PERSISTENCE_UNIT_INTERFACE_TYPES);
                     if (!checkForGBean(localConfiguration, persistenceUnitNameQuery, strictMatching)) {
@@ -115,11 +118,25 @@
                         checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
                     }
                 } else {
-                    persistenceUnitNameQuery = defaultPersistenceUnitAbstractNameQuery;
+                    persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.EMPTY_MAP, PERSISTENCE_UNIT_INTERFACE_TYPES);
+                    Set<AbstractNameQuery> patterns = Collections.singleton(persistenceUnitNameQuery);
+                    LinkedHashSet<GBeanData> gbeans = localConfiguration.findGBeanDatas(localConfiguration, patterns);
+                    persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
+                    if (gbeans.isEmpty()) {
+                        gbeans = localConfiguration.findGBeanDatas(patterns);
+                        persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
+
+                        if (gbeans.isEmpty()) {
+                            if (defaultPersistenceUnitAbstractNameQuery == null) {
+                                throw new DeploymentException("No default PersistenceUnit specified, and none located");
+                            }
+                            persistenceUnitNameQuery = defaultPersistenceUnitAbstractNameQuery;
+                        }
+                    }
                     checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
                 }
 
-                PersistenceContextReference reference = new PersistenceContextReference(localConfiguration.getId(), persistenceUnitNameQuery, transactionScoped, properties);
+                PersistenceContextReference reference = new PersistenceContextReference(getConfigId(localConfiguration, remoteConfiguration), persistenceUnitNameQuery, transactionScoped, properties);
 
                 NamingBuilder.JNDI_KEY.get(componentContext).put(ENV + persistenceContextRefName, reference);
             } catch (DeploymentException e) {
@@ -141,7 +158,7 @@
 
                 checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
 
-                PersistenceContextReference reference = new PersistenceContextReference(localConfiguration.getId(), persistenceUnitNameQuery, transactionScoped, properties);
+                PersistenceContextReference reference = new PersistenceContextReference(getConfigId(localConfiguration, remoteConfiguration), persistenceUnitNameQuery, transactionScoped, properties);
 
                 getJndiContextMap(componentContext).put(ENV + persistenceContextRefName, reference);
             } catch (DeploymentException e) {
@@ -159,12 +176,30 @@
         }
     }
 
+    private AbstractNameQuery checkForDefaultPersistenceUnit(LinkedHashSet<GBeanData> gbeans) throws DeploymentException {
+        AbstractNameQuery persistenceUnitNameQuery = null;
+        for (java.util.Iterator it = gbeans.iterator(); it.hasNext();) {
+            GBeanData gbean = (GBeanData) it.next();
+            AbstractName name = gbean.getAbstractName();
+            Map nameMap = name.getName();
+            if ("cmp".equals(nameMap.get("name"))) {
+                it.remove();
+            } else {
+                persistenceUnitNameQuery = new AbstractNameQuery(name);
+            }
+        }
+        if (gbeans.size() > 1) {
+            throw new DeploymentException("Too many matches for no-name persistence unit: " + gbeans);
+        }
+        return persistenceUnitNameQuery;
+    }
+
     private boolean checkForGBean(Configuration localConfiguration, AbstractNameQuery persistenceUnitNameQuery, boolean complainIfMissing) throws DeploymentException {
         try {
             localConfiguration.findGBeanData(persistenceUnitNameQuery);
             return true;
         } catch (GBeanNotFoundException e) {
-            if (complainIfMissing  || e.hasMatches()) { 
+            if (complainIfMissing || e.hasMatches()) {
                 String reason = e.hasMatches() ? "More than one GBean reference found." : "No GBeans found.";
                 throw new DeploymentException("Could not resolve reference at deploy time for query " + persistenceUnitNameQuery + ". " + reason, e);
             }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java?view=diff&rev=534748&r1=534747&r2=534748
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java Thu May  3 01:07:09 2007
@@ -17,30 +17,36 @@
 package org.apache.geronimo.persistence.builder;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.LinkedHashSet;
+import java.util.jar.JarFile;
 
 import javax.xml.namespace.QName;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.persistence.PersistenceUnitGBean;
 import org.apache.geronimo.xbeans.persistence.PersistenceDocument;
@@ -52,36 +58,59 @@
 /**
  * @version $Rev$ $Date$
  */
-public class PersistenceUnitBuilder implements NamespaceDrivenBuilder {
+public class PersistenceUnitBuilder implements ModuleBuilderExtension {
     private static final QName PERSISTENCE_QNAME = PersistenceDocument.type.getDocumentElementName();
 
     private final Environment defaultEnvironment;
     private final String defaultPersistenceProviderClassName;
-
-    public PersistenceUnitBuilder(Environment defaultEnvironment, String defaultPersistenceProviderClassName) {
+    private final Properties defaultPersistenceUnitProperties;
+    private final AbstractNameQuery defaultJtaDataSourceName;
+    private final AbstractNameQuery defaultNonJtaDataSourceName;
+    private static final String ANON_PU_NAME = "AnonymousPersistenceUnit";
+
+    public PersistenceUnitBuilder(Environment defaultEnvironment,
+            String defaultPersistenceProviderClassName,
+            String defaultJtaDataSourceName,
+            String defaultNonJtaDataSourceName,
+            Properties defaultPersistenceUnitProperties) throws URISyntaxException {
         this.defaultEnvironment = defaultEnvironment;
         this.defaultPersistenceProviderClassName = defaultPersistenceProviderClassName;
+        this.defaultJtaDataSourceName = defaultJtaDataSourceName == null ? null : getAbstractNameQuery(defaultJtaDataSourceName);
+        this.defaultNonJtaDataSourceName = defaultNonJtaDataSourceName == null ? null : getAbstractNameQuery(defaultNonJtaDataSourceName);
+        this.defaultPersistenceUnitProperties = defaultPersistenceUnitProperties == null ? new Properties() : defaultPersistenceUnitProperties;
     }
 
-    public void buildEnvironment(XmlObject container, Environment environment) throws DeploymentException {
-        XmlObject[] raws = container.selectChildren(PERSISTENCE_QNAME);
-        if (raws.length > 0) {
-            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
-        }
+    public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
     }
 
-    public void build(XmlObject container, DeploymentContext applicationContext, DeploymentContext moduleContext) throws DeploymentException {
+    public void installModule(JarFile earFile, EARContext earContext, Module module, Collection configurationStores, ConfigurationStore targetConfigurationStore, Collection repository) throws DeploymentException {
+    }
+
+    public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+        XmlObject container = module.getVendorDD();
+        EARContext moduleContext = module.getEarContext();
         XmlObject[] raws = container.selectChildren(PERSISTENCE_QNAME);
         for (XmlObject raw : raws) {
             PersistenceDocument.Persistence persistence = (PersistenceDocument.Persistence) raw.copy().changeType(PersistenceDocument.Persistence.type);
-            buildPersistenceUnits(persistence, moduleContext, null, null);
+            buildPersistenceUnits(persistence, module, NameFactory.PERSISTENCE_UNIT_MODULE, module.getTargetPath());
         }
-        ResourceFinder finder = new ResourceFinder("", moduleContext.getClassLoader(), null);
         try {
             //TODO the code that figures out the persistence unit name is incomplete
             URI baseURI = moduleContext.getBaseDir().toURI();
             String base = baseURI.toString();
-            Map generalData = ((EARContext) applicationContext).getGeneralData();
+            Map generalData = moduleContext.getGeneralData();
+            LinkedHashSet<String> manifestcp = (LinkedHashSet<String>) generalData.get("ManifestClassPath");
+            if (manifestcp == null) {
+                manifestcp = new LinkedHashSet<String>();
+                manifestcp.add(module.getTargetPath());
+            }
+            URL[] urls = new URL[manifestcp.size()];
+            int i = 0;
+            for (String path: manifestcp) {
+                URL url = baseURI.resolve(path).toURL();
+                urls[i++] = url;
+            }
+            ResourceFinder finder = new ResourceFinder("", null, urls);
             List<URL> knownPersistenceUrls = (List<URL>) generalData.get(PersistenceUnitBuilder.class.getName());
             if (knownPersistenceUrls == null) {
                 knownPersistenceUrls = new ArrayList<URL>();
@@ -89,36 +118,35 @@
             }
             List<URL> persistenceUrls = finder.findAll("META-INF/persistence.xml");
             persistenceUrls.removeAll(knownPersistenceUrls);
-            for (URL persistenceUrl: persistenceUrls) {
+            if (raws.length > 0 || persistenceUrls.size() > 0) {
+                EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
+            }
+            for (URL persistenceUrl : persistenceUrls) {
                 String persistenceLocation;
                 try {
-                     persistenceLocation = persistenceUrl.toURI().toString();
+                    persistenceLocation = persistenceUrl.toURI().toString();
                 } catch (URISyntaxException e) {
                     //????
                     continue;
                 }
                 int pos = persistenceLocation.indexOf(base);
-                if (pos < 0) {
-                    //wrong location?
-                    continue;
-                }
                 int endPos = persistenceLocation.lastIndexOf("!/");
                 if (endPos < 0) {
                     // if unable to find the '!/' marker, try to see if this is
                     // a war file with the persistence.xml directly embeded - no ejb-jar
-                    endPos = persistenceLocation.lastIndexOf("WEB-INF");
+                    endPos = persistenceLocation.lastIndexOf("META-INF");
                 }
                 if (endPos >= 0) {
                     String relative = persistenceLocation.substring(pos + base.length(), endPos);
                     PersistenceDocument persistenceDocument;
                     try {
                         XmlObject xmlObject = XmlBeansUtil.parse(persistenceUrl, moduleContext.getClassLoader());
-                        persistenceDocument = (PersistenceDocument)xmlObject.changeType(PersistenceDocument.type);
+                        persistenceDocument = (PersistenceDocument) xmlObject.changeType(PersistenceDocument.type);
                     } catch (XmlException e) {
                         throw new DeploymentException("Could not parse persistence.xml file: " + persistenceUrl, e);
                     }
                     PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
-                    buildPersistenceUnits(persistence, moduleContext, NameFactory.PERSISTENCE_UNIT_MODULE, relative);
+                    buildPersistenceUnits(persistence, module, NameFactory.PERSISTENCE_UNIT_MODULE, relative);
                     knownPersistenceUrls.add(persistenceUrl);
                 } else {
                     throw new DeploymentException("Could not find persistence.xml file: " + persistenceUrl);
@@ -129,20 +157,27 @@
         }
     }
 
-    private void buildPersistenceUnits(PersistenceDocument.Persistence persistence, DeploymentContext moduleContext, String moduleType, String moduleName) throws DeploymentException {
+    public void addGBeans(EARContext earContext, Module module, ClassLoader cl, Collection repository) throws DeploymentException {
+    }
+
+    private void buildPersistenceUnits(PersistenceDocument.Persistence persistence, Module module, String moduleType, String persistenceModulePath) throws DeploymentException {
         PersistenceDocument.Persistence.PersistenceUnit[] persistenceUnits = persistence.getPersistenceUnitArray();
         for (PersistenceDocument.Persistence.PersistenceUnit persistenceUnit : persistenceUnits) {
-            installPersistenceUnitGBean(persistenceUnit, moduleContext, moduleType, moduleName);
+            installPersistenceUnitGBean(persistenceUnit, module, moduleType, persistenceModulePath);
         }
     }
 
-    private void installPersistenceUnitGBean(PersistenceDocument.Persistence.PersistenceUnit persistenceUnit, DeploymentContext moduleContext, String moduleType, String moduleName) throws DeploymentException {
+    private void installPersistenceUnitGBean(PersistenceDocument.Persistence.PersistenceUnit persistenceUnit, Module module, String moduleType, String persistenceModulePath) throws DeploymentException {
+        EARContext moduleContext = module.getEarContext();
         String persistenceUnitName = persistenceUnit.getName().trim();
+        if (persistenceUnitName.length() == 0) {
+            persistenceUnitName = ANON_PU_NAME;
+        }
         AbstractName abstractName;
-        if (moduleType == null || moduleName == null || moduleName.length() == 0) {
-            abstractName = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), persistenceUnitName, PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
+        if (moduleType == null || persistenceModulePath == null || persistenceModulePath.length() == 0) {
+            abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), persistenceUnitName, PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
         } else {
-            abstractName = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), moduleName, moduleType);
+            abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), persistenceModulePath, moduleType);
             abstractName = moduleContext.getNaming().createChildName(abstractName, persistenceUnitName, PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
         }
         GBeanData gbeanData = new GBeanData(abstractName, PersistenceUnitGBean.GBEAN_INFO);
@@ -165,28 +200,26 @@
         }
         if (persistenceUnit.isSetJtaDataSource()) {
             String jtaDataSourceString = persistenceUnit.getJtaDataSource().trim();
-            if (jtaDataSourceString.indexOf('=') == -1) {
-                jtaDataSourceString = "?name=" + jtaDataSourceString;
-            }
             try {
-                AbstractNameQuery jtaDataSourceNameQuery = new AbstractNameQuery(new URI(jtaDataSourceString + "#org.apache.geronimo.connector.outbound.ConnectionFactorySource"));
+                AbstractNameQuery jtaDataSourceNameQuery = getAbstractNameQuery(jtaDataSourceString);
                 gbeanData.setReferencePattern("JtaDataSourceWrapper", jtaDataSourceNameQuery);
             } catch (URISyntaxException e) {
                 throw new DeploymentException("Could not create jta-data-source AbstractNameQuery from string: " + jtaDataSourceString, e);
             }
+        } else if (defaultJtaDataSourceName != null) {
+            gbeanData.setReferencePattern("JtaDataSourceWrapper", defaultJtaDataSourceName);
         }
 
         if (persistenceUnit.isSetNonJtaDataSource()) {
             String nonJtaDataSourceString = persistenceUnit.getNonJtaDataSource().trim();
-            if (nonJtaDataSourceString.indexOf('=') == -1) {
-                nonJtaDataSourceString = "?name=" + nonJtaDataSourceString;
-            }
             try {
-                AbstractNameQuery nonJtaDataSourceNameQuery = new AbstractNameQuery(new URI(nonJtaDataSourceString + "#org.apache.geronimo.connector.outbound.ConnectionFactorySource"));
+                AbstractNameQuery nonJtaDataSourceNameQuery = getAbstractNameQuery(nonJtaDataSourceString);
                 gbeanData.setReferencePattern("NonJtaDataSourceWrapper", nonJtaDataSourceNameQuery);
             } catch (URISyntaxException e) {
                 throw new DeploymentException("Could not create non-jta-data-source AbstractNameQuery from string: " + nonJtaDataSourceString, e);
             }
+        } else if (defaultNonJtaDataSourceName != null) {
+            gbeanData.setReferencePattern("NonJtaDataSourceWrapper", defaultNonJtaDataSourceName);
         }
 
         List<String> mappingFileNames = new ArrayList<String>();
@@ -196,21 +229,19 @@
         }
         gbeanData.setAttribute("mappingFileNames", mappingFileNames);
 
-        List<URL> jarFileUrls = new ArrayList<URL>();
+        gbeanData.setAttribute("persistenceUnitRoot", persistenceModulePath);
+
+        List<String> jarFileUrls = new ArrayList<String>();
+        //add the artifact the persistence.xml is in
+        //TODO since we are setting the root url, this might not be needed.  On the other hand,
+        //we might need to add all the manifest cp entries referenced from here.
+        jarFileUrls.add(persistenceModulePath);
+        //add the specified locations in the ear
         String[] jarFileUrlStrings = persistenceUnit.getJarFileArray();
-        for (String jarFileUrlString1 : jarFileUrlStrings) {
-            String jarFileUrlString = jarFileUrlString1.trim();
-            try {
-                URL jarFileUrl = new URL(jarFileUrlString);
-                jarFileUrls.add(jarFileUrl);
-            } catch (MalformedURLException e) {
-                throw new DeploymentException("could not create URL for jarFileURL", e);
-            }
+        for (String jarFileUrlString : jarFileUrlStrings) {
+            jarFileUrls.add(jarFileUrlString.trim());
         }
         gbeanData.setAttribute("jarFileUrls", jarFileUrls);
-        //TODO what is this from??
-//                URL persistenceUnitRootUrl = new URL(persistenceUnit.get)
-//                gbeanData.setAttribute("persistenceUnitRootUrl", persistenceUnitRootUrl);
 
         String[] managedClassNameStrings = persistenceUnit.getClass1Array();
         List<String> managedClassNames = new ArrayList<String>();
@@ -225,10 +256,10 @@
         }
 
         Properties properties = new Properties();
+        properties.putAll(defaultPersistenceUnitProperties);
         if (persistenceUnit.isSetProperties()) {
             PersistenceDocument.Persistence.PersistenceUnit.Properties.Property[] propertyObjects = persistenceUnit.getProperties().getPropertyArray();
-            for (PersistenceDocument.Persistence.PersistenceUnit.Properties.Property propertyObject : propertyObjects)
-            {
+            for (PersistenceDocument.Persistence.PersistenceUnit.Properties.Property propertyObject : propertyObjects) {
                 String key = propertyObject.getName().trim();
                 String value = propertyObject.getValue().trim();
                 properties.setProperty(key, value);
@@ -236,10 +267,16 @@
         }
 
         gbeanData.setAttribute("properties", properties);
-        if (moduleContext instanceof EARContext) {
-            AbstractNameQuery transactionManagerName = ((EARContext) moduleContext).getTransactionManagerName();
-            gbeanData.setReferencePattern("TransactionManager", transactionManagerName);
+        AbstractNameQuery transactionManagerName = moduleContext.getTransactionManagerName();
+        gbeanData.setReferencePattern("TransactionManager", transactionManagerName);
+    }
+
+    private AbstractNameQuery getAbstractNameQuery(String jtaDataSourceString) throws URISyntaxException {
+        if (jtaDataSourceString.indexOf('=') == -1) {
+            jtaDataSourceString = "?name=" + jtaDataSourceString;
         }
+        AbstractNameQuery jtaDataSourceNameQuery = new AbstractNameQuery(new URI(jtaDataSourceString + "#org.apache.geronimo.connector.outbound.ConnectionFactorySource"));
+        return jtaDataSourceNameQuery;
     }
 
     public QNameSet getSpecQNameSet() {
@@ -257,10 +294,16 @@
 
         infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
         infoBuilder.addAttribute("defaultPersistenceProviderClassName", String.class, true, true);
+        infoBuilder.addAttribute("defaultJtaDataSourceName", String.class, true, true);
+        infoBuilder.addAttribute("defaultNonJtaDataSourceName", String.class, true, true);
+        infoBuilder.addAttribute("defaultPersistenceUnitProperties", Properties.class, true, true);
 
         infoBuilder.setConstructor(new String[]{
                 "defaultEnvironment",
-                "defaultPersistenceProviderClassName"
+                "defaultPersistenceProviderClassName",
+                "defaultJtaDataSourceName",
+                "defaultNonJtaDataSourceName",
+                "defaultPersistenceUnitProperties"
         });
 
         GBEAN_INFO = infoBuilder.getBeanInfo();



Mime
View raw message