Source Code Cross Referenced for DeploymentDescEjb2.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » deployment » api » 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 » JOnAS 4.8.6 » org.objectweb.jonas_ejb.deployment.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@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: DeploymentDescEjb2.java 5450 2004-09-17 09:44:19Z joaninh $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ejb.deployment.api;
025:
026:        import java.util.ArrayList;
027:        import java.util.HashMap;
028:        import java.util.Iterator;
029:        import org.objectweb.jonas_ejb.deployment.xml.AssemblyDescriptor;
030:        import org.objectweb.jonas_ejb.deployment.xml.EjbJar;
031:        import org.objectweb.jonas_ejb.deployment.xml.EjbRelation;
032:        import org.objectweb.jonas_ejb.deployment.xml.Entity;
033:        import org.objectweb.jonas_ejb.deployment.xml.JonasEjbJar;
034:        import org.objectweb.jonas_ejb.deployment.xml.JonasEjbRelation;
035:        import org.objectweb.jonas_ejb.deployment.xml.JonasEntity;
036:        import org.objectweb.jonas_ejb.deployment.xml.JonasMessageDriven;
037:        import org.objectweb.jonas_ejb.deployment.xml.MessageDriven;
038:        import org.objectweb.jonas_ejb.lib.RdbMappingBuilder;
039:        import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
040:        import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
041:        import org.objectweb.jorm.metainfo.api.Manager;
042:        import org.objectweb.util.monolog.api.Logger;
043:        import org.objectweb.util.monolog.api.BasicLevel;
044:
045:        /**
046:         * Class to hold meta-information related to the deployment of an ejb-jar
047:         * This subclass is for specification EJB 2.x, i.e. CMP2 persistance and MDB.
048:         * It is also responsible for loading the Jorm Meta Information.
049:         * @author S.Chassande-Barrioz : Initial developer
050:         * @author Christophe Ney [cney@batisseurs.com]
051:         * @author Philippe Durieux (new Jorm mapping)
052:         */
053:        public class DeploymentDescEjb2 extends DeploymentDesc {
054:
055:            /**
056:             * The JORM meta-information manager
057:             */
058:            private RdbMappingBuilder rdbMapping = null;
059:
060:            /**
061:             * List of relations (EjbRelationDesc) defined in this Descriptor
062:             */
063:            private ArrayList ejbRelations = new ArrayList();
064:
065:            /**
066:             * Build the Meta-Information from the XML data binding trees
067:             * containing the EJB and JOnAS deployment descriptors.
068:             * @param classLoader The Class Loader to be used
069:             * @param ejbJar The EjbJar information, from standard deployment descriptor.
070:             * @param jonasEjbJar The JonasEjbJar information, from JOnAS specific deployment descriptor.
071:             * @param l The logger to be used for tracing
072:             * @param FileName deployment desc's jar or directory name
073:             * @throws DeploymentDescException Error when building the Deployment Descriptor
074:             */
075:            public DeploymentDescEjb2(ClassLoader classLoader, EjbJar ejbJar,
076:                    JonasEjbJar jonasEjbJar, Logger l, String fileName)
077:                    throws DeploymentDescException {
078:
079:                // Session and Entity bean descriptors are built here.
080:                // This part is common with EJB1.1 spec (no CMP2, no MDB)
081:                super (classLoader, ejbJar, jonasEjbJar, l, fileName);
082:
083:                // HashMap of jonas-message-driven
084:                HashMap jonasMessageDriven = new HashMap();
085:                for (Iterator i = jonasEjbJar.getJonasMessageDrivenList()
086:                        .iterator(); i.hasNext();) {
087:                    JonasMessageDriven jMd = (JonasMessageDriven) i.next();
088:                    jonasMessageDriven.put(jMd.getEjbName(), jMd);
089:                }
090:
091:                // message-driven beans
092:                for (Iterator i = ejbJar.getEnterpriseBeans()
093:                        .getMessageDrivenList().iterator(); i.hasNext();) {
094:                    BeanDesc bd = null;
095:                    MessageDriven md = (MessageDriven) i.next();
096:                    /*
097:                     * The Standard DTD allows a message-driven-bean without ejb-name
098:                     * Problem to associate infos to this bean (trans-attribute, jonas-specific infos)
099:                     * So the ejb-name must be specify and we check this
100:                     */
101:                    if (md.getEjbName() == null) {
102:                        throw new DeploymentDescException(
103:                                "ejb-name missing for a message driven bean");
104:                    }
105:                    // find corresponding jonas message-driven
106:                    JonasMessageDriven jMd = (JonasMessageDriven) jonasMessageDriven
107:                            .get(md.getEjbName());
108:                    if (jMd == null) {
109:                        throw new DeploymentDescException(
110:                                "jonas-message-driven-bean missing for bean "
111:                                        + md.getEjbName());
112:                    }
113:
114:                    bd = new MessageDrivenDesc(classLoader, md, asd, jMd,
115:                            jonasEjbJar.getJonasMessageDestinationList(),
116:                            fileName);
117:
118:                    bd.setDeploymentDesc(this );
119:                    bd.check();
120:                    beanDesc.put(bd.getEjbName(), bd);
121:                }
122:
123:                // Relations on Entity beans CMP2
124:                if (ejbJar.getRelationships() != null) {
125:
126:                    // ArrayList of standard-relation names (Strings)
127:                    ArrayList stdRelations = new ArrayList();
128:
129:                    // HashMap of jonas-relation
130:                    HashMap jonasRelations = new HashMap();
131:                    for (Iterator i = jonasEjbJar.getJonasEjbRelationList()
132:                            .iterator(); i.hasNext();) {
133:                        JonasEjbRelation jer = (JonasEjbRelation) i.next();
134:                        String jerName = jer.getEjbRelationName();
135:                        //if (!stdRelations.contains(jerName)) {
136:                        //    throw new DeploymentDescException("ejb-relation missing in ejb-jar.xml for the relation " + jerName);
137:                        //}
138:                        jonasRelations.put(jerName, jer);
139:                    }
140:
141:                    // ejb-relation
142:                    for (Iterator i = ejbJar.getRelationships()
143:                            .getEjbRelationList().iterator(); i.hasNext();) {
144:                        EjbRelation er = (EjbRelation) i.next();
145:
146:                        // build the descriptors for the relation.
147:                        EjbRelationDesc erd = new EjbRelationDesc(er, logger);
148:                        ejbRelations.add(erd);
149:
150:                        // Keep a list of relation names.
151:                        stdRelations.add(erd.getName());
152:
153:                        // find corresponding jonas relation (may not exist)
154:                        JonasEjbRelation jer = (JonasEjbRelation) jonasRelations
155:                                .get(erd.getName());
156:                        erd.setJonasInfo(jer);
157:
158:                        // makes the links between entity beans and relationship roles
159:                        EjbRelationshipRoleDesc rsd1 = erd
160:                                .getRelationshipRole1();
161:                        EjbRelationshipRoleDesc rsd2 = erd
162:                                .getRelationshipRole2();
163:                        EntityCmp2Desc ed1 = (EntityCmp2Desc) beanDesc.get(rsd1
164:                                .getSourceBeanName());
165:                        EntityCmp2Desc ed2 = (EntityCmp2Desc) beanDesc.get(rsd2
166:                                .getSourceBeanName());
167:                        // Check the sources beans names are correct
168:                        if ((ed1 == null) || (ed2 == null)) {
169:                            throw new DeploymentDescException(
170:                                    "Invalid ejb-name for a relation-ship-role-source for the relation '"
171:                                            + erd.getName() + "' ('"
172:                                            + rsd1.getSourceBeanName()
173:                                            + "' or '"
174:                                            + rsd2.getSourceBeanName()
175:                                            + "' invalid)");
176:                        }
177:                        // Check if the source beans have local interfaces
178:                        if ((ed1.getLocalHomeClass() == null)
179:                                || (ed1.getLocalClass() == null)) {
180:                            throw new DeploymentDescException(
181:                                    "The entity bean '"
182:                                            + ed1.getEjbName()
183:                                            + "' involved in the relationship '"
184:                                            + erd.getName()
185:                                            + "' must have local interfaces");
186:                        }
187:                        if ((ed2.getLocalHomeClass() == null)
188:                                || (ed2.getLocalClass() == null)) {
189:                            throw new DeploymentDescException(
190:                                    "The entity bean '"
191:                                            + ed2.getEjbName()
192:                                            + "' involved in the relationship '"
193:                                            + erd.getName()
194:                                            + "' must have local interfaces");
195:                        }
196:                        ed1.addEjbRelationshipRoleDesc(rsd1);
197:                        ed2.addEjbRelationshipRoleDesc(rsd2);
198:                        rsd1.setTargetBean(ed2);
199:                        rsd1.setSourceBean(ed1);
200:                        rsd2.setTargetBean(ed1);
201:                        rsd2.setSourceBean(ed2);
202:
203:                        // Fill the mapping information with the values defined in jonas DD
204:                        erd.fillMappingInfo();
205:
206:                        // Fill the mapping information for the relation with default values
207:                        // if some mapping information is missing
208:                        erd.fillMappingInfoWithDefault();
209:                    }
210:
211:                    for (Iterator i = jonasEjbJar.getJonasEjbRelationList()
212:                            .iterator(); i.hasNext();) {
213:                        JonasEjbRelation jer = (JonasEjbRelation) i.next();
214:                        String jerName = jer.getEjbRelationName();
215:                        if (!stdRelations.contains(jerName)) {
216:                            throw new DeploymentDescException(
217:                                    "ejb-relation missing in ejb-jar.xml for the relation "
218:                                            + jerName);
219:                        }
220:                    }
221:                }
222:
223:                // Trace
224:                if (logger.getCurrentIntLevel() == BasicLevel.DEBUG) {
225:                    logger.log(BasicLevel.DEBUG, "DEPLOYMENT DESCRIPTOR = \n("
226:                            + this .toString() + "\n)");
227:                }
228:            }
229:
230:            /**
231:             * In case of beans with old CMP1 persistance, we need to instanciate the old class,
232:             * as if we were in an old Deployment Descriptor.
233:             * Default is CMP2.x for entity beans with a EJB2.0 DD.
234:             * @param classLoader The ClassLoader to be used
235:             * @param ent Entity MetaInformation from XML files
236:             * @param asd AssemblyDescriptor MetaInformation from XML files
237:             * @param jEnt JonasEntity MetaInformation from XML files
238:             * @return The Entity Bean Descriptor, for the good CMP version.
239:             * @throws DeploymentDescException Cannot build Entity Descriptor
240:             */
241:            protected BeanDesc newEntityBeanDesc(ClassLoader classLoader,
242:                    Entity ent, AssemblyDescriptor asd, JonasEntity jEnt,
243:                    JLinkedList jMDRList) throws DeploymentDescException {
244:
245:                if (ent.getCmpVersion() == null
246:                        || ent.getCmpVersion().equals("2.x")) {
247:                    return new EntityJdbcCmp2Desc(classLoader, ent, asd, jEnt,
248:                            this , jMDRList, fileName);
249:                } else {
250:                    return new EntityJdbcCmp1Desc(classLoader, ent, asd, jEnt,
251:                            jMDRList, fileName);
252:                }
253:            }
254:
255:            /**
256:             * get the JORM Manager
257:             * At first call, loads all the meta information for entity beans CMP2
258:             * @return The Jorm Manager
259:             * @throws DeploymentDescException Cannot build Jorm Meta Information
260:             */
261:            public Manager getJormManager() throws DeploymentDescException {
262:                if (rdbMapping == null) {
263:                    rdbMapping = new RdbMappingBuilder(this , logger);
264:                }
265:                return rdbMapping.getJormMIManager();
266:            }
267:
268:            /**
269:             * Get iterator of meta-info for all defined relations
270:             * @return an iterator of EjbRelationDesc
271:             */
272:            public Iterator getEjbRelationDescIterator() {
273:                return ejbRelations.iterator();
274:            }
275:
276:            /**
277:             * String representation of the object for test purpose
278:             * @return String representation of this object
279:             */
280:            public String toString() {
281:                StringBuffer ret = new StringBuffer();
282:                ret.append(super .toString());
283:                for (Iterator i = getEjbRelationDescIterator(); i.hasNext();) {
284:                    ret.append("\nejbRelationDesc[]=" + i.next());
285:                }
286:                return ret.toString();
287:            }
288:
289:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.