Source Code Cross Referenced for AbstractEJB2xVerifier.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » verifier » strategy » 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 » EJB Server JBoss 4.2.1 » server » org.jboss.verifier.strategy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.verifier.strategy;
023:
024:        // $Id: AbstractEJB2xVerifier.java 57209 2006-09-26 12:21:57Z dimitris@jboss.org $
025:
026:        import org.jboss.metadata.EntityMetaData;
027:        import org.jboss.metadata.QueryMetaData;
028:        import org.jboss.util.Classes;
029:
030:        import java.lang.reflect.Method;
031:        import java.util.Iterator;
032:        import java.util.LinkedList;
033:        import java.util.List;
034:
035:        /**
036:         * Abstract EJB 2.x bean verifier.
037:         *
038:         * @author Thomas.Diesler@jboss.org
039:         * @since  08-Feb-2005
040:         */
041:
042:        public abstract class AbstractEJB2xVerifier extends AbstractVerifier {
043:            protected EJBVerifier11 cmp1XVerifier;
044:
045:            // The classes for an EJB
046:            protected Class bean;
047:            protected Class home;
048:            protected Class remote;
049:            protected Class localHome;
050:            protected Class local;
051:            protected Class serviceEndpointInterface;
052:
053:            /*
054:             * Constructor
055:             */
056:            public AbstractEJB2xVerifier(VerificationContext context) {
057:                super (context);
058:                cmp1XVerifier = new EJBVerifier11(context);
059:            }
060:
061:            /**
062:             * Check whether the given method is a create(...) method
063:             */
064:            public boolean isCreateMethod(Method m) {
065:                return m.getName().startsWith(CREATE_METHOD);
066:            }
067:
068:            public boolean isEjbCreateMethod(Method m) {
069:                return m.getName().startsWith(EJB_CREATE_METHOD);
070:            }
071:
072:            public boolean isEjbRemoveMethod(Method m) {
073:                return m.getName().startsWith(EJB_REMOVE_METHOD);
074:            }
075:
076:            public boolean isEjbSelectMethod(Method m) {
077:                return m.getName().startsWith(EJB_SELECT_METHOD);
078:            }
079:
080:            public boolean isEjbHomeMethod(Method m) {
081:                return m.getName().startsWith(EJB_HOME_METHOD);
082:            }
083:
084:            /** Finds java.rmi.Remote interface from the class
085:             */
086:            public boolean hasRemoteInterface(Class c) {
087:                return isAssignableFrom("java.rmi.Remote", c);
088:            }
089:
090:            /**
091:             * Return all ejbSelect methods
092:             */
093:            public Iterator getEjbSelectMethods(Class c) {
094:                List selects = new LinkedList();
095:                Method[] method = c.getMethods();
096:
097:                for (int i = 0; i < method.length; ++i) {
098:                    if (isEjbSelectMethod(method[i])) {
099:                        selects.add(method[i]);
100:                    }
101:                }
102:
103:                return selects.iterator();
104:            }
105:
106:            /**
107:             * Searches for an instance of an ejbRemove method from the class
108:             */
109:            public boolean hasEJBRemoveMethod(Class c) {
110:                Method[] method = c.getMethods();
111:                for (int i = 0; i < method.length; ++i) {
112:                    if (isEjbRemoveMethod(method[i]))
113:                        return true;
114:                }
115:
116:                return false;
117:            }
118:
119:            /**
120:             * Returns the ejbRemove(...) methods of a bean
121:             */
122:            public Iterator getEJBRemoveMethods(Class c) {
123:                List ejbRemoves = new LinkedList();
124:                Method[] method = c.getMethods();
125:
126:                for (int i = 0; i < method.length; ++i) {
127:                    if (isEjbRemoveMethod(method[i]))
128:                        ejbRemoves.add(method[i]);
129:                }
130:
131:                return ejbRemoves.iterator();
132:            }
133:
134:            /**
135:             * Home methods are any method on the home interface which is
136:             * neither a create or find method.
137:             */
138:            public Iterator getHomeMethods(Class c) {
139:                List homes = new LinkedList();
140:                Method[] method = c.getMethods();
141:
142:                for (int i = 0; i < method.length; ++i) {
143:                    if (!isCreateMethod(method[i])
144:                            && !isFinderMethod(method[i]))
145:                        homes.add(method[i]);
146:                }
147:
148:                return homes.iterator();
149:            }
150:
151:            public Iterator getEjbHomeMethods(Class c) {
152:                List homes = new LinkedList();
153:                Method[] method = c.getMethods();
154:
155:                for (int i = 0; i < method.length; ++i) {
156:                    if (isEjbHomeMethod(method[i]))
157:                        homes.add(method[i]);
158:                }
159:
160:                return homes.iterator();
161:            }
162:
163:            /**
164:             * Check whether there is a matching &lt;query&gt; Element defined
165:             * for the Method m
166:             *
167:             * @param m Method to check, should be either a Finder or a Select
168:             * @param e EntityMetaData
169:             *
170:             * @return <code>true</code> if a matching &lt;query&gt; Element
171:             *         was located.
172:             */
173:            protected boolean hasMatchingQuery(Method m, EntityMetaData e) {
174:                boolean result = false;
175:
176:                Iterator qIt = e.getQueries();
177:                while (qIt.hasNext()) {
178:                    QueryMetaData qmd = (QueryMetaData) qIt.next();
179:
180:                    // matching names
181:                    if (!qmd.getMethodName().equals(m.getName())) {
182:                        continue;
183:                    }
184:
185:                    Class[] methodParameter = m.getParameterTypes();
186:                    Class[] queryParameter = null;
187:
188:                    try {
189:                        queryParameter = Classes.convertToJavaClasses(qmd
190:                                .getMethodParams(), classloader);
191:                    } catch (ClassNotFoundException cnfe) {
192:                        // FIXME: this should be handled differently, especially
193:                        //        there shouldn't be a DeploymentException being
194:                        //        thrown ...
195:                        continue;
196:                    }
197:
198:                    // number of parameters has to match
199:                    if (methodParameter.length != queryParameter.length) {
200:                        continue;
201:                    }
202:
203:                    // walk the parameter list and compare for equality
204:                    boolean parametersMatch = true;
205:                    for (int i = 0; i < methodParameter.length; i++) {
206:                        if (!methodParameter[i].equals(queryParameter[i])) {
207:                            parametersMatch = false;
208:                            break;
209:                        }
210:                    }
211:
212:                    if (parametersMatch) {
213:                        result = true;
214:                        break;
215:                    }
216:                }
217:
218:                return result;
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.