Source Code Cross Referenced for EjbJarAnnotationMetadata.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) 


001:        package com.bm.ejb3metadata.annotations.metadata;
002:
003:        import java.util.Collection;
004:        import java.util.HashMap;
005:        import java.util.Map;
006:
007:        import javax.ejb.ApplicationException;
008:
009:        import com.bm.ejb3metadata.xml.struct.EJB3;
010:
011:        /**
012:         * This class represents the annotation metadata of all classes of an EjbJar
013:         * file. From this class, we can get metadata of all beans.
014:         * 
015:         * @author Daniel Wiese
016:         */
017:        public class EjbJarAnnotationMetadata {
018:
019:            private final static org.apache.log4j.Logger logger = org.apache.log4j.Logger
020:                    .getLogger(EjbJarAnnotationMetadata.class);
021:
022:            /**
023:             * List of class annotations metadata.
024:             */
025:            private Map<String, ClassAnnotationMetadata> classesAnnotationMetadata = null;
026:
027:            /**
028:             * Map of interface names and the first possible implementation Currently we
029:             * donīt manage different implementations of a session bean TODO check the
030:             * spect: if a Local/Romete interface has 2 different implementation
031:             */
032:            private Map<String, String> interface2implemantation = null;
033:
034:            /**
035:             * Link to the Deployment Descriptor object.
036:             */
037:            private EJB3 ejb3 = null;
038:
039:            /**
040:             * List of application exceptions used on this ejb-jar.
041:             */
042:            private Map<String, ApplicationException> applicationExceptions = null;
043:
044:            /**
045:             * Constructor.
046:             */
047:            public EjbJarAnnotationMetadata() {
048:                classesAnnotationMetadata = new HashMap<String, ClassAnnotationMetadata>();
049:            }
050:
051:            /**
052:             * Merge the items from another
053:             * 
054:             * @param other
055:             */
056:            public void mergeClassAnnotationMetadata(
057:                    EjbJarAnnotationMetadata other) {
058:                classesAnnotationMetadata
059:                        .putAll(other.classesAnnotationMetadata);
060:            }
061:
062:            /**
063:             * Add annotation metadata for a given class.
064:             * 
065:             * @param classAnnotationMetadata
066:             *            annotation metadata of a class.
067:             */
068:            public void addClassAnnotationMetadata(
069:                    final ClassAnnotationMetadata classAnnotationMetadata) {
070:                String key = classAnnotationMetadata.getClassName();
071:                // already exists ?
072:                if (classesAnnotationMetadata.containsKey(key)) {
073:                    String msg = "EjbJarAnnotationMetadata.addClassAnnotationMetadata.alreadyPresent";
074:                    logger.debug(msg);
075:                    // throw new IllegalStateException(msg);
076:                }
077:                classesAnnotationMetadata.put(key, classAnnotationMetadata);
078:            }
079:
080:            /**
081:             * Returns the name of the bean class by passing the rmote/ local interface
082:             * name.
083:             * 
084:             * @return the name of the bean class by passing the rmote/ local interface
085:             *         name.
086:             * @param interfaceName -
087:             *            the name of the local / remote interface
088:             */
089:            public String getBeanImplementationForInterface(String interfaceName) {
090:                return this .interface2implemantation.get(interfaceName);
091:            }
092:
093:            /**
094:             * Returns the name of the bean class by passing the rmote/ local interface
095:             * name.
096:             * 
097:             * @return the name of the bean class by passing the rmote/ local interface
098:             *         name.
099:             * @param interfaceName -
100:             *            the name of the local / remote interface
101:             */
102:            public String getBeanImplementationForInterface(Class interfaceName) {
103:                final String name = interfaceName.getName();
104:                if (interface2implemantation == null) {
105:                    buildInterfaceImplementationMap();
106:                }
107:                return this .interface2implemantation
108:                        .get(name.replace('.', '/'));
109:            }
110:
111:            /**
112:             * Builds a map of Local/Remote interfaces and itīs implementations.
113:             */
114:            private void buildInterfaceImplementationMap() {
115:                interface2implemantation = new HashMap<String, String>();
116:                for (ClassAnnotationMetadata current : this 
117:                        .getClassAnnotationMetadataCollection()) {
118:                    if (current.getLocalInterfaces() != null) {
119:                        for (String interfaze : current.getLocalInterfaces()
120:                                .getInterfaces()) {
121:                            // build no implementation map for anonymus classes and
122:                            // inner classes
123:                            if (current.getClassName().indexOf('$') < 0) {
124:                                this .interface2implemantation.put(interfaze,
125:                                        current.getClassName());
126:                            }
127:                        }
128:                    }
129:                    if (current.getRemoteInterfaces() != null) {
130:                        for (String interfaze : current.getRemoteInterfaces()
131:                                .getInterfaces()) {
132:                            // build no implementation map for anonymus classes and
133:                            // inner classes
134:                            if (current.getClassName().indexOf('$') < 0) {
135:                                this .interface2implemantation.put(interfaze,
136:                                        current.getClassName());
137:                            }
138:                        }
139:                    }
140:                }
141:            }
142:
143:            /**
144:             * Get class annotation metadata.
145:             * 
146:             * @param className
147:             *            key of the map of annotations bean.
148:             * @return Bean annotation metadata of a given name.
149:             */
150:            public ClassAnnotationMetadata getClassAnnotationMetadata(
151:                    final String className) {
152:                return classesAnnotationMetadata.get(className);
153:            }
154:
155:            /**
156:             * Get collections of bean annotation metadata.
157:             * 
158:             * @return collections of bean annotation metadata.
159:             */
160:            public Collection<ClassAnnotationMetadata> getClassAnnotationMetadataCollection() {
161:                return classesAnnotationMetadata.values();
162:            }
163:
164:            /**
165:             * @return the ejb3 deployment descriptor object.
166:             */
167:            public EJB3 getEjb3() {
168:                return ejb3;
169:            }
170:
171:            /**
172:             * Sets the ejb3 deployment descriptor object.
173:             * 
174:             * @param ejb3
175:             *            the ejb3 deployment descriptor object.
176:             */
177:            public void setEjb3(final EJB3 ejb3) {
178:                this .ejb3 = ejb3;
179:            }
180:
181:            /**
182:             * Gets the list of application exceptions defined on this ejb jar metadata.
183:             * 
184:             * @return the list of application exceptions defined on this ejb jar
185:             *         metadata.
186:             */
187:            public Map<String, ApplicationException> getApplicationExceptions() {
188:                if (applicationExceptions != null) {
189:                    return applicationExceptions;
190:                }
191:
192:                // compute it
193:                applicationExceptions = new HashMap<String, ApplicationException>();
194:
195:                // For each class, look if it is an application exception
196:                for (ClassAnnotationMetadata classMetadata : getClassAnnotationMetadataCollection()) {
197:                    ApplicationException appException = classMetadata
198:                            .getApplicationException();
199:                    // found it then add it in the map.
200:                    if (appException != null) {
201:                        applicationExceptions.put(classMetadata.getClassName()
202:                                .replaceAll("/", "."), appException);
203:                    }
204:                }
205:                return applicationExceptions;
206:            }
207:
208:            /**
209:             * Returns the interface2implemantation.
210:             * 
211:             * @return Returns the interface2implemantation.
212:             */
213:            public Map<String, String> getInterface2implemantation() {
214:                if (interface2implemantation == null) {
215:                    buildInterfaceImplementationMap();
216:                }
217:                return interface2implemantation;
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.