Source Code Cross Referenced for InheritanceInterfacesHelper.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: InheritanceInterfacesHelper.java 268 2006-03-24 15:09:48Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package com.bm.ejb3metadata.annotations.helper.bean;
025:
026:        import java.util.ArrayList;
027:        import java.util.List;
028:
029:        import com.bm.ejb3metadata.annotations.exceptions.ResolverException;
030:        import com.bm.ejb3metadata.annotations.impl.JLocal;
031:        import com.bm.ejb3metadata.annotations.impl.JRemote;
032:        import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
033:        import com.bm.ejb3metadata.annotations.metadata.EjbJarAnnotationMetadata;
034:
035:        /**
036:         * Analyze classes and if there are super classes, set all super interfaces to
037:         * the current class.
038:         * 
039:         * @author Florent Benoit
040:         */
041:        public final class InheritanceInterfacesHelper {
042:
043:            /**
044:             * Defines java.lang.Object class.
045:             */
046:            public static final String JAVA_LANG_OBJECT = "java/lang/Object";
047:
048:            /**
049:             * Helper class, no public constructor.
050:             */
051:            private InheritanceInterfacesHelper() {
052:
053:            }
054:
055:            /**
056:             * Found all method meta data of the super class and adds them to the bean's
057:             * class. Delegates to loop method.
058:             * 
059:             * @param classAnnotationMetadata
060:             *            bean' class to analyze.
061:             * @throws ResolverException
062:             *             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:                loop(classAnnotationMetadata, classAnnotationMetadata);
068:
069:            }
070:
071:            /**
072:             * Found all method meta data of the super class and adds them to the bean's
073:             * class.
074:             * 
075:             * @param beanClassAnnotationMetadata
076:             *            class where to report interfaces
077:             * @param visitingClassAnnotationMetadata
078:             *            class to analyze
079:             * @throws ResolverException
080:             *             if the super class in not in the given ejb-jar
081:             */
082:            public static void loop(
083:                    final ClassAnnotationMetadata beanClassAnnotationMetadata,
084:                    final ClassAnnotationMetadata visitingClassAnnotationMetadata)
085:                    throws ResolverException {
086:                String super Class = visitingClassAnnotationMetadata
087:                        .getSuperName();
088:                if (super Class != null) {
089:                    // try to see if it was analyzed (and not java.lang.Object)
090:                    if (!super Class.equals(JAVA_LANG_OBJECT)) {
091:                        EjbJarAnnotationMetadata ejbJarAnnotationMetadata = beanClassAnnotationMetadata
092:                                .getEjbJarAnnotationMetadata();
093:                        ClassAnnotationMetadata super Metadata = ejbJarAnnotationMetadata
094:                                .getClassAnnotationMetadata(super Class);
095:
096:                        if (super Metadata == null) {
097:                            throw new IllegalStateException(
098:                                    "No super class named '"
099:                                            + super Class
100:                                            + "' was analyzed. But it is referenced from '"
101:                                            + visitingClassAnnotationMetadata
102:                                                    .getClassName() + "'.");
103:                        }
104:
105:                        // Add in a new list the existing interfaces
106:                        List<String> newInterfacesLst = new ArrayList<String>();
107:                        String[] currentInterfaces = beanClassAnnotationMetadata
108:                                .getInterfaces();
109:                        if (currentInterfaces != null) {
110:                            for (String itf : currentInterfaces) {
111:                                newInterfacesLst.add(itf);
112:                            }
113:                        }
114:
115:                        // Add the interfaces of the super class only if there aren't
116:                        // yet present
117:                        String[] super Interfaces = super Metadata
118:                                .getInterfaces();
119:                        if (super Interfaces != null) {
120:                            for (String itf : super Interfaces) {
121:                                if (!newInterfacesLst.contains(itf)) {
122:                                    newInterfacesLst.add(itf);
123:                                }
124:                            }
125:                        }
126:
127:                        // Set the updated list.
128:                        beanClassAnnotationMetadata
129:                                .setInterfaces(newInterfacesLst
130:                                        .toArray(new String[newInterfacesLst
131:                                                .size()]));
132:
133:                        // The local and remote interfaces need to be reported from the
134:                        // superclass to the current class.
135:                        // Start with the local interfaces.
136:                        JLocal currentLocalInterfaces = beanClassAnnotationMetadata
137:                                .getLocalInterfaces();
138:                        JLocal super LocalInterfaces = super Metadata
139:                                .getLocalInterfaces();
140:                        if (super LocalInterfaces != null) {
141:                            if (currentLocalInterfaces == null) {
142:                                currentLocalInterfaces = new JLocal();
143:                                beanClassAnnotationMetadata
144:                                        .setLocalInterfaces(currentLocalInterfaces);
145:                            }
146:                            for (String itf : super LocalInterfaces
147:                                    .getInterfaces()) {
148:                                if (!currentLocalInterfaces.getInterfaces()
149:                                        .contains(itf)) {
150:                                    currentLocalInterfaces.addInterface(itf);
151:                                }
152:                            }
153:                        }
154:
155:                        // And then, with the remote interfaces
156:                        JRemote currentRemoteInterfaces = beanClassAnnotationMetadata
157:                                .getRemoteInterfaces();
158:                        JRemote super RemoteInterfaces = super Metadata
159:                                .getRemoteInterfaces();
160:                        if (super RemoteInterfaces != null) {
161:                            if (currentRemoteInterfaces == null) {
162:                                currentRemoteInterfaces = new JRemote();
163:                                beanClassAnnotationMetadata
164:                                        .setRemoteInterfaces(currentRemoteInterfaces);
165:                            }
166:                            for (String itf : super RemoteInterfaces
167:                                    .getInterfaces()) {
168:                                if (!currentRemoteInterfaces.getInterfaces()
169:                                        .contains(itf)) {
170:                                    currentRemoteInterfaces.addInterface(itf);
171:                                }
172:                            }
173:                        }
174:
175:                        // Loop again until java.lang.Object super class is found
176:                        if (!superMetadata.getClassName().equals(
177:                                JAVA_LANG_OBJECT)) {
178:                            loop(beanClassAnnotationMetadata, superMetadata);
179:                        }
180:                    }
181:                }
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.