View Javadoc

1   package com.bm.ejb3metadata.annotations.metadata;
2   
3   import static javax.ejb.TransactionAttributeType.REQUIRED;
4   import static javax.ejb.TransactionManagementType.CONTAINER;
5   
6   import java.util.ArrayList;
7   import java.util.Collection;
8   import java.util.HashMap;
9   import java.util.LinkedList;
10  import java.util.List;
11  import java.util.Map;
12  
13  import javax.ejb.ApplicationException;
14  import javax.ejb.TransactionAttributeType;
15  import javax.ejb.TransactionManagementType;
16  
17  import com.bm.ejb3metadata.annotations.ClassType;
18  import com.bm.ejb3metadata.annotations.InterceptorType;
19  import com.bm.ejb3metadata.annotations.JClassInterceptor;
20  import com.bm.ejb3metadata.annotations.JField;
21  import com.bm.ejb3metadata.annotations.JMethod;
22  import com.bm.ejb3metadata.annotations.exceptions.InterceptorsValidationException;
23  import com.bm.ejb3metadata.annotations.impl.JAnnotationResource;
24  import com.bm.ejb3metadata.annotations.impl.JCommonBean;
25  import com.bm.ejb3metadata.annotations.impl.JEjbEJB;
26  import com.bm.ejb3metadata.annotations.impl.JInterceptors;
27  import com.bm.ejb3metadata.annotations.impl.JLocal;
28  import com.bm.ejb3metadata.annotations.impl.JMessageDriven;
29  import com.bm.ejb3metadata.annotations.impl.JRemote;
30  import com.bm.ejb3metadata.annotations.impl.JService;
31  import com.bm.ejb3metadata.annotations.impl.JStateful;
32  import com.bm.ejb3metadata.annotations.impl.JStateless;
33  import com.bm.ejb3metadata.annotations.impl.JavaxPersistenceContext;
34  import com.bm.ejb3metadata.annotations.impl.JavaxPersistenceUnit;
35  import com.bm.ejb3metadata.annotations.metadata.interfaces.IEJBInterceptors;
36  import com.bm.ejb3metadata.annotations.metadata.interfaces.ITransactionAttribute;
37  
38  /**
39   * This class represents the annotation metadata of a Bean.<br>
40   * From this class, we can access to all methods of a bean with its associated
41   * information.
42   * 
43   * @author Daniel Wiese
44   */
45  public class ClassAnnotationMetadata extends CommonAnnotationMetadata implements
46  		ITransactionAttribute, IEJBInterceptors {
47  
48  	private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory
49  			.getLogger(ClassAnnotationMetadata.class);
50  
51  	/**
52  	 * List of method annotations metadata.
53  	 */
54  	private Map<JMethod, MethodAnnotationMetadata> methodsAnnotationMetadata = null;
55  
56  	/**
57  	 * List of field annotations metadata.
58  	 */
59  	private Map<JField, FieldAnnotationMetadata> fieldsAnnotationMetadata = null;
60  
61  	/**
62  	 * Parent meta data.
63  	 */
64  	private EjbJarAnnotationMetadata ejbJarAnnotationMetadata = null;
65  
66  	/**
67  	 * List of local interfaces.
68  	 */
69  	private JLocal jLocal = null;
70  
71  	/**
72  	 * List of remote interfaces.
73  	 */
74  	private JRemote jRemote = null;
75  
76  	/**
77  	 * CommonBean description.
78  	 */
79  	private JCommonBean jCommonBean = null;
80  
81  	/**
82  	 * Message Driven attribute.
83  	 */
84  	private JMessageDriven jMessageDriven = null;
85  
86  	/**
87  	 * Stateless attribute.
88  	 */
89  	private JStateless jStateless = null;
90  
91  	/**
92  	 * Stateful attribute.
93  	 */
94  	private JStateful jStateful = null;
95  
96  	/**
97  	 * Servie attribute (singelton).
98  	 */
99  	private JService jService = null;
100 
101 	/**
102 	 * Local Home.
103 	 */
104 	private String localHome = null;
105 
106 	/**
107 	 * Remote Home.
108 	 */
109 	private String remoteHome = null;
110 
111 	/**
112 	 * List of annotation interceptors.
113 	 */
114 	private JInterceptors annotationInterceptors = null;
115 
116 
117 	/**
118 	 * User interceptors. These interceptors correspond to a list of Interceptor
119 	 * that user has specified in its bean class. It is the interceptors defined
120 	 * in interceptor classes, not the bean class itself. Map&lt;interceptor
121 	 * type &lt;--&gt; List of methods/class corresponding to the
122 	 * interceptor&gt;
123 	 */
124 	private Map<InterceptorType, List<JClassInterceptor>> externalUserInterceptors = null;
125 
126 	/**
127 	 * Transaction management type (default = container).
128 	 */
129 	private TransactionManagementType transactionManagementType = CONTAINER;
130 
131 	/**
132 	 * Transaction attribute type (default = required).
133 	 */
134 	private TransactionAttributeType transactionAttributeType = REQUIRED;
135 
136 	/**
137 	 * Application exception annotation.
138 	 */
139 	private ApplicationException applicationException = null;
140 
141 	/**
142 	 * Superclass name.
143 	 */
144 	private String superName = null;
145 
146 	/**
147 	 * Interfaces of this clas.
148 	 */
149 	private String[] interfaces = null;
150 
151 	/**
152 	 * The type of the class.
153 	 * 
154 	 * @see ClassType
155 	 */
156 	private ClassType classType = null;
157 
158 	/**
159 	 * Name of the class associated to this metadata.
160 	 */
161 	private String className = null;
162 
163 	/**
164 	 * List of &#64;{@link javax.interceptor.AroundInvoke} methods on this
165 	 * class (should be only one per class, validating occurs after).
166 	 */
167 	private List<MethodAnnotationMetadata> aroundInvokeMethodsMetadata = null;
168 
169 	/**
170 	 * Object representing &#64;{@link javax.ejb.EJBs} annotation.
171 	 */
172 	private List<JEjbEJB> jEjbEJBs = null;
173 
174 	/**
175 	 * Object representing &#64;{@link javax.annotation.Resources} annotation.
176 	 */
177 	private List<JAnnotationResource> jAnnotationResources = null;
178 
179 	/**
180 	 * Object representing &#64;{@link javax.persistence.PersistenceContext}
181 	 * annotation.
182 	 */
183 	private List<JavaxPersistenceContext> javaxPersistencePersistenceContexts = null;
184 
185 	/**
186 	 * Object representing &#64;{@link javax.persistence.PersistenceUnit}
187 	 * annotation.
188 	 */
189 	private List<JavaxPersistenceUnit> javaxPersistencePersistenceUnits = null;
190 
191 	/**
192 	 * Methods used for &#64;{@link javax.annotation.PostConstruct} on this
193 	 * class (only one per class but may be defined in super classes).
194 	 */
195 	private LinkedList<MethodAnnotationMetadata> postConstructMethodsMetadata = null;
196 
197 	/**
198 	 * Methods used for &#64;{@link javax.annotation.PreDestroy} on this class
199 	 * (only one per class but may be defined in super classes).
200 	 */
201 	private LinkedList<MethodAnnotationMetadata> preDestroyMethodsMetadata = null;
202 
203 	/**
204 	 * Methods used for &#64;{@link javax.ejb.PostActivate} on this class (only
205 	 * one per class but may be defined in super classes).
206 	 */
207 	private LinkedList<MethodAnnotationMetadata> postActivateMethodsMetadata = null;
208 
209 	/**
210 	 * Methods used for &#64;{@link javax.ejb.PrePassivate} on this class (only
211 	 * one per class but may be defined in super classes).
212 	 */
213 	private LinkedList<MethodAnnotationMetadata> prePassivateMethodsMetadata = null;
214 
215 	/**
216 	 * Is that the class represented by this metadata has already been modified ?
217 	 */
218 	private boolean modified = false;
219 
220 	/**
221 	 * Constructor.
222 	 * 
223 	 * @param className
224 	 *            name of the class associated to these metadatas.
225 	 * @param ejbJarAnnotationMetadata
226 	 *            parent metadata object.
227 	 */
228 	public ClassAnnotationMetadata(final String className,
229 			final EjbJarAnnotationMetadata ejbJarAnnotationMetadata) {
230 		this.className = className;
231 		this.methodsAnnotationMetadata = new HashMap<JMethod, MethodAnnotationMetadata>();
232 		this.fieldsAnnotationMetadata = new HashMap<JField, FieldAnnotationMetadata>();
233 		this.ejbJarAnnotationMetadata = ejbJarAnnotationMetadata;
234 		this.postConstructMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
235 		this.preDestroyMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
236 		this.postActivateMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
237 		this.prePassivateMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
238 	}
239 
240 	/**
241 	 * name of the bean (associated to this metadata).
242 	 * 
243 	 * @return name of the bean (associated to this metadata).
244 	 */
245 	public String getClassName() {
246 		return className;
247 	}
248 
249 	/**
250 	 * Add method annotation metadata for a given Bean.
251 	 * 
252 	 * @param methodAnnotationMetadata
253 	 *            metadata of a method.
254 	 */
255 	public void addMethodAnnotationMetadata(
256 			final MethodAnnotationMetadata methodAnnotationMetadata) {
257 		JMethod key = methodAnnotationMetadata.getJMethod();
258 		// already exists ?
259 		if (methodsAnnotationMetadata.containsKey(key)) {
260 			String msg = "BeanAnnotationMetadata.addMethodAnnotationMetadata.alreadyPresent";
261 			logger.debug(msg);
262 			throw new IllegalStateException(msg);
263 		}
264 		methodsAnnotationMetadata.put(key, methodAnnotationMetadata);
265 	}
266 
267 	/**
268 	 * jMethod key of the map of methods annotations.
269 	 * 
270 	 * @param jMethod
271 	 *            key of the map of methods annotations.
272 	 * @return method annotation metadata of a given method.
273 	 */
274 	public MethodAnnotationMetadata getMethodAnnotationMetadata(
275 			final JMethod jMethod) {
276 		return methodsAnnotationMetadata.get(jMethod);
277 	}
278 
279 	/**
280 	 * Get collections of methods annotation metadata.
281 	 * 
282 	 * @return collections of methods annotation metadata.
283 	 */
284 	public Collection<MethodAnnotationMetadata> getMethodAnnotationMetadataCollection() {
285 		return methodsAnnotationMetadata.values();
286 	}
287 
288 	/**
289 	 * Add field annotation metadata for a given Bean.
290 	 * 
291 	 * @param fieldAnnotationMetadata
292 	 *            metadata of a field.
293 	 */
294 	public void addFieldAnnotationMetadata(
295 			final FieldAnnotationMetadata fieldAnnotationMetadata) {
296 		JField key = fieldAnnotationMetadata.getJField();
297 		// already exists ?
298 		if (fieldsAnnotationMetadata.containsKey(key)) {
299 			String msg = "BeanAnnotationMetadata.addFieldAnnotationMetadata.alreadyPresent";
300 			logger.debug(msg);
301 			throw new IllegalStateException(msg);
302 		}
303 		fieldsAnnotationMetadata.put(key, fieldAnnotationMetadata);
304 	}
305 
306 	/**
307 	 * key of the map of fields annotations.
308 	 * 
309 	 * @param jField
310 	 *            key of the map of fields annotations.
311 	 * @return field annotation metadata of a given method.
312 	 */
313 	public FieldAnnotationMetadata getFieldAnnotationMetadata(
314 			final JField jField) {
315 		return fieldsAnnotationMetadata.get(jField);
316 	}
317 
318 	/**
319 	 * Get collections of fields annotation metadata.
320 	 * 
321 	 * @return collections of fields annotation metadata.
322 	 */
323 	public Collection<FieldAnnotationMetadata> getFieldAnnotationMetadataCollection() {
324 		return fieldsAnnotationMetadata.values();
325 	}
326 
327 	/**
328 	 * Sets the local interfaces of this class.
329 	 * 
330 	 * @param jLocal
331 	 *            list of interfaces.
332 	 */
333 	public void setLocalInterfaces(final JLocal jLocal) {
334 		this.jLocal = jLocal;
335 	}
336 
337 	/**
338 	 * Sets the remote interfaces of this class.
339 	 * 
340 	 * @param jRemote
341 	 *            list of interfaces.
342 	 */
343 	public void setRemoteInterfaces(final JRemote jRemote) {
344 		this.jRemote = jRemote;
345 	}
346 
347 	/**
348 	 * the local interfaces of this class.
349 	 * 
350 	 * @return the local interfaces of this class.
351 	 */
352 	public JLocal getLocalInterfaces() {
353 		return jLocal;
354 	}
355 
356 	/**
357 	 * the remote interfaces of this class.
358 	 * 
359 	 * @return the remote interfaces of this class.
360 	 */
361 	public JRemote getRemoteInterfaces() {
362 		return jRemote;
363 	}
364 
365 	/**
366 	 * true if the class is a stateless class.
367 	 * 
368 	 * @return true if the class is a stateless class
369 	 */
370 	public boolean isStateless() {
371 		return (classType != null && classType == ClassType.STATELESS);
372 	}
373 
374 	/**
375 	 * true if the class is a stateful class.
376 	 * @return true if the class is a stateful class
377 	 */
378 	public boolean isStateful() {
379 		return (classType != null && classType == ClassType.STATEFUL);
380 	}
381 
382 	/**
383 	 * true if the class is a session bean class.
384 	 * @return true if the class is a session bean class
385 	 */
386 	public boolean isSession() {
387 		return (classType != null && (classType == ClassType.STATELESS || classType == ClassType.STATEFUL));
388 	}
389 
390 	/**
391 	 * true if the class is an MDB class.
392 	 * @return true if the class is an MDB class
393 	 */
394 	public boolean isMdb() {
395 		return (classType != null && classType == ClassType.MDB);
396 	}
397 
398 	/**
399 	 * true if the class is an MDB class.
400 	 * @return true if the class is an MDB class
401 	 */
402 	public boolean isService() {
403 		return (classType != null && classType == ClassType.SERVICE);
404 	}
405 
406 	/**
407 	 * Sets the type of this class.
408 	 * 
409 	 * @param cType
410 	 *            a type from enum class ClassType.
411 	 * @see com.bm.ejb3metadata.annotations.ClassType
412 	 */
413 	public void setClassType(final ClassType cType) {
414 		this.classType = cType;
415 	}
416 
417 	/**
418 	 * Message driven attribute.
419 	 * @return Message driven attribute.
420 	 */
421 	public JMessageDriven getJMessageDriven() {
422 		return jMessageDriven;
423 	}
424 
425 	/**
426 	 * Sets the message driven bean object.
427 	 * 
428 	 * @param messageDriven
429 	 *            attributes of message driven bean.
430 	 */
431 	public void setJMessageDriven(final JMessageDriven messageDriven) {
432 		jMessageDriven = messageDriven;
433 	}
434 
435 	/**
436 	 * string representation.
437 	 * @return string representation.
438 	 */
439 	@Override
440 	public String toString() {
441 		StringBuilder sb = new StringBuilder();
442 		// classname
443 		sb.append(this.getClass().getName().substring(
444 				this.getClass().getPackage().getName().length() + 1));
445 		sb.append("[\n");
446 
447 		// Add super class toString()
448 		sb.append(super.toString());
449 
450 		// Class name
451 		concatStringBuilder("className", className, sb);
452 
453 		// superclass name
454 		concatStringBuilder("superName", superName, sb);
455 
456 		// interfaces
457 		concatStringBuilder("interfaces", interfaces, sb);
458 
459 		// classType
460 		concatStringBuilder("classType", classType, sb);
461 
462 		// jLocal
463 		concatStringBuilder("jLocal", jLocal, sb);
464 
465 		// aroundInvokeMethodMetadatas
466 		concatStringBuilder("aroundInvokeMethodsMetadata",
467 				aroundInvokeMethodsMetadata, sb);
468 
469 		// jRemote
470 		concatStringBuilder("jRemote", jRemote, sb);
471 
472 		// jMessageDriven
473 		concatStringBuilder("jMessageDriven", jMessageDriven, sb);
474 
475 		// remoteHome
476 		concatStringBuilder("remoteHome", remoteHome, sb);
477 
478 		// localHome
479 		concatStringBuilder("localHome", localHome, sb);
480 
481 		// transactionManagementType
482 		concatStringBuilder("transactionManagementType",
483 				transactionManagementType, sb);
484 
485 		// transactionAttributeType
486 		concatStringBuilder("transactionAttributeType",
487 				transactionAttributeType, sb);
488 
489 		// annotation Interceptors
490 		concatStringBuilder("annotationInterceptors", annotationInterceptors,
491 				sb);
492 
493 		// jEjbEJBs
494 		concatStringBuilder("jAnnotationEJBs", jEjbEJBs, sb);
495 
496 		// jAnnotationResources
497 		concatStringBuilder("jAnnotationResources", jAnnotationResources, sb);
498 
499 		// javaxPersistencePersistenceContexts
500 		concatStringBuilder("javaxPersistencePersistenceContexts",
501 				javaxPersistencePersistenceContexts, sb);
502 
503 		// javaxPersistencePersistenceUnits
504 		concatStringBuilder("javaxPersistencePersistenceUnits",
505 				javaxPersistencePersistenceUnits, sb);
506 
507 		// Methods
508 		for (MethodAnnotationMetadata methodAnnotationMetadata : getMethodAnnotationMetadataCollection()) {
509 			concatStringBuilder("methods", methodAnnotationMetadata, sb);
510 		}
511 
512 		sb.append("]");
513 		return sb.toString();
514 	}
515 
516 	/**
517 	 * the &#64;{@link javax.ejb.RemoteHome} class name.
518 	 * @return the &#64;{@link javax.ejb.RemoteHome} class name.
519 	 */
520 	public String getRemoteHome() {
521 		return remoteHome;
522 	}
523 
524 	/**
525 	 * Sets the &#64;{@link javax.ejb.RemoteHome} class name.
526 	 * 
527 	 * @param remoteHome
528 	 *            the class name.
529 	 */
530 	public void setRemoteHome(final String remoteHome) {
531 		this.remoteHome = remoteHome;
532 	}
533 
534 	/**
535 	 * the &#64;{@link javax.ejb.LocalHome} class name.
536 	 * @return the &#64;{@link javax.ejb.LocalHome} class name.
537 	 */
538 	public String getLocalHome() {
539 		return localHome;
540 	}
541 
542 	/**
543 	 * Sets the &#64;{@link javax.ejb.LocalHome} class name.
544 	 * the &#64;{@link javax.ejb.LocalHome} class name.
545 	 * @param localHome
546 	 *            the class name.
547 	 */
548 	public void setLocalHome(final String localHome) {
549 		this.localHome = localHome;
550 	}
551 
552 	/**
553 	 * transaction management type from.
554 	 * @return transaction management type from.
555 	 * @see TransactionManagementType.
556 	 */
557 	public TransactionManagementType getTransactionManagementType() {
558 		return transactionManagementType;
559 	}
560 
561 	/**
562 	 * Sets transaction management type.
563 	 * 
564 	 * @see javax.ejb.TransactionManagementType
565 	 * @param transactionManagementType
566 	 *            value. (BEAN, CONTAINER)
567 	 */
568 	public void setTransactionManagementType(
569 			final TransactionManagementType transactionManagementType) {
570 		this.transactionManagementType = transactionManagementType;
571 	}
572 
573 	/**
574 	 *  transaction Attribute type.
575 	 * @return transaction Attribute type.
576 	 * @see javax.ejb.TransactionAttributeType
577 	 */
578 	public TransactionAttributeType getTransactionAttributeType() {
579 		return transactionAttributeType;
580 	}
581 
582 	/**
583 	 * Set Transaction Attribute Type.
584 	 * 
585 	 * @see javax.ejb.TransactionAttributeType
586 	 * @param transactionAttributeType
587 	 *            the type of transaction.
588 	 */
589 	public void setTransactionAttributeType(
590 			final TransactionAttributeType transactionAttributeType) {
591 		this.transactionAttributeType = transactionAttributeType;
592 	}
593 
594 	/**
595 	 * Object representing list of &#64;{@link javax.interceptor.Interceptors}.
596 	 * @return object representing list of &#64;{@link javax.interceptor.Interceptors}.
597 	 */
598 	public JInterceptors getAnnotationInterceptors() {
599 		return annotationInterceptors;
600 	}
601 
602 	/**
603 	 * Sets the object representing the &#64;{@link javax.interceptor.Interceptors}
604 	 * annotation.
605 	 * 
606 	 * @param annotationInterceptors
607 	 *            list of classes
608 	 */
609 	public void setAnnotationsInterceptors(
610 			final JInterceptors annotationInterceptors) {
611 		this.annotationInterceptors = annotationInterceptors;
612 	}
613 
614 	/**
615 	 * the &#64;{@link javax.ejb.ApplicationException} annotation.
616 	 * @return the &#64;{@link javax.ejb.ApplicationException} annotation.
617 	 */
618 	public ApplicationException getApplicationException() {
619 		return applicationException;
620 	}
621 
622 	/**
623 	 * Sets the object representing the &#64;{@link javax.ejb.ApplicationException}
624 	 * annotation.
625 	 * 
626 	 * @param applicationException
627 	 *            object representation
628 	 */
629 	public void setApplicationException(
630 			final ApplicationException applicationException) {
631 		this.applicationException = applicationException;
632 	}
633 
634 	/**
635 	 * true if the classs is a Bean.
636 	 * @return true if the classs is a Bean
637 	 */
638 	public boolean isBean() {
639 		return isStateless() || isStateful() || isMdb() || isService();
640 	}
641 
642 	/**
643 	 * array of interfaces name.
644 	 * @return array of interfaces name.
645 	 */
646 	public String[] getInterfaces() {
647 		return interfaces;
648 	}
649 
650 	/**
651 	 * Sets the interfaces of this class.
652 	 * 
653 	 * @param interfaces
654 	 *            name of interfaces.
655 	 */
656 	public void setInterfaces(final String[] interfaces) {
657 		this.interfaces = interfaces;
658 	}
659 
660 	/**
661 	 * the super class name.
662 	 * @return the super class name.
663 	 */
664 	public String getSuperName() {
665 		return superName;
666 	}
667 
668 	/**
669 	 * Sets the super class name.
670 	 * 
671 	 * @param superName
672 	 *            name of the super class.
673 	 */
674 	public void setSuperName(final String superName) {
675 		this.superName = superName;
676 	}
677 
678 	/**
679 	 * parent metadata object.
680 	 * @return parent metadata object.
681 	 */
682 	public EjbJarAnnotationMetadata getEjbJarAnnotationMetadata() {
683 		return ejbJarAnnotationMetadata;
684 	}
685 
686 	/**
687 	 * Map&lt;interceptor type &lt;--&gt; List of methods/class
688 	 *         corresponding to the interceptor&gt; (interceptor classes) of
689 	 *         user interceptors that enhancer will use.
690 	 * @return Map&lt;interceptor type &lt;--&gt; List of methods/class
691 	 *         corresponding to the interceptor&gt; (interceptor classes) of
692 	 *         user interceptors that enhancer will use.
693 	 */
694 	public Map<InterceptorType, List<JClassInterceptor>> getExternalUserEasyBeansInterceptors() {
695 		return externalUserInterceptors;
696 	}
697 
698 	/**
699 	 * Sets the list of user interceptors that enhancers will use.<br>
700 	 * These interceptors are defined outside the bean class (interceptor
701 	 * classes).
702 	 * 
703 	 * @param externalUserInterceptors
704 	 *            list of interceptors that enhancer will use.
705 	 */
706 	public void setExternalUserInterceptors(
707 			final Map<InterceptorType, List<JClassInterceptor>> externalUserInterceptors) {
708 		this.externalUserInterceptors = externalUserInterceptors;
709 	}
710 
711 
712 	/**
713 	 * the method metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
714 	 * @return the method metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
715 	 */
716 	public boolean isAroundInvokeMethodMetadata() {
717 		return (aroundInvokeMethodsMetadata != null);
718 	}
719 
720 	/**
721 	 * the list of methods metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
722 	 * @return the list of methods metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
723 	 */
724 	public List<MethodAnnotationMetadata> getAroundInvokeMethodMetadatas() {
725 		return aroundInvokeMethodsMetadata;
726 	}
727 
728 	/**
729 	 * Add a &#64;{@link javax.interceptor.AroundInvoke} method of this class.
730 	 * @param aroundInvokeMethodMetadata
731 	 *            the method.
732 	 */
733 	public void addAroundInvokeMethodMetadata(
734 			final MethodAnnotationMetadata aroundInvokeMethodMetadata) {
735 		if (aroundInvokeMethodsMetadata == null) {
736 			this.aroundInvokeMethodsMetadata = new ArrayList<MethodAnnotationMetadata>();
737 		}
738 		aroundInvokeMethodsMetadata.add(aroundInvokeMethodMetadata);
739 	}
740 
741 	/**
742 	 *  the methods metadata with annotation &#64;{@link javax.annotation.PostConstruct}.
743 	 * @return the methods metadata with annotation &#64;{@link javax.annotation.PostConstruct}.
744 	 */
745 	public LinkedList<MethodAnnotationMetadata> getPostConstructMethodsMetadata() {
746 		return postConstructMethodsMetadata;
747 	}
748 
749 	/**
750 	 * Adds a &#64;{@link javax.annotation.PostConstruct} method of this class.
751 	 * 
752 	 * @param postConstructMethodMetadata
753 	 *            the method.
754 	 */
755 	public void addPostConstructMethodMetadata(
756 			final MethodAnnotationMetadata postConstructMethodMetadata) {
757 		checkLifeCycleDuplicate(postConstructMethodMetadata,
758 				InterceptorType.POST_CONSTRUCT,
759 				getPostConstructMethodsMetadata());
760 		this.postConstructMethodsMetadata.addFirst(postConstructMethodMetadata);
761 	}
762 
763 	/**
764 	 * Checks that only method at one level of a class is present.
765 	 * 
766 	 * @param postConstructMethodMetadata
767 	 *            method to check
768 	 * @param itcType
769 	 *            the type of interceptor (used for the error)
770 	 * @param existingList
771 	 *            current list of methods
772 	 */
773 	private void checkLifeCycleDuplicate(
774 			final MethodAnnotationMetadata postConstructMethodMetadata,
775 			final InterceptorType itcType,
776 			final List<MethodAnnotationMetadata> existingList) {
777 		// First case : not inherited
778 		ClassAnnotationMetadata wantToAddClassMetadata = postConstructMethodMetadata
779 				.getClassAnnotationMetadata();
780 		if (postConstructMethodMetadata.isInherited()) {
781 			wantToAddClassMetadata = postConstructMethodMetadata
782 					.getOriginalClassAnnotationMetadata();
783 		}
784 		for (MethodAnnotationMetadata method : existingList) {
785 			ClassAnnotationMetadata compareMetaData;
786 			if (method.isInherited()) {
787 				compareMetaData = method.getOriginalClassAnnotationMetadata();
788 			} else {
789 				compareMetaData = method.getClassAnnotationMetadata();
790 			}
791 			if (compareMetaData.equals(wantToAddClassMetadata)) {
792 				throw new InterceptorsValidationException("Class "
793 						+ getClassName() + " has already a " + itcType
794 						+ " method which is " + method.getMethodName()
795 						+ ", cannot set new method "
796 						+ postConstructMethodMetadata.getMethodName());
797 			}
798 		}
799 	}
800 
801 	/**
802 	 * the methods metadata with annotation &#64;{@link javax.annotation.PreDestroy}.
803 	 * @return the methods metadata with annotation &#64;{@link javax.annotation.PreDestroy}.
804 	 */
805 	public LinkedList<MethodAnnotationMetadata> getPreDestroyMethodsMetadata() {
806 		return preDestroyMethodsMetadata;
807 	}
808 
809 	/**
810 	 * Adds a &#64;{@link javax.annotation.PreDestroy} method of this class.
811 	 * 
812 	 * @param preDestroyMethodMetadata
813 	 *            the method.
814 	 */
815 	public void addPreDestroyMethodMetadata(
816 			final MethodAnnotationMetadata preDestroyMethodMetadata) {
817 		checkLifeCycleDuplicate(preDestroyMethodMetadata,
818 				InterceptorType.PRE_DESTROY, getPreDestroyMethodsMetadata());
819 		this.preDestroyMethodsMetadata.addFirst(preDestroyMethodMetadata);
820 	}
821 
822 	/**
823 	 * the methods metadata with annotation &#64;{@link javax.ejb.PostActivate}.
824 	 * @return the methods metadata with annotation &#64;{@link javax.ejb.PostActivate}.
825 	 */
826 	public LinkedList<MethodAnnotationMetadata> getPostActivateMethodsMetadata() {
827 		return postActivateMethodsMetadata;
828 	}
829 
830 	/**
831 	 * Adds a &#64;{@link javax.ejb.PostActivate} method of this class.
832 	 * 
833 	 * @param postActivateMethodMetadata
834 	 *            the method.
835 	 */
836 	public void addPostActivateMethodMetadata(
837 			final MethodAnnotationMetadata postActivateMethodMetadata) {
838 		checkLifeCycleDuplicate(postActivateMethodMetadata,
839 				InterceptorType.POST_ACTIVATE, getPostActivateMethodsMetadata());
840 		this.postActivateMethodsMetadata.addFirst(postActivateMethodMetadata);
841 	}
842 
843 	/**
844 	 * the method metadata with annotation &#64;{@link javax.ejb.PrePassivate}.
845 	 * @return the method metadata with annotation &#64;{@link javax.ejb.PrePassivate}.
846 	 */
847 	public LinkedList<MethodAnnotationMetadata> getPrePassivateMethodsMetadata() {
848 		return prePassivateMethodsMetadata;
849 	}
850 
851 	/**
852 	 * Adds a &#64;{@link javax.ejb.PrePassivate} method of this class.
853 	 * 
854 	 * @param prePassivateMethodMetadata
855 	 *            the method.
856 	 */
857 	public void addPrePassivateMethodMetadata(
858 			final MethodAnnotationMetadata prePassivateMethodMetadata) {
859 		checkLifeCycleDuplicate(prePassivateMethodMetadata,
860 				InterceptorType.PRE_PASSIVATE, getPrePassivateMethodsMetadata());
861 		this.prePassivateMethodsMetadata.addFirst(prePassivateMethodMetadata);
862 	}
863 
864 	/**
865 	 * Is that this class is an interceptor class ?
866 	 * 
867 	 * @return true if it the case, else false.
868 	 */
869 	public boolean isInterceptor() {
870 		return (aroundInvokeMethodsMetadata != null && aroundInvokeMethodsMetadata
871 				.size() > 0)
872 				|| (postConstructMethodsMetadata != null && postConstructMethodsMetadata
873 						.size() > 0)
874 				|| (preDestroyMethodsMetadata != null && preDestroyMethodsMetadata
875 						.size() > 0)
876 				|| (prePassivateMethodsMetadata != null && prePassivateMethodsMetadata
877 						.size() > 0)
878 				|| (postActivateMethodsMetadata != null && postActivateMethodsMetadata
879 						.size() > 0);
880 	}
881 
882 	/**
883 	 * jEjbEJBs list representing &#64;{@link javax.ejb.EJBs}
884 	 *         annotation.
885 	 * @return jEjbEJBs list representing &#64;{@link javax.ejb.EJBs}
886 	 *         annotation.
887 	 */
888 	public List<JEjbEJB> getJEjbEJBs() {
889 		return jEjbEJBs;
890 	}
891 
892 	/**
893 	 * Set JEjbEJBs object.
894 	 * 
895 	 * @param jEjbEJBs
896 	 *            list representing javax.ejb.EJBs annotation.
897 	 */
898 	public void setJEjbEJBs(final List<JEjbEJB> jEjbEJBs) {
899 		this.jEjbEJBs = jEjbEJBs;
900 	}
901 
902 	/**
903 	 * JAnnotationResources list representing &#64;{@link javax.annotation.Resources}
904 	 *         annotation.
905 	 * @return JAnnotationResources list representing &#64;{@link javax.annotation.Resources}
906 	 *         annotation.
907 	 */
908 	public List<JAnnotationResource> getJAnnotationResources() {
909 		return jAnnotationResources;
910 	}
911 
912 	/**
913 	 * Sets JAnnotationResources object.
914 	 * 
915 	 * @param jAnnotationResources
916 	 *            list representing javax.annotation.Resources annotation.
917 	 */
918 	public void setJAnnotationResources(
919 			final List<JAnnotationResource> jAnnotationResources) {
920 		this.jAnnotationResources = jAnnotationResources;
921 	}
922 
923 	/**
924 	 * javaxPersistencePersistenceContexts list representing &#64;{@link javax.persistence.PersistenceContexts}
925 	 *         annotation.
926 	 * @return javaxPersistencePersistenceContexts list representing &#64;{@link javax.persistence.PersistenceContexts}
927 	 *         annotation.
928 	 */
929 	public List<JavaxPersistenceContext> getJavaxPersistencePersistenceContexts() {
930 		return javaxPersistencePersistenceContexts;
931 	}
932 
933 	/**
934 	 * Sets JavaxPersistencePersistenceContexts object.
935 	 * 
936 	 * @param javaxPersistencePersistenceContexts
937 	 *            list representing &#64;{@link javax.persistence.PersistenceContexts}
938 	 *            annotation.
939 	 */
940 	public void setJavaxPersistencePersistenceContexts(
941 			final List<JavaxPersistenceContext> javaxPersistencePersistenceContexts) {
942 		this.javaxPersistencePersistenceContexts = javaxPersistencePersistenceContexts;
943 	}
944 
945 	/**
946 	 * javaxPersistencePersistenceUnits list representing &#64;{@link javax.persistence.PersistenceUnits}
947 	 *         annotation.
948 	 * @return javaxPersistencePersistenceUnits list representing &#64;{@link javax.persistence.PersistenceUnits}
949 	 *         annotation.
950 	 */
951 	public List<JavaxPersistenceUnit> getJavaxPersistencePersistenceUnits() {
952 		return javaxPersistencePersistenceUnits;
953 	}
954 
955 	/**
956 	 * Sets setJavaxPersistencePersistenceUnits object.
957 	 * 
958 	 * @param javaxPersistencePersistenceUnits
959 	 *            list representing &#64;{@link javax.persistence.PersistenceUnits}
960 	 *            annotation.
961 	 */
962 	public void setJavaxPersistencePersistenceUnits(
963 			final List<JavaxPersistenceUnit> javaxPersistencePersistenceUnits) {
964 		this.javaxPersistencePersistenceUnits = javaxPersistencePersistenceUnits;
965 	}
966 
967 	/**
968 	 * the attributes for a Stateless/Stateful/MDB.
969 	 * @return the attributes for a Stateless/Stateful/MDB
970 	 */
971 	public JCommonBean getJCommonBean() {
972 		return jCommonBean;
973 	}
974 
975 	/**
976 	 * Sets the attributes for a Stateless/Stateful/MDB.
977 	 * 
978 	 * @param commonBean
979 	 *            the attributes
980 	 */
981 	public void setJCommonBean(final JCommonBean commonBean) {
982 		jCommonBean = commonBean;
983 	}
984 
985 	/**
986 	 * the attributes for a Stateful.
987 	 * @return the attributes for a Stateful
988 	 */
989 	public JStateful getJStateful() {
990 		return jStateful;
991 	}
992 
993 	/**
994 	 * Sets the attributes for a Stateful.
995 	 * 
996 	 * @param jStateful
997 	 *            the attributes
998 	 */
999 	public void setJStateful(final JStateful jStateful) {
1000 		this.jStateful = jStateful;
1001 	}
1002 
1003 	/**
1004 	 * the attributes for a Stateless.
1005 	 * @return the attributes for a Stateless
1006 	 */
1007 	public JStateless getJStateless() {
1008 		return jStateless;
1009 	}
1010 
1011 	/**
1012 	 * Sets the attributes for a Stateless.
1013 	 * 
1014 	 * @param jStateless
1015 	 *            the attributes
1016 	 */
1017 	public void setJStateless(final JStateless jStateless) {
1018 		this.jStateless = jStateless;
1019 	}
1020 
1021 	/**
1022 	 * the jService.
1023 	 * @return the jService
1024 	 */
1025 	public JService getJService() {
1026 		return jService;
1027 	}
1028 
1029 	/**
1030 	 * Sets the attributes for a Stateless.
1031 	 * 
1032 	 * @param service
1033 	 *            the jService to set
1034 	 */
1035 	public void setJService(final JService service) {
1036 		jService = service;
1037 	}
1038 
1039 	/**
1040 	 * true if the class has been modified.
1041 	 * @return true if the class has been modified.
1042 	 *  
1043 	 */
1044 	public boolean wasModified() {
1045 		return modified;
1046 	}
1047 
1048 	/**
1049 	 * Defines that this class has been modified.
1050 	 */
1051 	public void setModified() {
1052 		this.modified = true;
1053 	}
1054 
1055 }