Source Code Cross Referenced for ClassAnnotationMetadata.java in  » Testing » Ejb3Unit » com » bm » ejb3metadata » annotations » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » Ejb3Unit » com.bm.ejb3metadata.annotations.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.bm.ejb3metadata.annotations.metadata;
0002:
0003:        import static javax.ejb.TransactionAttributeType.REQUIRED;
0004:        import static javax.ejb.TransactionManagementType.CONTAINER;
0005:
0006:        import java.util.ArrayList;
0007:        import java.util.Collection;
0008:        import java.util.HashMap;
0009:        import java.util.LinkedList;
0010:        import java.util.List;
0011:        import java.util.Map;
0012:
0013:        import javax.ejb.ApplicationException;
0014:        import javax.ejb.TransactionAttributeType;
0015:        import javax.ejb.TransactionManagementType;
0016:
0017:        import com.bm.ejb3metadata.annotations.ClassType;
0018:        import com.bm.ejb3metadata.annotations.InterceptorType;
0019:        import com.bm.ejb3metadata.annotations.JClassInterceptor;
0020:        import com.bm.ejb3metadata.annotations.JField;
0021:        import com.bm.ejb3metadata.annotations.JMethod;
0022:        import com.bm.ejb3metadata.annotations.exceptions.InterceptorsValidationException;
0023:        import com.bm.ejb3metadata.annotations.impl.JAnnotationResource;
0024:        import com.bm.ejb3metadata.annotations.impl.JCommonBean;
0025:        import com.bm.ejb3metadata.annotations.impl.JEjbEJB;
0026:        import com.bm.ejb3metadata.annotations.impl.JInterceptors;
0027:        import com.bm.ejb3metadata.annotations.impl.JLocal;
0028:        import com.bm.ejb3metadata.annotations.impl.JMessageDriven;
0029:        import com.bm.ejb3metadata.annotations.impl.JRemote;
0030:        import com.bm.ejb3metadata.annotations.impl.JService;
0031:        import com.bm.ejb3metadata.annotations.impl.JStateful;
0032:        import com.bm.ejb3metadata.annotations.impl.JStateless;
0033:        import com.bm.ejb3metadata.annotations.impl.JavaxPersistenceContext;
0034:        import com.bm.ejb3metadata.annotations.impl.JavaxPersistenceUnit;
0035:        import com.bm.ejb3metadata.annotations.metadata.interfaces.IEJBInterceptors;
0036:        import com.bm.ejb3metadata.annotations.metadata.interfaces.ITransactionAttribute;
0037:
0038:        /**
0039:         * This class represents the annotation metadata of a Bean.<br>
0040:         * From this class, we can access to all methods of a bean with its associated
0041:         * information.
0042:         * 
0043:         * @author Daniel Wiese
0044:         */
0045:        public class ClassAnnotationMetadata extends CommonAnnotationMetadata
0046:                implements  ITransactionAttribute, IEJBInterceptors {
0047:
0048:            private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
0049:                    .getLogger(ClassAnnotationMetadata.class);
0050:
0051:            /**
0052:             * List of method annotations metadata.
0053:             */
0054:            private Map<JMethod, MethodAnnotationMetadata> methodsAnnotationMetadata = null;
0055:
0056:            /**
0057:             * List of field annotations metadata.
0058:             */
0059:            private Map<JField, FieldAnnotationMetadata> fieldsAnnotationMetadata = null;
0060:
0061:            /**
0062:             * Parent meta data.
0063:             */
0064:            private EjbJarAnnotationMetadata ejbJarAnnotationMetadata = null;
0065:
0066:            /**
0067:             * List of local interfaces.
0068:             */
0069:            private JLocal jLocal = null;
0070:
0071:            /**
0072:             * List of remote interfaces.
0073:             */
0074:            private JRemote jRemote = null;
0075:
0076:            /**
0077:             * CommonBean description.
0078:             */
0079:            private JCommonBean jCommonBean = null;
0080:
0081:            /**
0082:             * Message Driven attribute.
0083:             */
0084:            private JMessageDriven jMessageDriven = null;
0085:
0086:            /**
0087:             * Stateless attribute.
0088:             */
0089:            private JStateless jStateless = null;
0090:
0091:            /**
0092:             * Stateful attribute.
0093:             */
0094:            private JStateful jStateful = null;
0095:
0096:            /**
0097:             * Servie attribute (singelton).
0098:             */
0099:            private JService jService = null;
0100:
0101:            /**
0102:             * Local Home.
0103:             */
0104:            private String localHome = null;
0105:
0106:            /**
0107:             * Remote Home.
0108:             */
0109:            private String remoteHome = null;
0110:
0111:            /**
0112:             * List of annotation interceptors.
0113:             */
0114:            private JInterceptors annotationInterceptors = null;
0115:
0116:            /**
0117:             * User interceptors. These interceptors correspond to a list of Interceptor
0118:             * that user has specified in its bean class. It is the interceptors defined
0119:             * in interceptor classes, not the bean class itself. Map&lt;interceptor
0120:             * type &lt;--&gt; List of methods/class corresponding to the
0121:             * interceptor&gt;
0122:             */
0123:            private Map<InterceptorType, List<JClassInterceptor>> externalUserInterceptors = null;
0124:
0125:            /**
0126:             * Transaction management type (default = container).
0127:             */
0128:            private TransactionManagementType transactionManagementType = CONTAINER;
0129:
0130:            /**
0131:             * Transaction attribute type (default = required).
0132:             */
0133:            private TransactionAttributeType transactionAttributeType = REQUIRED;
0134:
0135:            /**
0136:             * Application exception annotation.
0137:             */
0138:            private ApplicationException applicationException = null;
0139:
0140:            /**
0141:             * Superclass name.
0142:             */
0143:            private String super Name = null;
0144:
0145:            /**
0146:             * Interfaces of this clas.
0147:             */
0148:            private String[] interfaces = null;
0149:
0150:            /**
0151:             * The type of the class.
0152:             * 
0153:             * @see ClassType
0154:             */
0155:            private ClassType classType = null;
0156:
0157:            /**
0158:             * Name of the class associated to this metadata.
0159:             */
0160:            private String className = null;
0161:
0162:            /**
0163:             * List of &#64;{@link javax.interceptor.AroundInvoke} methods on this
0164:             * class (should be only one per class, validating occurs after).
0165:             */
0166:            private List<MethodAnnotationMetadata> aroundInvokeMethodsMetadata = null;
0167:
0168:            /**
0169:             * Object representing &#64;{@link javax.ejb.EJBs} annotation.
0170:             */
0171:            private List<JEjbEJB> jEjbEJBs = null;
0172:
0173:            /**
0174:             * Object representing &#64;{@link javax.annotation.Resources} annotation.
0175:             */
0176:            private List<JAnnotationResource> jAnnotationResources = null;
0177:
0178:            /**
0179:             * Object representing &#64;{@link javax.persistence.PersistenceContext}
0180:             * annotation.
0181:             */
0182:            private List<JavaxPersistenceContext> javaxPersistencePersistenceContexts = null;
0183:
0184:            /**
0185:             * Object representing &#64;{@link javax.persistence.PersistenceUnit}
0186:             * annotation.
0187:             */
0188:            private List<JavaxPersistenceUnit> javaxPersistencePersistenceUnits = null;
0189:
0190:            /**
0191:             * Methods used for &#64;{@link javax.annotation.PostConstruct} on this
0192:             * class (only one per class but may be defined in super classes).
0193:             */
0194:            private LinkedList<MethodAnnotationMetadata> postConstructMethodsMetadata = null;
0195:
0196:            /**
0197:             * Methods used for &#64;{@link javax.annotation.PreDestroy} on this class
0198:             * (only one per class but may be defined in super classes).
0199:             */
0200:            private LinkedList<MethodAnnotationMetadata> preDestroyMethodsMetadata = null;
0201:
0202:            /**
0203:             * Methods used for &#64;{@link javax.ejb.PostActivate} on this class (only
0204:             * one per class but may be defined in super classes).
0205:             */
0206:            private LinkedList<MethodAnnotationMetadata> postActivateMethodsMetadata = null;
0207:
0208:            /**
0209:             * Methods used for &#64;{@link javax.ejb.PrePassivate} on this class (only
0210:             * one per class but may be defined in super classes).
0211:             */
0212:            private LinkedList<MethodAnnotationMetadata> prePassivateMethodsMetadata = null;
0213:
0214:            /**
0215:             * Is that the class represented by this metadata has already been modified ?
0216:             */
0217:            private boolean modified = false;
0218:
0219:            /**
0220:             * Constructor.
0221:             * 
0222:             * @param className
0223:             *            name of the class associated to these metadatas.
0224:             * @param ejbJarAnnotationMetadata
0225:             *            parent metadata object.
0226:             */
0227:            public ClassAnnotationMetadata(final String className,
0228:                    final EjbJarAnnotationMetadata ejbJarAnnotationMetadata) {
0229:                this .className = className;
0230:                this .methodsAnnotationMetadata = new HashMap<JMethod, MethodAnnotationMetadata>();
0231:                this .fieldsAnnotationMetadata = new HashMap<JField, FieldAnnotationMetadata>();
0232:                this .ejbJarAnnotationMetadata = ejbJarAnnotationMetadata;
0233:                this .postConstructMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
0234:                this .preDestroyMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
0235:                this .postActivateMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
0236:                this .prePassivateMethodsMetadata = new LinkedList<MethodAnnotationMetadata>();
0237:            }
0238:
0239:            /**
0240:             * name of the bean (associated to this metadata).
0241:             * 
0242:             * @return name of the bean (associated to this metadata).
0243:             */
0244:            public String getClassName() {
0245:                return className;
0246:            }
0247:
0248:            /**
0249:             * Add method annotation metadata for a given Bean.
0250:             * 
0251:             * @param methodAnnotationMetadata
0252:             *            metadata of a method.
0253:             */
0254:            public void addMethodAnnotationMetadata(
0255:                    final MethodAnnotationMetadata methodAnnotationMetadata) {
0256:                JMethod key = methodAnnotationMetadata.getJMethod();
0257:                // already exists ?
0258:                if (methodsAnnotationMetadata.containsKey(key)) {
0259:                    String msg = "BeanAnnotationMetadata.addMethodAnnotationMetadata.alreadyPresent";
0260:                    logger.debug(msg);
0261:                    throw new IllegalStateException(msg);
0262:                }
0263:                methodsAnnotationMetadata.put(key, methodAnnotationMetadata);
0264:            }
0265:
0266:            /**
0267:             * jMethod key of the map of methods annotations.
0268:             * 
0269:             * @param jMethod
0270:             *            key of the map of methods annotations.
0271:             * @return method annotation metadata of a given method.
0272:             */
0273:            public MethodAnnotationMetadata getMethodAnnotationMetadata(
0274:                    final JMethod jMethod) {
0275:                return methodsAnnotationMetadata.get(jMethod);
0276:            }
0277:
0278:            /**
0279:             * Get collections of methods annotation metadata.
0280:             * 
0281:             * @return collections of methods annotation metadata.
0282:             */
0283:            public Collection<MethodAnnotationMetadata> getMethodAnnotationMetadataCollection() {
0284:                return methodsAnnotationMetadata.values();
0285:            }
0286:
0287:            /**
0288:             * Add field annotation metadata for a given Bean.
0289:             * 
0290:             * @param fieldAnnotationMetadata
0291:             *            metadata of a field.
0292:             */
0293:            public void addFieldAnnotationMetadata(
0294:                    final FieldAnnotationMetadata fieldAnnotationMetadata) {
0295:                JField key = fieldAnnotationMetadata.getJField();
0296:                // already exists ?
0297:                if (fieldsAnnotationMetadata.containsKey(key)) {
0298:                    String msg = "BeanAnnotationMetadata.addFieldAnnotationMetadata.alreadyPresent";
0299:                    logger.debug(msg);
0300:                    throw new IllegalStateException(msg);
0301:                }
0302:                fieldsAnnotationMetadata.put(key, fieldAnnotationMetadata);
0303:            }
0304:
0305:            /**
0306:             * key of the map of fields annotations.
0307:             * 
0308:             * @param jField
0309:             *            key of the map of fields annotations.
0310:             * @return field annotation metadata of a given method.
0311:             */
0312:            public FieldAnnotationMetadata getFieldAnnotationMetadata(
0313:                    final JField jField) {
0314:                return fieldsAnnotationMetadata.get(jField);
0315:            }
0316:
0317:            /**
0318:             * Get collections of fields annotation metadata.
0319:             * 
0320:             * @return collections of fields annotation metadata.
0321:             */
0322:            public Collection<FieldAnnotationMetadata> getFieldAnnotationMetadataCollection() {
0323:                return fieldsAnnotationMetadata.values();
0324:            }
0325:
0326:            /**
0327:             * Sets the local interfaces of this class.
0328:             * 
0329:             * @param jLocal
0330:             *            list of interfaces.
0331:             */
0332:            public void setLocalInterfaces(final JLocal jLocal) {
0333:                this .jLocal = jLocal;
0334:            }
0335:
0336:            /**
0337:             * Sets the remote interfaces of this class.
0338:             * 
0339:             * @param jRemote
0340:             *            list of interfaces.
0341:             */
0342:            public void setRemoteInterfaces(final JRemote jRemote) {
0343:                this .jRemote = jRemote;
0344:            }
0345:
0346:            /**
0347:             * the local interfaces of this class.
0348:             * 
0349:             * @return the local interfaces of this class.
0350:             */
0351:            public JLocal getLocalInterfaces() {
0352:                return jLocal;
0353:            }
0354:
0355:            /**
0356:             * the remote interfaces of this class.
0357:             * 
0358:             * @return the remote interfaces of this class.
0359:             */
0360:            public JRemote getRemoteInterfaces() {
0361:                return jRemote;
0362:            }
0363:
0364:            /**
0365:             * true if the class is a stateless class.
0366:             * 
0367:             * @return true if the class is a stateless class
0368:             */
0369:            public boolean isStateless() {
0370:                return (classType != null && classType == ClassType.STATELESS);
0371:            }
0372:
0373:            /**
0374:             * true if the class is a stateful class.
0375:             * @return true if the class is a stateful class
0376:             */
0377:            public boolean isStateful() {
0378:                return (classType != null && classType == ClassType.STATEFUL);
0379:            }
0380:
0381:            /**
0382:             * true if the class is a session bean class.
0383:             * @return true if the class is a session bean class
0384:             */
0385:            public boolean isSession() {
0386:                return (classType != null && (classType == ClassType.STATELESS || classType == ClassType.STATEFUL));
0387:            }
0388:
0389:            /**
0390:             * true if the class is an MDB class.
0391:             * @return true if the class is an MDB class
0392:             */
0393:            public boolean isMdb() {
0394:                return (classType != null && classType == ClassType.MDB);
0395:            }
0396:
0397:            /**
0398:             * true if the class is an MDB class.
0399:             * @return true if the class is an MDB class
0400:             */
0401:            public boolean isService() {
0402:                return (classType != null && classType == ClassType.SERVICE);
0403:            }
0404:
0405:            /**
0406:             * Sets the type of this class.
0407:             * 
0408:             * @param cType
0409:             *            a type from enum class ClassType.
0410:             * @see com.bm.ejb3metadata.annotations.ClassType
0411:             */
0412:            public void setClassType(final ClassType cType) {
0413:                this .classType = cType;
0414:            }
0415:
0416:            /**
0417:             * Message driven attribute.
0418:             * @return Message driven attribute.
0419:             */
0420:            public JMessageDriven getJMessageDriven() {
0421:                return jMessageDriven;
0422:            }
0423:
0424:            /**
0425:             * Sets the message driven bean object.
0426:             * 
0427:             * @param messageDriven
0428:             *            attributes of message driven bean.
0429:             */
0430:            public void setJMessageDriven(final JMessageDriven messageDriven) {
0431:                jMessageDriven = messageDriven;
0432:            }
0433:
0434:            /**
0435:             * string representation.
0436:             * @return string representation.
0437:             */
0438:            @Override
0439:            public String toString() {
0440:                StringBuilder sb = new StringBuilder();
0441:                // classname
0442:                sb.append(this .getClass().getName().substring(
0443:                        this .getClass().getPackage().getName().length() + 1));
0444:                sb.append("[\n");
0445:
0446:                // Add super class toString()
0447:                sb.append(super .toString());
0448:
0449:                // Class name
0450:                concatStringBuilder("className", className, sb);
0451:
0452:                // superclass name
0453:                concatStringBuilder("superName", super Name, sb);
0454:
0455:                // interfaces
0456:                concatStringBuilder("interfaces", interfaces, sb);
0457:
0458:                // classType
0459:                concatStringBuilder("classType", classType, sb);
0460:
0461:                // jLocal
0462:                concatStringBuilder("jLocal", jLocal, sb);
0463:
0464:                // aroundInvokeMethodMetadatas
0465:                concatStringBuilder("aroundInvokeMethodsMetadata",
0466:                        aroundInvokeMethodsMetadata, sb);
0467:
0468:                // jRemote
0469:                concatStringBuilder("jRemote", jRemote, sb);
0470:
0471:                // jMessageDriven
0472:                concatStringBuilder("jMessageDriven", jMessageDriven, sb);
0473:
0474:                // remoteHome
0475:                concatStringBuilder("remoteHome", remoteHome, sb);
0476:
0477:                // localHome
0478:                concatStringBuilder("localHome", localHome, sb);
0479:
0480:                // transactionManagementType
0481:                concatStringBuilder("transactionManagementType",
0482:                        transactionManagementType, sb);
0483:
0484:                // transactionAttributeType
0485:                concatStringBuilder("transactionAttributeType",
0486:                        transactionAttributeType, sb);
0487:
0488:                // annotation Interceptors
0489:                concatStringBuilder("annotationInterceptors",
0490:                        annotationInterceptors, sb);
0491:
0492:                // jEjbEJBs
0493:                concatStringBuilder("jAnnotationEJBs", jEjbEJBs, sb);
0494:
0495:                // jAnnotationResources
0496:                concatStringBuilder("jAnnotationResources",
0497:                        jAnnotationResources, sb);
0498:
0499:                // javaxPersistencePersistenceContexts
0500:                concatStringBuilder("javaxPersistencePersistenceContexts",
0501:                        javaxPersistencePersistenceContexts, sb);
0502:
0503:                // javaxPersistencePersistenceUnits
0504:                concatStringBuilder("javaxPersistencePersistenceUnits",
0505:                        javaxPersistencePersistenceUnits, sb);
0506:
0507:                // Methods
0508:                for (MethodAnnotationMetadata methodAnnotationMetadata : getMethodAnnotationMetadataCollection()) {
0509:                    concatStringBuilder("methods", methodAnnotationMetadata, sb);
0510:                }
0511:
0512:                sb.append("]");
0513:                return sb.toString();
0514:            }
0515:
0516:            /**
0517:             * the &#64;{@link javax.ejb.RemoteHome} class name.
0518:             * @return the &#64;{@link javax.ejb.RemoteHome} class name.
0519:             */
0520:            public String getRemoteHome() {
0521:                return remoteHome;
0522:            }
0523:
0524:            /**
0525:             * Sets the &#64;{@link javax.ejb.RemoteHome} class name.
0526:             * 
0527:             * @param remoteHome
0528:             *            the class name.
0529:             */
0530:            public void setRemoteHome(final String remoteHome) {
0531:                this .remoteHome = remoteHome;
0532:            }
0533:
0534:            /**
0535:             * the &#64;{@link javax.ejb.LocalHome} class name.
0536:             * @return the &#64;{@link javax.ejb.LocalHome} class name.
0537:             */
0538:            public String getLocalHome() {
0539:                return localHome;
0540:            }
0541:
0542:            /**
0543:             * Sets the &#64;{@link javax.ejb.LocalHome} class name.
0544:             * the &#64;{@link javax.ejb.LocalHome} class name.
0545:             * @param localHome
0546:             *            the class name.
0547:             */
0548:            public void setLocalHome(final String localHome) {
0549:                this .localHome = localHome;
0550:            }
0551:
0552:            /**
0553:             * transaction management type from.
0554:             * @return transaction management type from.
0555:             * @see TransactionManagementType.
0556:             */
0557:            public TransactionManagementType getTransactionManagementType() {
0558:                return transactionManagementType;
0559:            }
0560:
0561:            /**
0562:             * Sets transaction management type.
0563:             * 
0564:             * @see javax.ejb.TransactionManagementType
0565:             * @param transactionManagementType
0566:             *            value. (BEAN, CONTAINER)
0567:             */
0568:            public void setTransactionManagementType(
0569:                    final TransactionManagementType transactionManagementType) {
0570:                this .transactionManagementType = transactionManagementType;
0571:            }
0572:
0573:            /**
0574:             *  transaction Attribute type.
0575:             * @return transaction Attribute type.
0576:             * @see javax.ejb.TransactionAttributeType
0577:             */
0578:            public TransactionAttributeType getTransactionAttributeType() {
0579:                return transactionAttributeType;
0580:            }
0581:
0582:            /**
0583:             * Set Transaction Attribute Type.
0584:             * 
0585:             * @see javax.ejb.TransactionAttributeType
0586:             * @param transactionAttributeType
0587:             *            the type of transaction.
0588:             */
0589:            public void setTransactionAttributeType(
0590:                    final TransactionAttributeType transactionAttributeType) {
0591:                this .transactionAttributeType = transactionAttributeType;
0592:            }
0593:
0594:            /**
0595:             * Object representing list of &#64;{@link javax.interceptor.Interceptors}.
0596:             * @return object representing list of &#64;{@link javax.interceptor.Interceptors}.
0597:             */
0598:            public JInterceptors getAnnotationInterceptors() {
0599:                return annotationInterceptors;
0600:            }
0601:
0602:            /**
0603:             * Sets the object representing the &#64;{@link javax.interceptor.Interceptors}
0604:             * annotation.
0605:             * 
0606:             * @param annotationInterceptors
0607:             *            list of classes
0608:             */
0609:            public void setAnnotationsInterceptors(
0610:                    final JInterceptors annotationInterceptors) {
0611:                this .annotationInterceptors = annotationInterceptors;
0612:            }
0613:
0614:            /**
0615:             * the &#64;{@link javax.ejb.ApplicationException} annotation.
0616:             * @return the &#64;{@link javax.ejb.ApplicationException} annotation.
0617:             */
0618:            public ApplicationException getApplicationException() {
0619:                return applicationException;
0620:            }
0621:
0622:            /**
0623:             * Sets the object representing the &#64;{@link javax.ejb.ApplicationException}
0624:             * annotation.
0625:             * 
0626:             * @param applicationException
0627:             *            object representation
0628:             */
0629:            public void setApplicationException(
0630:                    final ApplicationException applicationException) {
0631:                this .applicationException = applicationException;
0632:            }
0633:
0634:            /**
0635:             * true if the classs is a Bean.
0636:             * @return true if the classs is a Bean
0637:             */
0638:            public boolean isBean() {
0639:                return isStateless() || isStateful() || isMdb() || isService();
0640:            }
0641:
0642:            /**
0643:             * array of interfaces name.
0644:             * @return array of interfaces name.
0645:             */
0646:            public String[] getInterfaces() {
0647:                return interfaces;
0648:            }
0649:
0650:            /**
0651:             * Sets the interfaces of this class.
0652:             * 
0653:             * @param interfaces
0654:             *            name of interfaces.
0655:             */
0656:            public void setInterfaces(final String[] interfaces) {
0657:                this .interfaces = interfaces;
0658:            }
0659:
0660:            /**
0661:             * the super class name.
0662:             * @return the super class name.
0663:             */
0664:            public String getSuperName() {
0665:                return super Name;
0666:            }
0667:
0668:            /**
0669:             * Sets the super class name.
0670:             * 
0671:             * @param superName
0672:             *            name of the super class.
0673:             */
0674:            public void setSuperName(final String super Name) {
0675:                this .super Name = super Name;
0676:            }
0677:
0678:            /**
0679:             * parent metadata object.
0680:             * @return parent metadata object.
0681:             */
0682:            public EjbJarAnnotationMetadata getEjbJarAnnotationMetadata() {
0683:                return ejbJarAnnotationMetadata;
0684:            }
0685:
0686:            /**
0687:             * Map&lt;interceptor type &lt;--&gt; List of methods/class
0688:             *         corresponding to the interceptor&gt; (interceptor classes) of
0689:             *         user interceptors that enhancer will use.
0690:             * @return Map&lt;interceptor type &lt;--&gt; List of methods/class
0691:             *         corresponding to the interceptor&gt; (interceptor classes) of
0692:             *         user interceptors that enhancer will use.
0693:             */
0694:            public Map<InterceptorType, List<JClassInterceptor>> getExternalUserEasyBeansInterceptors() {
0695:                return externalUserInterceptors;
0696:            }
0697:
0698:            /**
0699:             * Sets the list of user interceptors that enhancers will use.<br>
0700:             * These interceptors are defined outside the bean class (interceptor
0701:             * classes).
0702:             * 
0703:             * @param externalUserInterceptors
0704:             *            list of interceptors that enhancer will use.
0705:             */
0706:            public void setExternalUserInterceptors(
0707:                    final Map<InterceptorType, List<JClassInterceptor>> externalUserInterceptors) {
0708:                this .externalUserInterceptors = externalUserInterceptors;
0709:            }
0710:
0711:            /**
0712:             * the method metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
0713:             * @return the method metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
0714:             */
0715:            public boolean isAroundInvokeMethodMetadata() {
0716:                return (aroundInvokeMethodsMetadata != null);
0717:            }
0718:
0719:            /**
0720:             * the list of methods metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
0721:             * @return the list of methods metadata with annotation &#64;{@link javax.interceptor.AroundInvoke}.
0722:             */
0723:            public List<MethodAnnotationMetadata> getAroundInvokeMethodMetadatas() {
0724:                return aroundInvokeMethodsMetadata;
0725:            }
0726:
0727:            /**
0728:             * Add a &#64;{@link javax.interceptor.AroundInvoke} method of this class.
0729:             * @param aroundInvokeMethodMetadata
0730:             *            the method.
0731:             */
0732:            public void addAroundInvokeMethodMetadata(
0733:                    final MethodAnnotationMetadata aroundInvokeMethodMetadata) {
0734:                if (aroundInvokeMethodsMetadata == null) {
0735:                    this .aroundInvokeMethodsMetadata = new ArrayList<MethodAnnotationMetadata>();
0736:                }
0737:                aroundInvokeMethodsMetadata.add(aroundInvokeMethodMetadata);
0738:            }
0739:
0740:            /**
0741:             *  the methods metadata with annotation &#64;{@link javax.annotation.PostConstruct}.
0742:             * @return the methods metadata with annotation &#64;{@link javax.annotation.PostConstruct}.
0743:             */
0744:            public LinkedList<MethodAnnotationMetadata> getPostConstructMethodsMetadata() {
0745:                return postConstructMethodsMetadata;
0746:            }
0747:
0748:            /**
0749:             * Adds a &#64;{@link javax.annotation.PostConstruct} method of this class.
0750:             * 
0751:             * @param postConstructMethodMetadata
0752:             *            the method.
0753:             */
0754:            public void addPostConstructMethodMetadata(
0755:                    final MethodAnnotationMetadata postConstructMethodMetadata) {
0756:                checkLifeCycleDuplicate(postConstructMethodMetadata,
0757:                        InterceptorType.POST_CONSTRUCT,
0758:                        getPostConstructMethodsMetadata());
0759:                this .postConstructMethodsMetadata
0760:                        .addFirst(postConstructMethodMetadata);
0761:            }
0762:
0763:            /**
0764:             * Checks that only method at one level of a class is present.
0765:             * 
0766:             * @param postConstructMethodMetadata
0767:             *            method to check
0768:             * @param itcType
0769:             *            the type of interceptor (used for the error)
0770:             * @param existingList
0771:             *            current list of methods
0772:             */
0773:            private void checkLifeCycleDuplicate(
0774:                    final MethodAnnotationMetadata postConstructMethodMetadata,
0775:                    final InterceptorType itcType,
0776:                    final List<MethodAnnotationMetadata> existingList) {
0777:                // First case : not inherited
0778:                ClassAnnotationMetadata wantToAddClassMetadata = postConstructMethodMetadata
0779:                        .getClassAnnotationMetadata();
0780:                if (postConstructMethodMetadata.isInherited()) {
0781:                    wantToAddClassMetadata = postConstructMethodMetadata
0782:                            .getOriginalClassAnnotationMetadata();
0783:                }
0784:                for (MethodAnnotationMetadata method : existingList) {
0785:                    ClassAnnotationMetadata compareMetaData;
0786:                    if (method.isInherited()) {
0787:                        compareMetaData = method
0788:                                .getOriginalClassAnnotationMetadata();
0789:                    } else {
0790:                        compareMetaData = method.getClassAnnotationMetadata();
0791:                    }
0792:                    if (compareMetaData.equals(wantToAddClassMetadata)) {
0793:                        throw new InterceptorsValidationException("Class "
0794:                                + getClassName() + " has already a " + itcType
0795:                                + " method which is " + method.getMethodName()
0796:                                + ", cannot set new method "
0797:                                + postConstructMethodMetadata.getMethodName());
0798:                    }
0799:                }
0800:            }
0801:
0802:            /**
0803:             * the methods metadata with annotation &#64;{@link javax.annotation.PreDestroy}.
0804:             * @return the methods metadata with annotation &#64;{@link javax.annotation.PreDestroy}.
0805:             */
0806:            public LinkedList<MethodAnnotationMetadata> getPreDestroyMethodsMetadata() {
0807:                return preDestroyMethodsMetadata;
0808:            }
0809:
0810:            /**
0811:             * Adds a &#64;{@link javax.annotation.PreDestroy} method of this class.
0812:             * 
0813:             * @param preDestroyMethodMetadata
0814:             *            the method.
0815:             */
0816:            public void addPreDestroyMethodMetadata(
0817:                    final MethodAnnotationMetadata preDestroyMethodMetadata) {
0818:                checkLifeCycleDuplicate(preDestroyMethodMetadata,
0819:                        InterceptorType.PRE_DESTROY,
0820:                        getPreDestroyMethodsMetadata());
0821:                this .preDestroyMethodsMetadata
0822:                        .addFirst(preDestroyMethodMetadata);
0823:            }
0824:
0825:            /**
0826:             * the methods metadata with annotation &#64;{@link javax.ejb.PostActivate}.
0827:             * @return the methods metadata with annotation &#64;{@link javax.ejb.PostActivate}.
0828:             */
0829:            public LinkedList<MethodAnnotationMetadata> getPostActivateMethodsMetadata() {
0830:                return postActivateMethodsMetadata;
0831:            }
0832:
0833:            /**
0834:             * Adds a &#64;{@link javax.ejb.PostActivate} method of this class.
0835:             * 
0836:             * @param postActivateMethodMetadata
0837:             *            the method.
0838:             */
0839:            public void addPostActivateMethodMetadata(
0840:                    final MethodAnnotationMetadata postActivateMethodMetadata) {
0841:                checkLifeCycleDuplicate(postActivateMethodMetadata,
0842:                        InterceptorType.POST_ACTIVATE,
0843:                        getPostActivateMethodsMetadata());
0844:                this .postActivateMethodsMetadata
0845:                        .addFirst(postActivateMethodMetadata);
0846:            }
0847:
0848:            /**
0849:             * the method metadata with annotation &#64;{@link javax.ejb.PrePassivate}.
0850:             * @return the method metadata with annotation &#64;{@link javax.ejb.PrePassivate}.
0851:             */
0852:            public LinkedList<MethodAnnotationMetadata> getPrePassivateMethodsMetadata() {
0853:                return prePassivateMethodsMetadata;
0854:            }
0855:
0856:            /**
0857:             * Adds a &#64;{@link javax.ejb.PrePassivate} method of this class.
0858:             * 
0859:             * @param prePassivateMethodMetadata
0860:             *            the method.
0861:             */
0862:            public void addPrePassivateMethodMetadata(
0863:                    final MethodAnnotationMetadata prePassivateMethodMetadata) {
0864:                checkLifeCycleDuplicate(prePassivateMethodMetadata,
0865:                        InterceptorType.PRE_PASSIVATE,
0866:                        getPrePassivateMethodsMetadata());
0867:                this .prePassivateMethodsMetadata
0868:                        .addFirst(prePassivateMethodMetadata);
0869:            }
0870:
0871:            /**
0872:             * Is that this class is an interceptor class ?
0873:             * 
0874:             * @return true if it the case, else false.
0875:             */
0876:            public boolean isInterceptor() {
0877:                return (aroundInvokeMethodsMetadata != null && aroundInvokeMethodsMetadata
0878:                        .size() > 0)
0879:                        || (postConstructMethodsMetadata != null && postConstructMethodsMetadata
0880:                                .size() > 0)
0881:                        || (preDestroyMethodsMetadata != null && preDestroyMethodsMetadata
0882:                                .size() > 0)
0883:                        || (prePassivateMethodsMetadata != null && prePassivateMethodsMetadata
0884:                                .size() > 0)
0885:                        || (postActivateMethodsMetadata != null && postActivateMethodsMetadata
0886:                                .size() > 0);
0887:            }
0888:
0889:            /**
0890:             * jEjbEJBs list representing &#64;{@link javax.ejb.EJBs}
0891:             *         annotation.
0892:             * @return jEjbEJBs list representing &#64;{@link javax.ejb.EJBs}
0893:             *         annotation.
0894:             */
0895:            public List<JEjbEJB> getJEjbEJBs() {
0896:                return jEjbEJBs;
0897:            }
0898:
0899:            /**
0900:             * Set JEjbEJBs object.
0901:             * 
0902:             * @param jEjbEJBs
0903:             *            list representing javax.ejb.EJBs annotation.
0904:             */
0905:            public void setJEjbEJBs(final List<JEjbEJB> jEjbEJBs) {
0906:                this .jEjbEJBs = jEjbEJBs;
0907:            }
0908:
0909:            /**
0910:             * JAnnotationResources list representing &#64;{@link javax.annotation.Resources}
0911:             *         annotation.
0912:             * @return JAnnotationResources list representing &#64;{@link javax.annotation.Resources}
0913:             *         annotation.
0914:             */
0915:            public List<JAnnotationResource> getJAnnotationResources() {
0916:                return jAnnotationResources;
0917:            }
0918:
0919:            /**
0920:             * Sets JAnnotationResources object.
0921:             * 
0922:             * @param jAnnotationResources
0923:             *            list representing javax.annotation.Resources annotation.
0924:             */
0925:            public void setJAnnotationResources(
0926:                    final List<JAnnotationResource> jAnnotationResources) {
0927:                this .jAnnotationResources = jAnnotationResources;
0928:            }
0929:
0930:            /**
0931:             * javaxPersistencePersistenceContexts list representing &#64;{@link javax.persistence.PersistenceContexts}
0932:             *         annotation.
0933:             * @return javaxPersistencePersistenceContexts list representing &#64;{@link javax.persistence.PersistenceContexts}
0934:             *         annotation.
0935:             */
0936:            public List<JavaxPersistenceContext> getJavaxPersistencePersistenceContexts() {
0937:                return javaxPersistencePersistenceContexts;
0938:            }
0939:
0940:            /**
0941:             * Sets JavaxPersistencePersistenceContexts object.
0942:             * 
0943:             * @param javaxPersistencePersistenceContexts
0944:             *            list representing &#64;{@link javax.persistence.PersistenceContexts}
0945:             *            annotation.
0946:             */
0947:            public void setJavaxPersistencePersistenceContexts(
0948:                    final List<JavaxPersistenceContext> javaxPersistencePersistenceContexts) {
0949:                this .javaxPersistencePersistenceContexts = javaxPersistencePersistenceContexts;
0950:            }
0951:
0952:            /**
0953:             * javaxPersistencePersistenceUnits list representing &#64;{@link javax.persistence.PersistenceUnits}
0954:             *         annotation.
0955:             * @return javaxPersistencePersistenceUnits list representing &#64;{@link javax.persistence.PersistenceUnits}
0956:             *         annotation.
0957:             */
0958:            public List<JavaxPersistenceUnit> getJavaxPersistencePersistenceUnits() {
0959:                return javaxPersistencePersistenceUnits;
0960:            }
0961:
0962:            /**
0963:             * Sets setJavaxPersistencePersistenceUnits object.
0964:             * 
0965:             * @param javaxPersistencePersistenceUnits
0966:             *            list representing &#64;{@link javax.persistence.PersistenceUnits}
0967:             *            annotation.
0968:             */
0969:            public void setJavaxPersistencePersistenceUnits(
0970:                    final List<JavaxPersistenceUnit> javaxPersistencePersistenceUnits) {
0971:                this .javaxPersistencePersistenceUnits = javaxPersistencePersistenceUnits;
0972:            }
0973:
0974:            /**
0975:             * the attributes for a Stateless/Stateful/MDB.
0976:             * @return the attributes for a Stateless/Stateful/MDB
0977:             */
0978:            public JCommonBean getJCommonBean() {
0979:                return jCommonBean;
0980:            }
0981:
0982:            /**
0983:             * Sets the attributes for a Stateless/Stateful/MDB.
0984:             * 
0985:             * @param commonBean
0986:             *            the attributes
0987:             */
0988:            public void setJCommonBean(final JCommonBean commonBean) {
0989:                jCommonBean = commonBean;
0990:            }
0991:
0992:            /**
0993:             * the attributes for a Stateful.
0994:             * @return the attributes for a Stateful
0995:             */
0996:            public JStateful getJStateful() {
0997:                return jStateful;
0998:            }
0999:
1000:            /**
1001:             * Sets the attributes for a Stateful.
1002:             * 
1003:             * @param jStateful
1004:             *            the attributes
1005:             */
1006:            public void setJStateful(final JStateful jStateful) {
1007:                this .jStateful = jStateful;
1008:            }
1009:
1010:            /**
1011:             * the attributes for a Stateless.
1012:             * @return the attributes for a Stateless
1013:             */
1014:            public JStateless getJStateless() {
1015:                return jStateless;
1016:            }
1017:
1018:            /**
1019:             * Sets the attributes for a Stateless.
1020:             * 
1021:             * @param jStateless
1022:             *            the attributes
1023:             */
1024:            public void setJStateless(final JStateless jStateless) {
1025:                this .jStateless = jStateless;
1026:            }
1027:
1028:            /**
1029:             * the jService.
1030:             * @return the jService
1031:             */
1032:            public JService getJService() {
1033:                return jService;
1034:            }
1035:
1036:            /**
1037:             * Sets the attributes for a Stateless.
1038:             * 
1039:             * @param service
1040:             *            the jService to set
1041:             */
1042:            public void setJService(final JService service) {
1043:                jService = service;
1044:            }
1045:
1046:            /**
1047:             * true if the class has been modified.
1048:             * @return true if the class has been modified.
1049:             *  
1050:             */
1051:            public boolean wasModified() {
1052:                return modified;
1053:            }
1054:
1055:            /**
1056:             * Defines that this class has been modified.
1057:             */
1058:            public void setModified() {
1059:                this .modified = true;
1060:            }
1061:
1062:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.