1 13 package info.magnolia.cms.module; 14 15 import info.magnolia.cms.beans.config.ModuleRegistration; 16 17 import java.io.File ; 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 22 import org.apache.commons.lang.StringUtils; 23 24 25 30 public class ModuleDefinition { 31 32 35 private Collection dependencies = new ArrayList (); 36 37 40 private Collection servlets = new ArrayList (); 41 42 45 private Collection repositories = new ArrayList (); 46 47 50 private Collection properties = new ArrayList (); 51 52 55 private String name; 56 57 60 private String displayName = ""; 61 62 65 private String version; 66 67 70 private String description; 71 72 75 private String className; 76 77 80 private File moduleRoot; 81 82 85 public ModuleDefinition() { 86 } 87 88 94 public ModuleDefinition(String name, String version, String className) { 95 setName(name); 96 setVersion(version); 97 setClassName(className); 98 } 99 100 103 public String getName() { 104 return this.name; 105 } 106 107 111 public void setName(String name) { 112 this.name = name; 113 if (StringUtils.isEmpty(this.getDisplayName())) { 114 this.setDisplayName(name); 115 } 116 } 117 118 121 public String getVersion() { 122 return this.version; 123 } 124 125 128 public void setVersion(String version) { 129 this.version = version; 130 } 131 132 135 public Collection getDependencies() { 136 return this.dependencies; 137 } 138 139 public void addDependency(DependencyDefinition dep) { 140 this.dependencies.add(dep); 141 } 142 143 148 public boolean isDependent(ModuleDefinition def) { 149 for (Iterator iter = this.dependencies.iterator(); iter.hasNext();) { 151 DependencyDefinition dep = (DependencyDefinition) iter.next(); 152 if (dep.getName().equals(def.getName())) { 153 return true; 154 } 155 } 156 157 for (Iterator iter = this.dependencies.iterator(); iter.hasNext();) { 159 DependencyDefinition dep = (DependencyDefinition) iter.next(); 160 ModuleDefinition depDef = ModuleRegistration.getInstance().getModuleDefinition(dep.getName()); 161 if (depDef.isDependent(def)) { 162 return true; 163 } 164 } 165 return false; 167 } 168 169 172 public Collection getServlets() { 173 return this.servlets; 174 } 175 176 179 public void addServlet(ServletDefinition def) { 180 if (StringUtils.isEmpty(def.getComment())) { 181 def.setComment("a servlet used by the " + this.getName() + " module"); 182 } 183 this.servlets.add(def); 184 } 185 186 189 public Collection getRepositories() { 190 return this.repositories; 191 } 192 193 197 public void addRepository(RepositoryDefinition repository) { 198 this.repositories.add(repository); 199 } 200 201 204 public String getClassName() { 205 return this.className; 206 } 207 208 211 public void setClassName(String className) { 212 this.className = className; 213 } 214 215 218 public String getDescription() { 219 return this.description; 220 } 221 222 225 public void setDescription(String description) { 226 this.description = description; 227 } 228 229 232 public String getDisplayName() { 233 return this.displayName; 234 } 235 236 239 public void setDisplayName(String displayName) { 240 this.displayName = displayName; 241 } 242 243 247 public File getModuleRoot() { 248 return this.moduleRoot; 249 } 250 251 255 public void setModuleRoot(File moduleRoot) { 256 this.moduleRoot = moduleRoot; 257 } 258 259 262 public Collection getProperties() { 263 return properties; 264 } 265 266 public void addProperty(PropertyDefinition property) { 267 properties.add(property); 268 } 269 270 274 public String getProperty(String propertyName) { 275 final Iterator it = properties.iterator(); 276 while (it.hasNext()) { 277 final PropertyDefinition p = (PropertyDefinition) it.next(); 278 if (propertyName.equals(p.getName())) { 279 return p.getValue(); 280 } 281 } 282 return null; 283 } 284 } 285 | Popular Tags |