1 package com.bm.ejb3metadata.annotations.metadata;
2
3 import java.util.List;
4 import java.util.Map;
5
6 import javax.ejb.Remove;
7 import javax.ejb.TransactionAttributeType;
8
9 import com.bm.ejb3metadata.annotations.InterceptorType;
10 import com.bm.ejb3metadata.annotations.JClassInterceptor;
11 import com.bm.ejb3metadata.annotations.JMethod;
12 import com.bm.ejb3metadata.annotations.impl.JInterceptors;
13 import com.bm.ejb3metadata.annotations.metadata.interfaces.IEJBInterceptors;
14 import com.bm.ejb3metadata.annotations.metadata.interfaces.ITransactionAttribute;
15
16
17
18
19
20 public class MethodAnnotationMetadata extends CommonAnnotationMetadata
21 implements Cloneable, ITransactionAttribute, IEJBInterceptors {
22
23
24
25
26
27
28
29
30
31 private JMethod jMethod = null;
32
33
34
35
36 private ClassAnnotationMetadata classAnnotationMetadata = null;
37
38
39
40
41
42 private ClassAnnotationMetadata originalClassAnnotationMetadata = null;
43
44
45
46
47 private TransactionAttributeType transactionAttributeType = null;
48
49
50
51
52 private Remove remove = null;
53
54
55
56
57 private boolean businessMethod = false;
58
59
60
61
62 private boolean postConstruct = false;
63
64
65
66
67 private boolean preDestroy = false;
68
69
70
71
72 private boolean postActivate = false;
73
74
75
76
77 private boolean prePassivate = false;
78
79
80
81
82 private boolean aroundInvoke = false;
83
84
85
86
87
88 private boolean inherited = false;
89
90
91
92
93 private boolean excludeClassInterceptors = false;
94
95
96
97
98 private boolean timeout = false;
99
100
101
102
103
104
105 private List<JClassInterceptor> globalEasyBeansInterceptors = null;
106
107
108
109
110
111 private List<JClassInterceptor> interceptors = null;
112
113
114
115
116 private JInterceptors annotationInterceptors = null;
117
118
119
120
121
122
123 private Map<InterceptorType, List<JClassInterceptor>> userInterceptors = null;
124
125
126
127
128
129
130 public MethodAnnotationMetadata(final JMethod jMethod, final ClassAnnotationMetadata classAnnotationMetadata) {
131 this.jMethod = jMethod;
132 this.classAnnotationMetadata = classAnnotationMetadata;
133 }
134
135
136
137
138 public String getMethodName() {
139 return this.jMethod.getName();
140 }
141
142
143
144
145 public JMethod getJMethod() {
146 return this.jMethod;
147 }
148
149
150
151
152
153 public TransactionAttributeType getTransactionAttributeType() {
154 return transactionAttributeType;
155 }
156
157
158
159
160
161
162 public void setTransactionAttributeType(final TransactionAttributeType transactionAttributeType) {
163 this.transactionAttributeType = transactionAttributeType;
164 }
165
166
167
168
169 public boolean isBusinessMethod() {
170 return businessMethod;
171 }
172
173
174
175
176
177 public void setBusinessMethod(final boolean flag) {
178 this.businessMethod = flag;
179 }
180
181
182
183
184 public boolean isLifeCycleMethod() {
185 return isPostActivate() || isPostConstruct() || isPreDestroy() || isPrePassivate();
186 }
187
188
189
190
191 public Remove getJRemove() {
192 return this.remove;
193 }
194
195
196
197
198
199 public void setRemove(final Remove remove) {
200 this.remove = remove;
201 }
202
203
204
205
206
207
208 @Override
209 public String toString() {
210 StringBuilder sb = new StringBuilder();
211 String titleIndent = " ";
212
213
214 sb.append(titleIndent);
215 sb.append(this.getClass().getName().substring(this.getClass().getPackage().getName().length() + 1));
216 sb.append("[\n");
217
218
219 sb.append(super.toString());
220
221
222 concatStringBuilder("jMethod", jMethod, sb);
223
224
225 concatStringBuilder("inherited", Boolean.valueOf(inherited), sb);
226
227
228 concatStringBuilder("transactionAttributeType", transactionAttributeType, sb);
229
230
231 concatStringBuilder("remove", remove, sb);
232
233
234 concatStringBuilder("businessMethod", Boolean.valueOf(businessMethod), sb);
235
236
237 concatStringBuilder("aroundInvoke", Boolean.valueOf(aroundInvoke), sb);
238
239
240 concatStringBuilder("postConstruct", Boolean.valueOf(postConstruct), sb);
241
242
243 concatStringBuilder("preDestroy", Boolean.valueOf(preDestroy), sb);
244
245
246 concatStringBuilder("postActivate", Boolean.valueOf(postActivate), sb);
247
248
249 concatStringBuilder("prePassivate", Boolean.valueOf(prePassivate), sb);
250
251
252 concatStringBuilder("timeout", Boolean.valueOf(timeout), sb);
253
254
255 concatStringBuilder("annotationInterceptors", annotationInterceptors, sb);
256
257
258 concatStringBuilder("interceptors", interceptors, sb);
259
260 sb.append(titleIndent);
261 sb.append("]\n");
262 return sb.toString();
263 }
264
265
266
267
268 public boolean isPostActivate() {
269 return postActivate;
270 }
271
272
273
274
275
276 public void setPostActivate(final boolean postActivate) {
277 this.postActivate = postActivate;
278 }
279
280
281
282
283 public boolean isPostConstruct() {
284 return postConstruct;
285 }
286
287
288
289
290
291 public void setPostConstruct(final boolean postConstruct) {
292 this.postConstruct = postConstruct;
293 }
294
295
296
297
298
299 public boolean isPreDestroy() {
300 return preDestroy;
301 }
302
303
304
305
306
307 public void setPreDestroy(final boolean preDestroy) {
308 this.preDestroy = preDestroy;
309 }
310
311
312
313
314
315 public boolean isPrePassivate() {
316 return prePassivate;
317 }
318
319
320
321
322
323 public void setPrePassivate(final boolean prePassivate) {
324 this.prePassivate = prePassivate;
325 }
326
327
328
329
330 public boolean isTimeout() {
331 return timeout;
332 }
333
334
335
336
337
338 public void setTimeout(final boolean timeout) {
339 this.timeout = timeout;
340 }
341
342
343
344
345 public boolean isAroundInvoke() {
346 return aroundInvoke;
347 }
348
349
350
351
352
353 public void setAroundInvoke(final boolean aroundInvoke) {
354 this.aroundInvoke = aroundInvoke;
355 }
356
357
358
359
360 public boolean isInherited() {
361 return inherited;
362 }
363
364
365
366
367
368
369 public void setInherited(final boolean inherited, final ClassAnnotationMetadata originalClassAnnotationMetadata) {
370 this.inherited = inherited;
371 this.originalClassAnnotationMetadata = originalClassAnnotationMetadata;
372 }
373
374
375
376
377 public boolean isExcludedClassInterceptors() {
378 return excludeClassInterceptors;
379 }
380
381
382
383
384
385 public void setExcludeClassInterceptors(final boolean excludeClassInterceptors) {
386 this.excludeClassInterceptors = excludeClassInterceptors;
387 }
388
389
390
391
392
393
394 public ClassAnnotationMetadata getClassAnnotationMetadata() {
395 return classAnnotationMetadata;
396 }
397
398
399
400
401 public ClassAnnotationMetadata getOriginalClassAnnotationMetadata() {
402 return originalClassAnnotationMetadata;
403 }
404
405
406
407
408 public List<JClassInterceptor> getInterceptors() {
409 return interceptors;
410 }
411
412
413
414
415
416
417 public void setInterceptors(final List<JClassInterceptor> interceptors) {
418 this.interceptors = interceptors;
419 }
420
421
422
423
424 public JInterceptors getAnnotationInterceptors() {
425 return annotationInterceptors;
426 }
427
428
429
430
431
432 public void setAnnotationsInterceptors(final JInterceptors annotationInterceptors) {
433 this.annotationInterceptors = annotationInterceptors;
434 }
435
436
437
438
439
440 public Map<InterceptorType, List<JClassInterceptor>> getUserEasyBeansInterceptors() {
441 return userInterceptors;
442 }
443
444
445
446
447
448
449 public void setUserInterceptors(final Map<InterceptorType, List<JClassInterceptor>> userInterceptors) {
450 this.userInterceptors = userInterceptors;
451 }
452
453
454
455
456 public List<JClassInterceptor> getGlobalEasyBeansInterceptors() {
457 return globalEasyBeansInterceptors;
458 }
459
460
461
462
463
464 public void setGlobalEasyBeansInterceptors(final List<JClassInterceptor> globalEasyBeansInterceptors) {
465 this.globalEasyBeansInterceptors = globalEasyBeansInterceptors;
466 }
467
468
469
470
471 @Override
472 public Object clone() {
473 MethodAnnotationMetadata newMethodAnnotationMetadata = new MethodAnnotationMetadata(jMethod, classAnnotationMetadata);
474 newMethodAnnotationMetadata.setAnnotationsInterceptors(annotationInterceptors);
475 newMethodAnnotationMetadata.setAroundInvoke(aroundInvoke);
476 newMethodAnnotationMetadata.setBusinessMethod(businessMethod);
477 newMethodAnnotationMetadata.setExcludeClassInterceptors(excludeClassInterceptors);
478 newMethodAnnotationMetadata.setInherited(inherited, originalClassAnnotationMetadata);
479 newMethodAnnotationMetadata.setInterceptors(interceptors);
480 newMethodAnnotationMetadata.setJAnnotationResource(getJAnnotationResource());
481 newMethodAnnotationMetadata.setJEjbEJB(getJEjbEJB());
482 newMethodAnnotationMetadata.setJavaxPersistenceContext(getJavaxPersistenceContext());
483 newMethodAnnotationMetadata.setJavaxPersistenceUnit(getJavaxPersistenceUnit());
484 newMethodAnnotationMetadata.setPostActivate(postActivate);
485 newMethodAnnotationMetadata.setPostConstruct(postConstruct);
486 newMethodAnnotationMetadata.setPreDestroy(preDestroy);
487 newMethodAnnotationMetadata.setPrePassivate(prePassivate);
488 newMethodAnnotationMetadata.setRemove(remove);
489 newMethodAnnotationMetadata.setTimeout(timeout);
490 newMethodAnnotationMetadata.setTransactionAttributeType(transactionAttributeType);
491 newMethodAnnotationMetadata.setUserInterceptors(userInterceptors);
492 newMethodAnnotationMetadata.setGlobalEasyBeansInterceptors(globalEasyBeansInterceptors);
493 return newMethodAnnotationMetadata;
494 }
495
496
497
498
499
500
501 public void setClassAnnotationMetadata(final ClassAnnotationMetadata classAnnotationMetadata) {
502 this.classAnnotationMetadata = classAnnotationMetadata;
503 }
504 }