1 package org.apache.fulcrum.yaafi.framework.role;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Iterator;
6
7 import org.apache.fulcrum.yaafi.framework.util.ToStringBuilder;
8 import org.apache.fulcrum.yaafi.framework.util.Validate;
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
35 public class RoleEntryImpl implements RoleEntry {
36
37 private String name;
38
39
40 private String implementationClazzName;
41
42
43 private String shorthand;
44
45
46 private boolean isEarlyInit;
47
48
49 private String description;
50
51
52 private String componentType;
53
54
55
56
57 private String componentFlavour;
58
59
60 private boolean hasDynamicProxy;
61
62
63 private ArrayList<String> interceptorList;
64
65
66 private String logCategory;
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 public RoleEntryImpl(String name, String defaultClass, String shorthand, boolean earlyInit, String description,
86 String componentType, String componentFlavour, boolean hasProxy, ArrayList<String> interceptorList,
87 String logCategory) {
88 Validate.notEmpty(name, "name");
89 Validate.notEmpty(defaultClass, "defaultClass");
90 Validate.notEmpty(shorthand, "shorthand");
91 Validate.notEmpty(componentType, "componentType");
92 Validate.notEmpty(componentFlavour, "componentFlavour");
93 Validate.notNull(interceptorList, "interceptorList");
94 Validate.notEmpty(logCategory, "logCategory");
95
96 this.name = name;
97 this.implementationClazzName = defaultClass;
98 this.shorthand = shorthand;
99 this.isEarlyInit = earlyInit;
100 this.description = description;
101 this.componentType = componentType;
102 this.componentFlavour = componentFlavour;
103 this.hasDynamicProxy = hasProxy;
104 this.interceptorList = interceptorList;
105 this.logCategory = logCategory;
106 }
107
108
109
110
111 public String getComponentType() {
112 return componentType;
113 }
114
115
116
117
118 public String getDescription() {
119 return description;
120 }
121
122
123
124
125 public String getImplementationClazzName() {
126 return implementationClazzName;
127 }
128
129
130
131
132 public boolean isEarlyInit() {
133 return isEarlyInit;
134 }
135
136
137
138
139 public String getName() {
140 return name;
141 }
142
143
144
145
146 public String getShorthand() {
147 return shorthand;
148 }
149
150
151
152
153 public String getComponentFlavour() {
154 return componentFlavour;
155 }
156
157
158
159
160 public boolean hasDynamicProxy() {
161 return hasDynamicProxy;
162 }
163
164
165
166
167 public void setHasDynamicProxy(boolean hasProxy) {
168 this.hasDynamicProxy = hasProxy;
169 }
170
171
172
173
174
175
176
177 public boolean hasInterceptor(String interceptorName) {
178 String currInterceptorName = null;
179 Iterator<String> iterator = this.interceptorList.iterator();
180
181 while (iterator.hasNext()) {
182 currInterceptorName = iterator.next();
183
184 if (currInterceptorName.equals(interceptorName)) {
185 return true;
186 }
187 }
188
189 return false;
190 }
191
192
193
194
195
196
197 public void addInterceptors(Collection<?> collection) {
198 String currInterceptorName = null;
199 Iterator<?> iterator = collection.iterator();
200
201 while (iterator.hasNext()) {
202 currInterceptorName = (String) iterator.next();
203
204 if (this.hasInterceptor(currInterceptorName) == false) {
205 this.interceptorList.add(currInterceptorName);
206 }
207 }
208 }
209
210
211
212
213 public String[] getInterceptorList() {
214 return interceptorList.toArray(new String[interceptorList.size()]);
215 }
216
217
218
219
220 public String getLogCategory() {
221 return logCategory;
222 }
223
224
225
226
227 public String toString() {
228 ToStringBuilder toStringBuilder = new ToStringBuilder(this);
229 toStringBuilder.append("name", this.name);
230 toStringBuilder.append("shorthand", this.shorthand);
231 toStringBuilder.append("implementationClazzName", this.implementationClazzName);
232 toStringBuilder.append("isEarlyInit", this.isEarlyInit);
233 toStringBuilder.append("hasDynamicProxy", this.hasDynamicProxy);
234 toStringBuilder.append("componentType", this.componentType);
235 toStringBuilder.append("componentFlavour", this.componentFlavour);
236 toStringBuilder.append("interceptorList", this.interceptorList);
237 toStringBuilder.append("logCategory", this.logCategory);
238 toStringBuilder.append("description", this.description);
239 return toStringBuilder.toString();
240 }
241 }