Source Code Cross Referenced for InheritanceMethodResolver.java in  » Testing » Ejb3Unit » com » bm » ejb3metadata » annotations » helper » bean » 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.helper.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: easybeans@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: InheritanceMethodResolver.java 486 2006-05-22 15:46:08Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package com.bm.ejb3metadata.annotations.helper.bean;
025:
026:        import org.ejb3unit.asm.Type;
027:
028:        import com.bm.ejb3metadata.annotations.JMethod;
029:        import com.bm.ejb3metadata.annotations.exceptions.ResolverException;
030:        import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
031:        import com.bm.ejb3metadata.annotations.metadata.EjbJarAnnotationMetadata;
032:        import com.bm.ejb3metadata.annotations.metadata.MethodAnnotationMetadata;
033:
034:        /**
035:         * This class adds method meta data to bean class from the super class.<br>
036:         * TODO: Try to analyze super class from a super classloader if not found in the
037:         * current ejb-jar
038:         * @see <a href="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 Spec ?4.6.2</a><br><p>
039:         *      A super class can't be a bean class (stateless, stateful, etc) so the
040:         *      method metadata don't need to be cloned</p>
041:         * @author Florent Benoit
042:         */
043:        public final class InheritanceMethodResolver {
044:
045:            /**
046:             * java.lang.object internal name.
047:             */
048:            private static final String JAVA_LANG_OBJECT = Type
049:                    .getInternalName(Object.class);
050:
051:            /**
052:             * Helper class, no public constructor.
053:             */
054:            private InheritanceMethodResolver() {
055:
056:            }
057:
058:            /**
059:             * Found all method meta data of the super class and adds them to the class
060:             * being analyzed.
061:             * @param classAnnotationMetadata class to analyze
062:             * @throws ResolverException if the super class in not in the given ejb-jar
063:             */
064:            public static void resolve(
065:                    final ClassAnnotationMetadata classAnnotationMetadata)
066:                    throws ResolverException {
067:                addMethodMetadata(classAnnotationMetadata,
068:                        classAnnotationMetadata);
069:            }
070:
071:            /**
072:             * Adds method meta data on the first class by iterating on the second given
073:             * class.
074:             * @param beanclassAnnotationMetadata class where to add method metadata
075:             * @param visitingClassAnnotationMetadata takes method metadata from super
076:             *        class of the given class
077:             * @throws ResolverException if a super class metadata is not found from
078:             *         ejb-jar
079:             */
080:            private static void addMethodMetadata(
081:                    final ClassAnnotationMetadata beanclassAnnotationMetadata,
082:                    final ClassAnnotationMetadata visitingClassAnnotationMetadata)
083:                    throws ResolverException {
084:
085:                // Analyze super classes of the given class
086:                String super Class = visitingClassAnnotationMetadata
087:                        .getSuperName();
088:
089:                if (super Class != null) {
090:
091:                    // If super class is java.lang.Object, break the loop
092:                    if (super Class.equals(JAVA_LANG_OBJECT)) {
093:                        return;
094:                    }
095:
096:                    // Get parent meta-data
097:                    EjbJarAnnotationMetadata ejbJarAnnotationMetadata = beanclassAnnotationMetadata
098:                            .getEjbJarAnnotationMetadata();
099:
100:                    // Get meta data of the super class
101:                    ClassAnnotationMetadata super ClassMetadata = ejbJarAnnotationMetadata
102:                            .getClassAnnotationMetadata(super Class);
103:
104:                    if (super ClassMetadata == null) {
105:                        // TODO : I18n
106:                        throw new ResolverException(
107:                                "The class "
108:                                        + beanclassAnnotationMetadata
109:                                        + " extends the class "
110:                                        + super Class
111:                                        + "but this class seems to be outside of the ejb-jar");
112:                    }
113:
114:                    // Takes method metadata of the super class and adds them to the
115:                    // bean class
116:                    // Note : the flag inherited is set to true
117:                    for (MethodAnnotationMetadata methodAnnotationMetadata : super ClassMetadata
118:                            .getMethodAnnotationMetadataCollection()) {
119:                        // check that the method has not be redefined
120:                        JMethod method = methodAnnotationMetadata.getJMethod();
121:
122:                        // Add only if it is not present.
123:                        if (beanclassAnnotationMetadata
124:                                .getMethodAnnotationMetadata(method) == null) {
125:                            // Add a clone of the method to bean class
126:                            MethodAnnotationMetadata clonedMethodAnnotationMetadata = (MethodAnnotationMetadata) methodAnnotationMetadata
127:                                    .clone();
128:                            // set new class linked to this method metadata
129:                            clonedMethodAnnotationMetadata
130:                                    .setClassAnnotationMetadata(beanclassAnnotationMetadata);
131:                            beanclassAnnotationMetadata
132:                                    .addMethodAnnotationMetadata(clonedMethodAnnotationMetadata);
133:
134:                            // method is inherited
135:                            clonedMethodAnnotationMetadata.setInherited(true,
136:                                    super ClassMetadata);
137:
138:                            // lifecycle / aroundInvoke
139:                            if (clonedMethodAnnotationMetadata
140:                                    .isPostConstruct()) {
141:                                beanclassAnnotationMetadata
142:                                        .addPostConstructMethodMetadata(clonedMethodAnnotationMetadata);
143:                            }
144:                            if (clonedMethodAnnotationMetadata.isPreDestroy()) {
145:                                beanclassAnnotationMetadata
146:                                        .addPreDestroyMethodMetadata(clonedMethodAnnotationMetadata);
147:                            }
148:                            if (clonedMethodAnnotationMetadata.isPostActivate()) {
149:                                beanclassAnnotationMetadata
150:                                        .addPostActivateMethodMetadata(clonedMethodAnnotationMetadata);
151:                            }
152:                            if (clonedMethodAnnotationMetadata.isPrePassivate()) {
153:                                beanclassAnnotationMetadata
154:                                        .addPrePassivateMethodMetadata(clonedMethodAnnotationMetadata);
155:                            }
156:                            if (clonedMethodAnnotationMetadata.isAroundInvoke()) {
157:                                beanclassAnnotationMetadata
158:                                        .addAroundInvokeMethodMetadata(clonedMethodAnnotationMetadata);
159:                            }
160:                        }
161:                    }
162:
163:                    // Loop again
164:                    addMethodMetadata(beanclassAnnotationMetadata,
165:                            superClassMetadata);
166:
167:                }
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.