You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2008/01/03 20:35:05 UTC

svn commit: r608606 - in /geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment: AbstractNamingBuilder.java ENCConfigBuilder.java

Author: gawor
Date: Thu Jan  3 11:35:04 2008
New Revision: 608606

URL: http://svn.apache.org/viewvc?rev=608606&view=rev
Log:
reduce code duplication

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java?rev=608606&r1=608605&r2=608606&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java Thu Jan  3 11:35:04 2008
@@ -227,42 +227,11 @@
     }
 
     public static AbstractNameQuery buildAbstractNameQuery(GerPatternType pattern, String type, String moduleType, Set interfaceTypes) {
-        String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
-        String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
-        String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
-        String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
-        String name = pattern.getName().trim();
-
-        Artifact artifact = artifactid != null ? new Artifact(groupId, artifactid, version, null) : null;
-        Map nameMap = new HashMap();
-        nameMap.put("name", name);
-        if (type != null) {
-            nameMap.put("j2eeType", type);
-        }
-        if (module != null && moduleType != null) {
-            nameMap.put(moduleType, module);
-        }
-        if (interfaceTypes != null) {
-            Set trimmed = new HashSet();
-            for (Iterator it = interfaceTypes.iterator(); it.hasNext();) {
-                String intf = (String) it.next();
-                trimmed.add(intf == null ? null : intf.trim());
-            }
-            interfaceTypes = trimmed;
-        }
-        return new AbstractNameQuery(artifact, nameMap, interfaceTypes);
+        return ENCConfigBuilder.buildAbstractNameQueryFromPattern(pattern, null, type, moduleType, interfaceTypes);
     }
 
     public static AbstractNameQuery buildAbstractNameQuery(Artifact configId, String module, String name, String type, String moduleType) {
-        Map nameMap = new HashMap();
-        nameMap.put("name", name);
-        if (type != null) {
-            nameMap.put("j2eeType", type);
-        }
-        if (module != null) {
-            nameMap.put(moduleType, module);
-        }
-        return new AbstractNameQuery(configId, nameMap);
+        return ENCConfigBuilder.buildAbstractNameQuery(configId, module, name, type, moduleType);
     }
 
     public static Class assureInterface(String interfaceName, String superInterfaceName, String interfaceType, ClassLoader cl) throws DeploymentException {

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?rev=608606&r1=608605&r2=608606&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java Thu Jan  3 11:35:04 2008
@@ -50,13 +50,17 @@
     }
 
     public static AbstractNameQuery buildAbstractNameQuery(GerPatternType pattern, String type, String moduleType, Set interfaceTypes) {
+        return buildAbstractNameQueryFromPattern(pattern, "car", type, moduleType, interfaceTypes);
+    }
+    
+    public static AbstractNameQuery buildAbstractNameQueryFromPattern(GerPatternType pattern, String artifactType, String type, String moduleType, Set interfaceTypes)  {
         String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
         String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
         String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
         String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
         String name = pattern.getName().trim();
 
-        Artifact artifact = artifactid != null ? new Artifact(groupId, artifactid, version, "car") : null;
+        Artifact artifact = artifactid != null ? new Artifact(groupId, artifactid, version, artifactType) : null;
         Map nameMap = new HashMap();
         nameMap.put("name", name);
         if (type != null) {
@@ -65,7 +69,7 @@
         if (module != null && moduleType != null) {
             nameMap.put(moduleType, module);
         }
-        if(interfaceTypes != null) {
+        if (interfaceTypes != null) {
             Set trimmed = new HashSet();
             for (Iterator it = interfaceTypes.iterator(); it.hasNext();) {
                 String intf = (String) it.next();
@@ -82,7 +86,7 @@
         if (type != null) {
             nameMap.put("j2eeType", type);
         }
-        if (module != null) {
+        if (module != null && moduleType != null) {        
             nameMap.put(moduleType, module);
         }
         return new AbstractNameQuery(configId, nameMap);