geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r1103356 - in /geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment: EARConfigBuilder.java NamingBuilderCollection.java
Date Sun, 15 May 2011 12:55:48 GMT
Author: genspring
Date: Sun May 15 12:55:47 2011
New Revision: 1103356

URL: http://svn.apache.org/viewvc?rev=1103356&view=rev
Log:
to avoid NPE when building plugin with ext-module tag in DD.

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilderCollection.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=1103356&r1=1103355&r2=1103356&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Sun May 15 12:55:47 2011
@@ -444,7 +444,7 @@ public class EARConfigBuilder implements
         // todo change module so you can extract the real module path back out.. then we
can eliminate
         // the moduleLocations and have addModules return the modules
         String applicationName = null;
-        if (application.getApplicationName() != null) {
+        if (application!=null && application.getApplicationName() != null) {
             applicationName = application.getApplicationName().trim();
         } else if (earFile != null) {
             applicationName = FileUtils.removeExtension(new File(earFile.getName()).getName(),
".ear");
@@ -458,14 +458,14 @@ public class EARConfigBuilder implements
                 earFile,
                 application,
                 gerApplication,
-                application.toString()
+                application==null ? null : application.toString()
         );
         try {
             addModules(earFile, application, gerApplication, environment, applicationInfo,
idBuilder);
             if (applicationInfo.getModules().isEmpty()) {
                 //if no application.xml and no modules detected, return null for stand-alone
module processing
                 return null;
-            } else {
+            } else if (application!=null){
                 addModulesToDefaultPlan(application, applicationInfo.getModules());
             }
         } catch (Throwable e) {

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilderCollection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilderCollection.java?rev=1103356&r1=1103355&r2=1103356&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilderCollection.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilderCollection.java
Sun May 15 12:55:47 2011
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -32,7 +33,17 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.openejb.jee.DataSource;
+import org.apache.openejb.jee.EjbLocalRef;
+import org.apache.openejb.jee.EjbRef;
+import org.apache.openejb.jee.EnvEntry;
 import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.MessageDestinationRef;
+import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.PersistenceUnitRef;
+import org.apache.openejb.jee.ResourceEnvRef;
+import org.apache.openejb.jee.ResourceRef;
+import org.apache.openejb.jee.ServiceRef;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -47,18 +58,35 @@ public class NamingBuilderCollection ext
     }
 
     public void buildEnvironment(JndiConsumer specDD, XmlObject plan, Environment environment)
throws DeploymentException {
+        if(specDD == null){
+            // java ee 5 and 6 might not have spec DD, adding this to avoid the NPE.
+            specDD = new JndiConsumerNonNull();
+        }
+        
         for (NamingBuilder namingBuilder : getSortedBuilders()) {
             namingBuilder.buildEnvironment(specDD, plan, environment);
         }
     }
 
     public void initContext(JndiConsumer specDD, XmlObject plan, Module module) throws DeploymentException
{
+        
+        if(specDD == null){
+            // java ee 5 and 6 might not have spec DD, adding this to avoid the NPE.
+            specDD = new JndiConsumerNonNull();
+        }
+        
         for (NamingBuilder namingBuilder : getSortedBuilders()) {
             namingBuilder.initContext(specDD, plan, module);
         }
     }
 
     public void buildNaming(JndiConsumer specDD, XmlObject plan, Module module, Map<EARContext.Key,
Object> sharedContext) throws DeploymentException {
+        
+        if(specDD == null){
+            // java ee 5 and 6 might not have spec DD, adding this to avoid the NPE.
+            specDD = new JndiConsumerNonNull();
+        }
+        
         for (NamingBuilder namingBuilder : getSortedBuilders()) {
             if (EARConfigBuilder.createPlanMode.get().booleanValue()) {
                 try {
@@ -78,6 +106,113 @@ public class NamingBuilderCollection ext
         return list;        
     }
     
+    private final class JndiConsumerNonNull implements JndiConsumer {
+        @Override
+        public String getJndiConsumerName() {
+            return null;
+        }
+
+        @Override
+        public Collection<EnvEntry> getEnvEntry() {
+            return new ArrayList<EnvEntry>();
+        }
+
+        @Override
+        public Map<String, EnvEntry> getEnvEntryMap() {
+            return new HashMap<String, EnvEntry>();
+        }
+
+        @Override
+        public Collection<EjbRef> getEjbRef() {
+            return new ArrayList<EjbRef>();
+        }
+
+        @Override
+        public Map<String, EjbRef> getEjbRefMap() {
+             return new HashMap<String, EjbRef>();
+        }
+
+        @Override
+        public Collection<EjbLocalRef> getEjbLocalRef() {
+            return new ArrayList<EjbLocalRef>();
+        }
+
+        @Override
+        public Map<String, EjbLocalRef> getEjbLocalRefMap() {
+            return new HashMap<String, EjbLocalRef>();
+        }
+
+        @Override
+        public Collection<ServiceRef> getServiceRef() {
+            return new ArrayList<ServiceRef>();
+        }
+
+        @Override
+        public Map<String, ServiceRef> getServiceRefMap() {
+            return new HashMap<String, ServiceRef>();
+        }
+
+        @Override
+        public Collection<ResourceRef> getResourceRef() {
+            return new ArrayList<ResourceRef>();
+        }
+
+        @Override
+        public Map<String, ResourceRef> getResourceRefMap() {
+            return new HashMap<String, ResourceRef>();
+        }
+
+        @Override
+        public Collection<ResourceEnvRef> getResourceEnvRef() {
+            return new ArrayList<ResourceEnvRef>();
+        }
+
+        @Override
+        public Map<String, ResourceEnvRef> getResourceEnvRefMap() {
+            return new HashMap<String, ResourceEnvRef>();
+        }
+
+        @Override
+        public Collection<MessageDestinationRef> getMessageDestinationRef() {
+            return new ArrayList<MessageDestinationRef>();
+        }
+
+        @Override
+        public Map<String, MessageDestinationRef> getMessageDestinationRefMap() {
+            return new HashMap<String, MessageDestinationRef>();
+        }
+
+        @Override
+        public Collection<PersistenceContextRef> getPersistenceContextRef() {
+            return new ArrayList<PersistenceContextRef>();
+        }
+
+        @Override
+        public Map<String, PersistenceContextRef> getPersistenceContextRefMap() {
+            return new HashMap<String, PersistenceContextRef>();
+        }
+
+        @Override
+        public Collection<PersistenceUnitRef> getPersistenceUnitRef() {
+            return new ArrayList<PersistenceUnitRef>();
+        }
+
+        @Override
+        public Map<String, PersistenceUnitRef> getPersistenceUnitRefMap() {
+            return new HashMap<String, PersistenceUnitRef>();
+        }
+
+        @Override
+        public Collection<DataSource> getDataSource() {
+            return new ArrayList<DataSource>();
+        }
+
+        @Override
+        public Map<String, DataSource> getDataSourceMap() {
+            return new HashMap<String, DataSource>();
+        }
+    }
+
     private static class NamingBuilderComparator implements Comparator<NamingBuilder>
{
         public int compare(NamingBuilder o1, NamingBuilder o2) {
             return o1.getPriority() - o2.getPriority();



Mime
View raw message