1 22 package org.jboss.deployment.spi; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 27 import javax.enterprise.deploy.shared.ModuleType ; 28 import javax.enterprise.deploy.spi.Target ; 29 import javax.enterprise.deploy.spi.TargetModuleID ; 30 31 45 public class TargetModuleIDImpl implements TargetModuleID 46 { 47 48 private TargetModuleIDImpl parentModuleID; 49 private List childModuleIDs = new ArrayList (); 50 private JBossTarget target; 51 private String moduleID; 52 private ModuleType moduleType; 53 private boolean isRunning; 54 55 58 public TargetModuleIDImpl(Target target, String moduleID, TargetModuleID parentModuleID, boolean isRunning, ModuleType moduleType) 59 { 60 this.target = (JBossTarget)target; 61 this.moduleID = moduleID; 62 this.parentModuleID = (TargetModuleIDImpl)parentModuleID; 63 this.isRunning = isRunning; 64 this.moduleType = moduleType; 65 } 66 67 70 public boolean isRunning() 71 { 72 return isRunning; 73 } 74 75 78 public ModuleType getModuleType() 79 { 80 return moduleType; 81 } 82 83 85 89 public Target getTarget() 90 { 91 return target; 92 } 93 94 98 public String getModuleID() 99 { 100 return moduleID; 101 } 102 103 107 public String getWebURL() 108 { 109 return null; } 111 112 116 public TargetModuleID getParentTargetModuleID() 117 { 118 return parentModuleID; 119 } 120 121 125 public TargetModuleID [] getChildTargetModuleID() 126 { 127 TargetModuleID [] idarr = new TargetModuleID [childModuleIDs.size()]; 128 childModuleIDs.toArray(idarr); 129 return idarr; 130 } 131 132 public void addChildTargetModuleID(TargetModuleID childModuleID) 133 { 134 childModuleIDs.add(childModuleID); 135 } 136 137 public int hashCode() 138 { 139 String hashStr = moduleType + moduleID; 140 if (parentModuleID != null) 141 { 142 hashStr += parentModuleID.moduleID; 143 } 144 return hashStr.hashCode(); 145 } 146 147 150 public boolean equals(Object obj) 151 { 152 boolean equals = false; 153 if (obj instanceof TargetModuleIDImpl) 154 { 155 TargetModuleIDImpl other = (TargetModuleIDImpl)obj; 156 equals = moduleType.equals(other.moduleType) && moduleID.equals(other.moduleID); 157 if (equals && parentModuleID != null) 158 equals = equals && parentModuleID.equals(other.parentModuleID); 159 } 160 return equals; 161 } 162 163 public String toString() 164 { 165 String parentID = (parentModuleID != null ? parentModuleID.moduleID : null); 166 return "[host=" + target.getHostName() + ",parent=" + parentID + ",id=" + moduleID + "]"; 167 } 168 } 169 | Popular Tags |