geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r507861 - in /geronimo/server/trunk/modules: geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2e...
Date Thu, 15 Feb 2007 08:58:55 GMT
Author: djencks
Date: Thu Feb 15 00:58:54 2007
New Revision: 507861

URL: http://svn.apache.org/viewvc?view=rev&rev=507861
Log:
GERONIMO-2485 Make persistence unit gbean abstract names more unique.  NOT FINISHED, but in
its current state gives different names to autogenerated cmp persistence units in different
ejb modules

Modified:
    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/deployment/EARContext.java
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java

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=507861&r1=507860&r2=507861
==============================================================================
--- 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 Feb 15 00:58:54 2007
@@ -101,7 +101,7 @@
         this.configuration = createTempConfiguration(environment, moduleType, baseDir, inPlaceConfigurationDir,
configurationManager, naming);
 
         this.configurationManager = configurationManager;
-        
+
         if (null == inPlaceConfigurationDir) {
             resourceContext = new CopyResourceContext(configuration, baseDir);
         } else {
@@ -109,6 +109,23 @@
         }
     }
 
+    public DeploymentContext(AbstractName name, DeploymentContext sharedParent) {
+        this.baseDir = sharedParent.baseDir;
+
+        this.inPlaceConfigurationDir = sharedParent.inPlaceConfigurationDir;
+
+        this.moduleName = name;
+
+        this.naming = sharedParent.naming;
+
+        this.configuration = sharedParent.configuration;
+
+        this.configurationManager = sharedParent.configurationManager;
+
+        resourceContext = sharedParent.resourceContext;
+
+    }
+
     private static ConfigurationManager createConfigurationManager(ConfigurationManager configurationManager,
Collection repositories) {
         return new DeploymentConfigurationManager(configurationManager, repositories);
     }
@@ -203,7 +220,7 @@
      * to the classpath of the configuration.
      *
      * @param targetPath where the packed jar file should be placed
-     * @param jarFile the jar file to copy
+     * @param jarFile    the jar file to copy
      * @throws IOException if there's a problem copying the jar file
      */
     public void addIncludeAsPackedJar(URI targetPath, JarFile jarFile) throws IOException
{
@@ -216,8 +233,8 @@
      * to the classpath of the configuration.
      *
      * @param targetPath where the ZIP file entry should be placed
-     * @param zipFile the ZIP file
-     * @param zipEntry the ZIP file entry
+     * @param zipFile    the ZIP file
+     * @param zipEntry   the ZIP file entry
      * @throws IOException if there's a problem copying the ZIP entry
      */
     public void addInclude(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException
{
@@ -294,7 +311,8 @@
 
             try {
                 URI targetUri = moduleBaseUri.resolve(pathUri);
-                if (targetUri.getPath().endsWith("/")) throw new IllegalStateException("target
path must not end with a '/' character: " + targetUri);
+                if (targetUri.getPath().endsWith("/"))
+                    throw new IllegalStateException("target path must not end with a '/'
character: " + targetUri);
                 configuration.addToClassPath(targetUri.toString());
             } catch (IOException e) {
                 throw new DeploymentException(e);
@@ -303,7 +321,8 @@
     }
 
     public void addClass(URI targetPath, String fqcn, byte[] bytes) throws IOException, URISyntaxException
{
-        if (!targetPath.getPath().endsWith("/")) throw new IllegalStateException("target
path must end with a '/' character: " + targetPath);
+        if (!targetPath.getPath().endsWith("/"))
+            throw new IllegalStateException("target path must end with a '/' character: "
+ targetPath);
 
         String classFileName = fqcn.replace('.', '/') + ".class";
 
@@ -355,7 +374,7 @@
         return configuration;
     }
 
-    public void flush() throws IOException{
+    public void flush() throws IOException {
         resourceContext.flush();
     }
 

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java?view=diff&rev=507861&r1=507860&r2=507861
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
Thu Feb 15 00:58:54 2007
@@ -110,6 +110,18 @@
         this.corbaGBeanObjectName = parent.getCORBAGBeanName();
     }
 
+    public EARContext(AbstractName moduleName, EARContext parent) {
+        super(moduleName, parent);
+        this.serverName = parent.getServerName();
+
+        this.transactionManagerObjectName = parent.getTransactionManagerName();
+        this.connectionTrackerObjectName = parent.getConnectionTrackerName();
+        this.transactedTimerName = parent.getTransactedTimerName();
+        this.nonTransactedTimerName = parent.getNonTransactedTimerName();
+        this.corbaGBeanObjectName = parent.getCORBAGBeanName();
+
+    }
+
     public AbstractNameQuery getServerName() {
         return serverName;
     }

Modified: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java?view=diff&rev=507861&r1=507860&r2=507861
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/j2eeobjectnames/NameFactory.java
Thu Feb 15 00:58:54 2007
@@ -98,6 +98,7 @@
     public static final String LOGIN_MODULE = "LoginModule";
     public static final String APP_CLIENT = "AppClient";
     public static final String PERSISTENCE_UNIT = "PersistenceUnit";
+    public static final String PERSISTENCE_UNIT_MODULE = "PersistenceUnitModule";
     //jsr 88 configurer
     public static final String DEPLOYMENT_CONFIGURER = "DeploymentConfigurer";
     public static final String CONFIGURATION_STORE = "ConfigurationStore";

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=507861&r1=507860&r2=507861
==============================================================================
--- 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 Feb 15 00:58:54 2007
@@ -38,6 +38,7 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
 import org.apache.geronimo.openejb.EjbDeployment;
@@ -320,7 +321,8 @@
     public void initContext(EARContext earContext, Module module, ClassLoader classLoader)
throws DeploymentException {
         EjbModule ejbModule = (EjbModule) module;
         ejbModule.setClassLoader(classLoader);
-        ejbModule.setEarContext(earContext);
+        EARContext moduleContext = new EARContext(module.getModuleName(), earContext);
+        ejbModule.setEarContext(moduleContext);
         ejbModule.setRootEarContext(earContext);
 
         // build the config info tree

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=507861&r1=507860&r2=507861
==============================================================================
--- 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 Feb 15 00:58:54 2007
@@ -73,12 +73,27 @@
         XmlObject[] raws = container.selectChildren(PERSISTENCE_QNAME);
         for (XmlObject raw : raws) {
             PersistenceDocument.Persistence persistence = (PersistenceDocument.Persistence)
raw.copy().changeType(PersistenceDocument.Persistence.type);
-            buildPersistenceUnits(persistence, moduleContext);
+            buildPersistenceUnits(persistence, moduleContext, null, null);
         }
         ResourceFinder finder = new ResourceFinder("", moduleContext.getClassLoader(), null);
         try {
+            //TODO the code that figures out the persistence unit name is incomplete
+            URI baseURI = applicationContext.getBaseDir().toURI();
             List<URL> persistenceUrls = finder.findAll("META-INF/persistence.xml");
             for (URL persistenceUrl: persistenceUrls) {
+                URI relativeURI;
+                try {
+                    relativeURI = baseURI.relativize(persistenceUrl.toURI());
+                } catch (URISyntaxException e) {
+                    continue;
+                }
+                String relative = relativeURI.toString();
+                int pos = relative.indexOf("!/");
+                if (pos > 0) {
+                    relative = relative.substring(0, pos -1);
+                } else {
+                    relative = null;
+                }
                 PersistenceDocument persistenceDocument;
                 try {
                     persistenceDocument = (PersistenceDocument) XmlBeansUtil.parse(persistenceUrl,
moduleContext.getClassLoader());
@@ -86,23 +101,29 @@
                     throw new DeploymentException("Could not parse persistence.xml file:
" + persistenceUrl, e);
                 }
                 PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
-                buildPersistenceUnits(persistence, moduleContext);
+                buildPersistenceUnits(persistence, moduleContext, NameFactory.PERSISTENCE_UNIT_MODULE,
relative);
             }
         } catch (IOException e) {
             throw new DeploymentException("Could not look for META-INF/persistence.xml files",
e);
         }
     }
 
-    private void buildPersistenceUnits(PersistenceDocument.Persistence persistence, DeploymentContext
moduleContext) throws DeploymentException {
+    private void buildPersistenceUnits(PersistenceDocument.Persistence persistence, DeploymentContext
moduleContext, String moduleType, String moduleName) throws DeploymentException {
         PersistenceDocument.Persistence.PersistenceUnit[] persistenceUnits = persistence.getPersistenceUnitArray();
         for (PersistenceDocument.Persistence.PersistenceUnit persistenceUnit : persistenceUnits)
{
-            installPersistenceUnitGBean(persistenceUnit, moduleContext);
+            installPersistenceUnitGBean(persistenceUnit, moduleContext, moduleType, moduleName);
         }
     }
 
-    private void installPersistenceUnitGBean(PersistenceDocument.Persistence.PersistenceUnit
persistenceUnit, DeploymentContext moduleContext) throws DeploymentException {
+    private void installPersistenceUnitGBean(PersistenceDocument.Persistence.PersistenceUnit
persistenceUnit, DeploymentContext moduleContext, String moduleType, String moduleName) throws
DeploymentException {
         String persistenceUnitName = persistenceUnit.getName().trim();
-        AbstractName abstractName = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
persistenceUnitName, PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
+        AbstractName abstractName;
+        if (moduleType == null || moduleName == null) {
+            abstractName = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
persistenceUnitName, PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
+        } else {
+            abstractName = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
moduleName, moduleType);
+            abstractName = moduleContext.getNaming().createChildName(abstractName, persistenceUnitName,
PersistenceUnitGBean.GBEAN_INFO.getJ2eeType());
+        }
         GBeanData gbeanData = new GBeanData(abstractName, PersistenceUnitGBean.GBEAN_INFO);
         try {
             moduleContext.addGBean(gbeanData);



Mime
View raw message