Source Code Cross Referenced for InheritanceMethodResolver.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » deployment » 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 » J2EE » ow2 easybeans » org.ow2.easybeans.deployment.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@ow2.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 2057 2007-11-21 15:35:32Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.deployment.annotations.helper.bean;
025:
026:        import org.ow2.easybeans.asm.Opcodes;
027:        import org.ow2.easybeans.asm.Type;
028:        import org.ow2.easybeans.deployment.annotations.JMethod;
029:        import org.ow2.easybeans.deployment.annotations.exceptions.ResolverException;
030:        import org.ow2.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
031:        import org.ow2.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata;
032:        import org.ow2.easybeans.deployment.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:                        MethodAnnotationMetadata beanMethod = beanclassAnnotationMetadata
123:                                .getMethodAnnotationMetadata(method);
124:
125:                        // overriding ?
126:                        boolean overrided = true;
127:                        overrided = !((method.getAccess() & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE);
128:
129:                        // Add only if it is not present or if current method is not
130:                        // overriding super method (it means super method is private)
131:                        if (beanMethod == null
132:                                || (!overrided && beanMethod != null && !beanMethod
133:                                        .isInherited())) {
134:                            // Add a clone of the method to bean class
135:                            MethodAnnotationMetadata clonedMethodAnnotationMetadata = (MethodAnnotationMetadata) methodAnnotationMetadata
136:                                    .clone();
137:                            // set new class linked to this method metadata
138:                            clonedMethodAnnotationMetadata
139:                                    .setClassAnnotationMetadata(beanclassAnnotationMetadata);
140:
141:                            // method is inherited
142:                            clonedMethodAnnotationMetadata.setInherited(true,
143:                                    super ClassMetadata);
144:
145:                            beanclassAnnotationMetadata
146:                                    .addMethodAnnotationMetadata(clonedMethodAnnotationMetadata);
147:
148:                            // lifecycle / aroundInvoke
149:                            if (clonedMethodAnnotationMetadata
150:                                    .isPostConstruct()) {
151:                                beanclassAnnotationMetadata
152:                                        .addPostConstructMethodMetadata(clonedMethodAnnotationMetadata);
153:                            }
154:                            if (clonedMethodAnnotationMetadata.isPreDestroy()) {
155:                                beanclassAnnotationMetadata
156:                                        .addPreDestroyMethodMetadata(clonedMethodAnnotationMetadata);
157:                            }
158:                            if (clonedMethodAnnotationMetadata.isPostActivate()) {
159:                                beanclassAnnotationMetadata
160:                                        .addPostActivateMethodMetadata(clonedMethodAnnotationMetadata);
161:                            }
162:                            if (clonedMethodAnnotationMetadata.isPrePassivate()) {
163:                                beanclassAnnotationMetadata
164:                                        .addPrePassivateMethodMetadata(clonedMethodAnnotationMetadata);
165:                            }
166:                            if (clonedMethodAnnotationMetadata.isAroundInvoke()) {
167:                                beanclassAnnotationMetadata
168:                                        .addAroundInvokeMethodMetadata(clonedMethodAnnotationMetadata);
169:                            }
170:                        }
171:                    }
172:
173:                    // Loop again
174:                    addMethodMetadata(beanclassAnnotationMetadata,
175:                            superClassMetadata);
176:
177:                }
178:            }
179:
180:        }
w___ww.___j__av___a_2s___.___c__o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.