1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.model;
35
36 import org.apache.commons.lang.StringUtils;
37
38 import java.util.ArrayList;
39 import java.util.Collection;
40
41 import info.magnolia.module.ModuleVersionHandler;
42
43
44
45
46
47
48
49 public class ModuleDefinition {
50 private String name;
51 private String displayName;
52 private String description;
53 private String className;
54 private Class<? extends ModuleVersionHandler> versionHandler;
55 private Version version;
56 private Collection<DependencyDefinition> dependencies = new ArrayList<DependencyDefinition>();
57 private Collection<ServletDefinition> servlets = new ArrayList<ServletDefinition>();
58 private Collection<RepositoryDefinition> repositories = new ArrayList<RepositoryDefinition>();
59 private Collection<PropertyDefinition> properties = new ArrayList<PropertyDefinition>();
60
61 public ModuleDefinition() {
62 }
63
64 public ModuleDefinition(String name, Version version, String className, Class<? extends ModuleVersionHandler> versionHandler) {
65 this.name = name;
66 this.version = version;
67 this.className = className;
68 this.versionHandler = versionHandler;
69 }
70
71 public String getName() {
72 return this.name;
73 }
74
75 public void setName(String name) {
76 this.name = name;
77 }
78
79
80
81
82 public String getDisplayName() {
83 if (StringUtils.isEmpty(this.displayName)) {
84 return this.name;
85 }
86
87 return this.displayName;
88 }
89
90 public void setDisplayName(String displayName) {
91 this.displayName = displayName;
92 }
93
94 public String getDescription() {
95 return this.description;
96 }
97
98 public void setDescription(String description) {
99 this.description = description;
100 }
101
102 public String getClassName() {
103 return this.className;
104 }
105
106 public void setClassName(String className) {
107 this.className = className;
108 }
109
110 public Class<? extends ModuleVersionHandler> getVersionHandler() {
111 return versionHandler;
112 }
113
114 public void setVersionHandler(Class<? extends ModuleVersionHandler> versionHandler) {
115 this.versionHandler = versionHandler;
116 }
117
118 public void setVersion(Version version) {
119 this.version = version;
120 }
121
122 public Version getVersion() {
123 return version;
124 }
125
126 public Collection<DependencyDefinition> getDependencies() {
127 return this.dependencies;
128 }
129
130 public void addDependency(DependencyDefinition dep) {
131 dependencies.add(dep);
132 }
133
134 public Collection<ServletDefinition> getServlets() {
135 return this.servlets;
136 }
137
138 public void addServlet(ServletDefinition def) {
139 if (StringUtils.isEmpty(def.getComment())) {
140 def.setComment("a servlet used by the " + this.getName() + " module");
141 }
142 this.servlets.add(def);
143 }
144
145 public Collection<RepositoryDefinition> getRepositories() {
146 return this.repositories;
147 }
148
149 public void addRepository(RepositoryDefinition repository) {
150 this.repositories.add(repository);
151 }
152
153 public Collection<PropertyDefinition> getProperties() {
154 return properties;
155 }
156
157 public void addProperty(PropertyDefinition property) {
158 properties.add(property);
159 }
160
161
162
163
164
165 public String getProperty(String propertyName) {
166 for (PropertyDefinition p : properties) {
167 if (propertyName.equals(p.getName())) {
168 return p.getValue();
169 }
170 }
171 return null;
172 }
173
174 public String toString() {
175 return getDisplayName() + " (version " + version + ")";
176 }
177 }