1 17 package org.apache.geronimo.deployment; 18 19 import org.apache.geronimo.kernel.repository.Artifact; 20 import org.apache.geronimo.kernel.repository.Version; 21 import org.apache.geronimo.kernel.repository.Environment; 22 23 31 public class ModuleIDBuilder { 32 private Version defaultVersion; 33 private String defaultGroup; 34 35 public ModuleIDBuilder() { 36 defaultVersion = new Version(Long.toString(System.currentTimeMillis())); 37 defaultGroup = Artifact.DEFAULT_GROUP_ID; 38 } 39 40 44 public void setDefaultGroup(String defaultGroup) { 45 this.defaultGroup = defaultGroup; 46 } 47 48 49 53 public void setDefaultVersion(Version defaultVersion) { 54 this.defaultVersion = defaultVersion; 55 } 56 57 72 public Artifact resolve(Artifact argument, String defaultType) { 73 if(argument.isResolved()) { 74 return argument; 75 } 76 if(argument.getArtifactId() == null || argument.getArtifactId().equals("")) { 77 throw new IllegalArgumentException ("Incoming Artifact must have an ArtifactID (not "+argument+")"); 78 } 79 return new Artifact(argument.getGroupId() == null || argument.getGroupId().equals("") ? defaultGroup : argument.getGroupId(), 80 argument.getArtifactId(), 81 argument.getVersion() == null ? defaultVersion : argument.getVersion(), 82 argument.getType() == null || argument.getType().equals("") ? defaultType : argument.getType()); 83 } 84 85 91 public Artifact createDefaultArtifact(String defaultArtifact, String defaultType) { 92 return new Artifact(defaultGroup, defaultArtifact, defaultVersion, defaultType); 93 } 94 95 108 public void resolve(Environment environment, String defaultArtifactId, String defaultType) { 109 if(environment.getConfigId() == null) { 110 environment.setConfigId(resolve(new Artifact(null, defaultArtifactId, (Version)null, defaultType), defaultType)); 111 } else if(!environment.getConfigId().isResolved()) { 112 environment.setConfigId(resolve(environment.getConfigId(), defaultType)); 113 } 114 } 115 } 116 | Popular Tags |