Source Code Cross Referenced for BeanVerifier.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » verifier » 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 
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;
023:
024:        /*
025:         * Class org.jboss.verifier.BeanVerifier
026:         * Copyright (C) 2000  Juha Lindfors
027:         *
028:         * This library is free software; you can redistribute it and/or
029:         * modify it under the terms of the GNU Lesser General Public
030:         * License as published by the Free Software Foundation; either
031:         * version 2 of the License, or (at your option) any later version
032:         * 
033:         * This library is distributed in the hope that it will be useful,
034:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
035:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
036:         * Lesser General Public License for more details.
037:         * 
038:         * You should have received a copy of the GNU Lesser General Public
039:         * License along with this library; if not, write to the Free Software
040:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
041:         *
042:         * This package and its source code is available at www.jboss.org
043:         * $Id: BeanVerifier.java 57209 2006-09-26 12:21:57Z dimitris@jboss.org $
044:         */
045:
046:        // standard imports
047:        import org.jboss.logging.Logger;
048:        import org.jboss.metadata.ApplicationMetaData;
049:        import org.jboss.metadata.BeanMetaData;
050:        import org.jboss.metadata.EntityMetaData;
051:        import org.jboss.metadata.MessageDrivenMetaData;
052:        import org.jboss.metadata.SessionMetaData;
053:        import org.jboss.verifier.event.VerificationEvent;
054:        import org.jboss.verifier.event.VerificationEventGeneratorSupport;
055:        import org.jboss.verifier.event.VerificationListener;
056:        import org.jboss.verifier.strategy.EJBVerifier11;
057:        import org.jboss.verifier.strategy.EJBVerifier20;
058:        import org.jboss.verifier.strategy.EJBVerifier21;
059:        import org.jboss.verifier.strategy.VerificationContext;
060:        import org.jboss.verifier.strategy.VerificationStrategy;
061:
062:        import java.net.URL;
063:        import java.util.Iterator;
064:
065:        /**
066:         * Attempts to verify the spec compliance of the beans in a given
067:         * EJB-JAR file. Works against EJB spec 1.1 and 2.0. Built for use in
068:         * JBoss project.
069:         *
070:         * @see     org.jboss.verifier.strategy.VerificationStrategy
071:         * @see     org.jboss.verifier.factory.VerificationEventFactory
072:         *
073:         * @author  <a href="mailto:juha.lindfors@jboss.org">Juha Lindfors</a>
074:         * @author  Thomas.Diesler@jboss.org
075:         * @version $Revision: 57209 $
076:         * @since   JDK 1.3
077:         */
078:        public class BeanVerifier implements  VerificationContext {
079:            private ApplicationMetaData ejbMetaData;
080:            private ClassLoader ejbClassLoader;
081:            private URL ejbURL;
082:
083:            private VerificationStrategy verifier;
084:
085:            private boolean success = true;
086:
087:            private static Logger log = Logger.getLogger(BeanVerifier.class);
088:
089:            /*
090:             * Support class which handles the event notification logic.
091:             */
092:            private VerificationEventGeneratorSupport events = new VerificationEventGeneratorSupport();
093:
094:            /**
095:             * Default constructor.
096:             */
097:            public BeanVerifier() {
098:            }
099:
100:            /**
101:             * Checks the Enterprise Java Beans found in this Jar for EJB spec
102:             * compliance (EJB Spec. 1.1). Ensures that the given interfaces
103:             * and implementation classes implement required methods and follow
104:             * the contract given in the spec.
105:             *
106:             * @param   url     URL to the bean jar file
107:             */
108:            public void verify(URL url, ApplicationMetaData metaData) {
109:                verify(url, metaData, null);
110:            }
111:
112:            /**
113:             * Checks the Enterprise Java Beans found in this Jar for EJB spec
114:             * compliance (EJB Spec. 1.1). Ensures that the given interfaces
115:             * and implementation classes implement required methods and follow
116:             * the contract given in the spec.
117:             *
118:             * @param   url     URL to the bean jar file
119:             * @param   cl      The ClassLoader to use
120:             */
121:            public void verify(URL url, ApplicationMetaData metaData,
122:                    ClassLoader cl) {
123:                ejbURL = url;
124:                ejbMetaData = metaData;
125:                ejbClassLoader = cl;
126:
127:                if (metaData.isEJB1x()) {
128:                    setVerifier(VERSION_1_1);
129:                } else if (metaData.isEJB21()) {
130:                    setVerifier(VERSION_2_1);
131:                } else {
132:                    setVerifier(VERSION_2_0);
133:                }
134:
135:                Iterator beans = ejbMetaData.getEnterpriseBeans();
136:
137:                while (beans.hasNext()) {
138:                    BeanMetaData bean = (BeanMetaData) beans.next();
139:
140:                    if (bean.isEntity()) {
141:                        EntityMetaData entityBean = (EntityMetaData) bean;
142:                        if (metaData.isEJB2x() && entityBean.isCMP1x()) {
143:                            // Hook for verifying CMP 1.x Beans in a 2.x JAR: store
144:                            // current state and restore this state after verification
145:                            // of the EJB completes.
146:                            boolean storedSuccess = success;
147:
148:                            verifier.checkEntity(entityBean);
149:
150:                            if (success != storedSuccess) {
151:                                log
152:                                        .warn("The CMP 1.x EJB '"
153:                                                + entityBean.getEjbName()
154:                                                + "' generated some verification warnings. The Deployer "
155:                                                + "will ignore these warnings but you should check "
156:                                                + "your EJB to be on the safe side of things.");
157:                            }
158:
159:                            success = storedSuccess;
160:                        } else {
161:                            verifier.checkEntity(entityBean);
162:                        }
163:                    } else if (bean.isSession()) {
164:                        verifier.checkSession((SessionMetaData) bean);
165:                    } else {
166:                        verifier.checkMessageBean((MessageDrivenMetaData) bean);
167:                    }
168:                }
169:            }
170:
171:            /**
172:             * Check if the Verifier was successful
173:             *
174:             * @return <code>true</code> if all Beans have been verified,
175:             *   <code>false</code> otherwise.
176:             */
177:            public boolean getSuccess() {
178:                return success;
179:            }
180:
181:            /*
182:             *************************************************************************
183:             *
184:             *   IMPLEMENTS VERIFICATION EVENT GENERATOR INTERFACE
185:             *
186:             *************************************************************************
187:             */
188:            public void addVerificationListener(VerificationListener listener) {
189:                events.addVerificationListener(listener);
190:            }
191:
192:            public void removeVerificationListener(VerificationListener listener) {
193:                events.removeVerificationListener(listener);
194:            }
195:
196:            public void fireBeanChecked(VerificationEvent event) {
197:                events.fireBeanChecked(event);
198:            }
199:
200:            public void fireSpecViolation(VerificationEvent event) {
201:                // A Spec Violation has been found. Mark as unsuccessful.
202:                success = false;
203:                events.fireSpecViolation(event);
204:            }
205:
206:            /*
207:             **************************************************************************
208:             *
209:             *   IMPLEMENTS VERIFICATION CONTEXT INTERFACE
210:             *
211:             **************************************************************************
212:             */
213:            public ApplicationMetaData getApplicationMetaData() {
214:                return ejbMetaData;
215:            }
216:
217:            public URL getJarLocation() {
218:                return ejbURL;
219:            }
220:
221:            public ClassLoader getClassLoader() {
222:                return ejbClassLoader;
223:            }
224:
225:            public String getEJBVersion() {
226:                return VERSION_1_1;
227:
228:                // [TODO] fix this to return a correct version
229:            }
230:
231:            /*
232:             * Will set the correct strategy implementation according to the supplied
233:             * version information. Might widen the scope to public, but protected
234:             * will do for now.
235:             */
236:            protected void setVerifier(String version) {
237:                if (VERSION_1_1.equals(version)) {
238:                    verifier = new EJBVerifier11(this );
239:                } else if (VERSION_2_0.equals(version)) {
240:                    verifier = new EJBVerifier20(this );
241:                } else if (VERSION_2_1.equals(version)) {
242:                    verifier = new EJBVerifier21(this );
243:                } else {
244:                    throw new IllegalArgumentException(UNRECOGNIZED_VERSION
245:                            + ": " + version);
246:                }
247:            }
248:
249:            /*
250:             * accessor for reference to the verification strategy in use
251:             */
252:            protected VerificationStrategy getVerifier() {
253:                return verifier;
254:            }
255:
256:            /*
257:             * String constants
258:             */
259:            private final static String UNRECOGNIZED_VERSION = "Unknown version string";
260:        }
261:
262:        /*
263:         vim:ts=3:sw=3:et
264:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.