Source Code Cross Referenced for ResolverHelper.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » deployment » annotations » helper » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2006-2007 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: ResolverHelper.java 1970 2007-10-16 11:49:25Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.deployment.annotations.helper;
025:
026:        import static org.ow2.easybeans.deployment.annotations.helper.bean.InheritanceInterfacesHelper.JAVA_LANG_OBJECT;
027:
028:        import java.util.ArrayList;
029:        import java.util.List;
030:
031:        import org.ow2.easybeans.deployment.annotations.JMethod;
032:        import org.ow2.easybeans.deployment.annotations.exceptions.ResolverException;
033:        import org.ow2.easybeans.deployment.annotations.helper.bean.BusinessMethodResolver;
034:        import org.ow2.easybeans.deployment.annotations.helper.bean.EJB21Finder;
035:        import org.ow2.easybeans.deployment.annotations.helper.bean.InheritanceInterfacesHelper;
036:        import org.ow2.easybeans.deployment.annotations.helper.bean.InheritanceMethodResolver;
037:        import org.ow2.easybeans.deployment.annotations.helper.bean.InterceptorsClassResolver;
038:        import org.ow2.easybeans.deployment.annotations.helper.bean.InterfaceAnnotatedHelper;
039:        import org.ow2.easybeans.deployment.annotations.helper.bean.SecurityResolver;
040:        import org.ow2.easybeans.deployment.annotations.helper.bean.SessionBeanHelper;
041:        import org.ow2.easybeans.deployment.annotations.helper.bean.TimedObjectInterface;
042:        import org.ow2.easybeans.deployment.annotations.helper.bean.TransactionResolver;
043:        import org.ow2.easybeans.deployment.annotations.helper.bean.checks.TimerBeanValidator;
044:        import org.ow2.easybeans.deployment.annotations.helper.bean.mdb.MDBListenerBusinessMethodResolver;
045:        import org.ow2.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
046:        import org.ow2.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata;
047:        import org.ow2.easybeans.deployment.annotations.metadata.MethodAnnotationMetadata;
048:
049:        /**
050:         * This class handle some steps that need to be done after the meta-data
051:         * generation.
052:         * @author Florent Benoit
053:         */
054:        public final class ResolverHelper {
055:
056:            /**
057:             * Helper class, no public constructor.
058:             */
059:            private ResolverHelper() {
060:
061:            }
062:
063:            /**
064:             * The helper will analyze datas of a given EjbJarAnnotationMetadata object.
065:             * @param ejbJarAnnotationMetadata object to analyze
066:             * @throws ResolverException if one of resolver fails
067:             */
068:            public static void resolve(
069:                    final EjbJarAnnotationMetadata ejbJarAnnotationMetadata)
070:                    throws ResolverException {
071:
072:                // Found each bean class
073:                for (ClassAnnotationMetadata classMetaData : ejbJarAnnotationMetadata
074:                        .getClassAnnotationMetadataCollection()) {
075:
076:                    if (classMetaData.isBean()) {
077:
078:                        // Inheritance on interfaces
079:                        InheritanceInterfacesHelper.resolve(classMetaData);
080:                        InterfaceAnnotatedHelper.resolve(classMetaData);
081:                        InheritanceMethodResolver.resolve(classMetaData);
082:
083:                        // Analyze EJB 2.1x home/localhome for finding interface used
084:                        EJB21Finder.resolve(classMetaData);
085:
086:                        // Find business method
087:                        if (classMetaData.isSession()) {
088:                            BusinessMethodResolver.resolve(classMetaData);
089:                        } else if (classMetaData.isMdb()) {
090:                            MDBListenerBusinessMethodResolver
091:                                    .resolve(classMetaData);
092:                        }
093:
094:                        // Security
095:                        SecurityResolver.resolve(classMetaData);
096:
097:                        // Transaction
098:                        TransactionResolver.resolve(classMetaData);
099:
100:                        // Interceptors
101:                        InterceptorsClassResolver.resolve(classMetaData);
102:
103:                        // Check the timer methods (only one by bean) and if the signature is valid
104:                        TimedObjectInterface.resolve(classMetaData);
105:                        TimerBeanValidator.validate(classMetaData);
106:
107:                    }
108:
109:                    // for each bean, call sub helper
110:                    if (classMetaData.isSession()) {
111:                        SessionBeanHelper.resolve(classMetaData);
112:                    }
113:                }
114:            }
115:
116:            /**
117:             * Gets method metadata on the given class metadata for the given method.
118:             * @param bean the class metadata on which retrieve the method
119:             * @param jMethod the method to get
120:             * @param inherited get the correct method in super class, not inherited
121:             * @param interfaceName the name of the interface that the class should have
122:             * @return the method metadata, else exception
123:             */
124:            public static MethodAnnotationMetadata getMethod(
125:                    final ClassAnnotationMetadata bean, final JMethod jMethod,
126:                    final boolean inherited, final String interfaceName) {
127:                MethodAnnotationMetadata method = bean
128:                        .getMethodAnnotationMetadata(jMethod);
129:                if (method == null) {
130:                    throw new IllegalStateException("Bean '" + bean
131:                            + "' implements " + interfaceName + " but no "
132:                            + jMethod + " method found in metadata");
133:                }
134:                // gets the correct method on the correct level. (not the inherited method) if we don't want the inherited method.
135:                if (method.isInherited() && !inherited) {
136:                    String super ClassName = bean.getSuperName();
137:                    // loop while class is not java.lang.Object
138:                    while (!JAVA_LANG_OBJECT.equals(super ClassName)) {
139:                        ClassAnnotationMetadata super MetaData = bean
140:                                .getEjbJarAnnotationMetadata()
141:                                .getClassAnnotationMetadata(super ClassName);
142:                        // If the method is found in the super class and is not inherited, use this one
143:                        if (super MetaData != null) {
144:                            MethodAnnotationMetadata super Method = super MetaData
145:                                    .getMethodAnnotationMetadata(jMethod);
146:                            if (super Method != null
147:                                    && !super Method.isInherited()) {
148:                                return super Method;
149:                            }
150:                            super ClassName = super MetaData.getSuperName();
151:                        } else {
152:                            // break the loop
153:                            super ClassName = JAVA_LANG_OBJECT;
154:                        }
155:                    }
156:
157:                }
158:
159:                return method;
160:            }
161:
162:            /**
163:             * Gets all interfaces used by a class.
164:             * @param sessionBean the metadata to analyze.
165:             * @return the list of interfaces from a given class.
166:             */
167:            public static List<String> getAllInterfacesFromClass(
168:                    final ClassAnnotationMetadata sessionBean) {
169:                // build list
170:                List<String> allInterfaces = new ArrayList<String>();
171:
172:                // Class to analyze
173:                String className = sessionBean.getClassName();
174:
175:                // loop while class is not java.lang.Object
176:                while (!JAVA_LANG_OBJECT.equals(className)) {
177:                    ClassAnnotationMetadata metaData = sessionBean
178:                            .getEjbJarAnnotationMetadata()
179:                            .getClassAnnotationMetadata(className);
180:                    // find metadata, all interfaces found
181:                    if (metaData != null) {
182:                        String[] interfaces = metaData.getInterfaces();
183:                        if (interfaces != null) {
184:                            for (String itf : interfaces) {
185:                                allInterfaces.add(itf);
186:                            }
187:                        }
188:                        className = metaData.getSuperName();
189:                    } else {
190:                        // break the loop
191:                        className = JAVA_LANG_OBJECT;
192:                    }
193:                }
194:                return allInterfaces;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.