1 17 18 package org.apache.geronimo.naming.deployment; 19 20 import java.util.HashMap ; 21 import java.util.HashSet ; 22 import java.util.Iterator ; 23 import java.util.Map ; 24 import java.util.Set ; 25 26 import org.apache.geronimo.gbean.AbstractNameQuery; 27 import org.apache.geronimo.kernel.repository.Artifact; 28 import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanLocatorType; 29 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType; 30 31 34 public class ENCConfigBuilder { 35 36 public static AbstractNameQuery getGBeanQuery(String j2eeType, GerGbeanLocatorType gerGbeanLocator) { 37 AbstractNameQuery abstractNameQuery; 38 if (gerGbeanLocator.isSetGbeanLink()) { 39 String linkName = gerGbeanLocator.getGbeanLink().trim(); 41 abstractNameQuery = buildAbstractNameQuery(null, null, linkName, j2eeType, null); 42 43 } else { 44 GerPatternType patternType = gerGbeanLocator.getPattern(); 45 abstractNameQuery = buildAbstractNameQuery(patternType, j2eeType, null, null); 47 } 48 return abstractNameQuery; 50 } 51 52 public static AbstractNameQuery buildAbstractNameQuery(GerPatternType pattern, String type, String moduleType, Set interfaceTypes) { 53 String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null; 54 String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null; 55 String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null; 56 String module = pattern.isSetModule() ? pattern.getModule().trim() : null; 57 String name = pattern.getName().trim(); 58 59 Artifact artifact = artifactid != null ? new Artifact(groupId, artifactid, version, "car") : null; 60 Map nameMap = new HashMap (); 61 nameMap.put("name", name); 62 if (type != null) { 63 nameMap.put("j2eeType", type); 64 } 65 if (module != null && moduleType != null) { 66 nameMap.put(moduleType, module); 67 } 68 if(interfaceTypes != null) { 69 Set trimmed = new HashSet (); 70 for (Iterator it = interfaceTypes.iterator(); it.hasNext();) { 71 String intf = (String ) it.next(); 72 trimmed.add(intf == null ? null : intf.trim()); 73 } 74 interfaceTypes = trimmed; 75 } 76 return new AbstractNameQuery(artifact, nameMap, interfaceTypes); 77 } 78 79 public static AbstractNameQuery buildAbstractNameQuery(Artifact configId, String module, String name, String type, String moduleType) { 80 Map nameMap = new HashMap (); 81 nameMap.put("name", name); 82 if (type != null) { 83 nameMap.put("j2eeType", type); 84 } 85 if (module != null) { 86 nameMap.put(moduleType, module); 87 } 88 return new AbstractNameQuery(configId, nameMap); 89 } 90 91 } 92 | Popular Tags |