Source Code Cross Referenced for EjbJar.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_lib » genbase » archive » 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_lib.genbase.archive 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS : Java(TM) OpenSource 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: EjbJar.java 7057 2005-07-18 23:53:31Z mwringe $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_lib.genbase.archive;
025:
026:        import java.io.File;
027:        import java.io.IOException;
028:        import java.io.InputStream;
029:        import java.net.URL;
030:        import java.util.Hashtable;
031:        import java.util.List;
032:        import java.util.Map;
033:        import java.util.Vector;
034:
035:        import javax.xml.parsers.ParserConfigurationException;
036:
037:        import org.w3c.dom.Document;
038:        import org.xml.sax.SAXException;
039:
040:        import org.objectweb.jonas_ejb.deployment.api.BeanDesc;
041:        import org.objectweb.jonas_ejb.deployment.api.DeploymentDesc;
042:        import org.objectweb.jonas_ejb.deployment.lib.EjbDeploymentDescManager;
043:
044:        import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
045:        import org.objectweb.jonas_lib.genbase.GenBaseException;
046:        import org.objectweb.jonas_lib.genbase.utils.XMLUtils;
047:        import org.objectweb.jonas_lib.loader.EjbJarClassLoader;
048:
049:        import org.objectweb.jonas_ws.deployment.api.WSDeploymentDesc;
050:        import org.objectweb.jonas_ws.deployment.lib.WSDeploymentDescManager;
051:
052:        import org.objectweb.util.monolog.api.BasicLevel;
053:
054:        /**
055:         * EjbJar represents an EjbJar J2EE Archive.
056:         *
057:         * @author Guillaume Sauthier
058:         */
059:        public class EjbJar extends J2EEArchive implements  WsEndpoint {
060:
061:            /** Application containing the ejbjar */
062:            private Application app;
063:
064:            /** WebServices deployment descriptor */
065:            private WSDeploymentDesc wsDD = null;
066:
067:            /** EjbJar deployment descriptor */
068:            private DeploymentDesc ejbDD = null;
069:
070:            /** inner EJBs List */
071:            private List ejbs;
072:
073:            /** descriptors list */
074:            private Map descriptors;
075:
076:            /** jonas-ejb-jar document */
077:            private Document jEjbJar;
078:
079:            /** jonas-webservices document */
080:            private Document jWebservices = null;
081:
082:            /**
083:             * Create a new EjbJar not contained in Application
084:             *
085:             * @param archive
086:             *            the archive file
087:             *
088:             * @throws GenBaseException
089:             *             When init fails
090:             */
091:            public EjbJar(Archive archive) throws GenBaseException {
092:                super (archive);
093:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
094:                    getLogger().log(BasicLevel.DEBUG,
095:                            "Wrapping '" + archive.getName() + "' in EjbJar");
096:                }
097:                init();
098:            }
099:
100:            /**
101:             * Create a new EjbJar contained in Application
102:             *
103:             * @param archive
104:             *            the archive file
105:             * @param app
106:             *            container application
107:             *
108:             * @throws GenBaseException
109:             *             When init fails
110:             */
111:            public EjbJar(Archive archive, Application app)
112:                    throws GenBaseException {
113:                super (archive);
114:                setApplication(app);
115:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
116:                    getLogger().log(BasicLevel.DEBUG,
117:                            "Wrapping '" + archive.getName() + "' in EjbJar");
118:                }
119:                init();
120:            }
121:
122:            /**
123:             * Initialize the EjbJar module.
124:             *
125:             * @throws GenBaseException
126:             *             When ejb classlaoder cannot be created or when Descriptor
127:             *             cannot be loaded.
128:             */
129:            private void init() throws GenBaseException {
130:                loadDescriptors();
131:            }
132:
133:            /**
134:             * Initialize the Archive.
135:             * @throws GenBaseException When initialization fails.
136:             */
137:            public void initialize() throws GenBaseException {
138:
139:                try {
140:                    if (app == null) {
141:                        // simple ejb case
142:                        setModuleClassloader(new EjbJarClassLoader(
143:                                new URL[] { getArchive().getRootFile().toURL() },
144:                                Thread.currentThread().getContextClassLoader()));
145:                    } else {
146:                        // embedded ejb case
147:                        setModuleClassloader(app.getEJBClassLoader());
148:                    }
149:                } catch (IOException ioe) {
150:                    String err = getI18n().getMessage("EjbJar.init.loader",
151:                            getArchive().getRootFile());
152:                    throw new GenBaseException(err, ioe);
153:                }
154:
155:                try {
156:                    ejbDD = EjbDeploymentDescManager.getDeploymentDesc(
157:                            getRootFile().getAbsolutePath(),
158:                            getModuleClassloader());
159:                } catch (DeploymentDescException dde) {
160:                    throw new GenBaseException(dde);
161:                }
162:
163:                try {
164:                    wsDD = WSDeploymentDescManager.getDeploymentDesc(
165:                            getRootFile().getAbsolutePath(),
166:                            getModuleClassloader());
167:                } catch (DeploymentDescException dde) {
168:                    throw new GenBaseException(dde);
169:                }
170:
171:                // create inner EJBs
172:                ejbs = new Vector();
173:
174:                BeanDesc[] bd = ejbDD.getBeanDesc();
175:
176:                for (int i = 0; i < bd.length; i++) {
177:                    ejbs.add(new Ejb(bd[i], XMLUtils.getBeanElement(jEjbJar
178:                            .getDocumentElement(), bd[i].getEjbName())));
179:                }
180:
181:            }
182:
183:            /**
184:             * Load Deployment Descriptor of an EjbJar.
185:             *
186:             * @throws GenBaseException
187:             *             When parsing fails
188:             */
189:            private void loadDescriptors() throws GenBaseException {
190:                try {
191:
192:                    jEjbJar = XMLUtils.newDocument(getJonasEjbJarInputStream(),
193:                            "META-INF/jonas-ejb-jar.xml", isDTDsAllowed());
194:
195:                    InputStream isJws = getJonasWebservicesInputStream();
196:                    if (isJws != null) {
197:                        jWebservices = XMLUtils.newDocument(isJws,
198:                                "META-INF/jonas-webservices.xml",
199:                                isDTDsAllowed());
200:                    }
201:
202:                } catch (SAXException saxe) {
203:                    String err = getI18n().getMessage(
204:                            "EjbJar.loadDescriptors.parseError");
205:                    throw new GenBaseException(err, saxe);
206:                } catch (ParserConfigurationException pce) {
207:                    String err = getI18n().getMessage(
208:                            "EjbJar.loadDescriptors.prepare");
209:                    throw new GenBaseException(err, pce);
210:                } catch (IOException ioe) {
211:                    String err = getI18n().getMessage(
212:                            "EjbJar.loadDescriptors.parseError");
213:                    throw new GenBaseException(err, ioe);
214:                }
215:
216:                descriptors = new Hashtable();
217:                descriptors.put("META-INF/jonas-ejb-jar.xml", jEjbJar);
218:            }
219:
220:            /**
221:             * Returns the List of Ejb contained in this EjbJar.
222:             *
223:             * @return the List of Ejb contained in this EjbJar.
224:             */
225:            public List getEjbs() {
226:                return ejbs;
227:            }
228:
229:            /**
230:             * Returns the list of webservice-description elements contained by a
231:             * module.
232:             *
233:             * @return the list of webservice-description elements contained by a
234:             *         module.
235:             */
236:            public List getServiceDescs() {
237:                if (wsDD != null) {
238:                    return wsDD.getServiceDescs();
239:                } else {
240:                    return new Vector();
241:                }
242:            }
243:
244:            /**
245:             * Add *.class from directory in the archive.
246:             *
247:             * @param classes
248:             *            directory containing classes files.
249:             */
250:            public void addClasses(File classes) {
251:                addDirectory(classes);
252:            }
253:
254:            /**
255:             * @return Returns the desired war filename (jonas-webservices/war)
256:             */
257:            public String getWarName() {
258:                if (wsDD != null) {
259:                    return wsDD.getWarFile();
260:                } else {
261:                    return null;
262:                }
263:            }
264:
265:            /**
266:             * @return Returns the desired context-root (jonas-webservices/context-root)
267:             */
268:            public String getContextRoot() {
269:                // compute context root name from ejbjar name
270:                String archiveName = this .getArchive().getName();
271:                String root = null;
272:                if (archiveName.toLowerCase().endsWith(".jar")) {
273:                    root = archiveName.toLowerCase().substring(0,
274:                            archiveName.length() - ".jar".length());
275:                } else {
276:                    root = archiveName;
277:                }
278:                if (wsDD != null) {
279:                    String croot = wsDD.getContextRoot();
280:                    if (croot != null) {
281:                        root = croot;
282:                    }
283:                }
284:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
285:                    getLogger().log(BasicLevel.DEBUG,
286:                            "Computed context root : " + root);
287:                }
288:                return root;
289:            }
290:
291:            /**
292:             * Set the container application of this EjbJar
293:             *
294:             * @param app
295:             *            container application
296:             */
297:            public void setApplication(Application app) {
298:                this .app = app;
299:            }
300:
301:            /**
302:             * Return the container application of this EjbJar
303:             *
304:             * @return the container application of this EjbJar
305:             */
306:            public Application getApplication() {
307:                return app;
308:            }
309:
310:            /**
311:             * Returns a Map of name to Document for each modified Descriptor of the
312:             * archive.
313:             *
314:             * @return a Map of name to Document
315:             */
316:            public Map getDescriptors() {
317:                return descriptors;
318:            }
319:
320:            /**
321:             * Returns true if filename must be omitted in the archive.
322:             *
323:             * @param name
324:             *            filename to be tested
325:             *
326:             * @return true if filename must be omitted.
327:             */
328:            public boolean omit(String name) {
329:                return (name.equals("META-INF/jonas-ejb-jar.xml") || name
330:                        .equals("META-INF\\jonas-ejb-jar.xml"));
331:            }
332:
333:            /**
334:             * Returns the Document of the jonas-ejb-jar.xml file.
335:             *
336:             * @return the Document of the jonas-ejb-jar.xml file.
337:             */
338:            public Document getJonasEjbJarDoc() {
339:                return jEjbJar;
340:            }
341:
342:            /**
343:             * Return the Document of the the jonas-webservices.xml
344:             *
345:             * @return the Document of the jonas-webservices.xml file
346:             */
347:            public Document getJonasWebservicesDoc() {
348:                return jWebservices;
349:            }
350:
351:            /**
352:             * Returns the InputStream of the jonas-ejb-jar.xml file.
353:             *
354:             * @return the InputStream of the jonas-ejb-jar.xml file.
355:             *
356:             * @throws IOException
357:             *             When InputStream of jonas-ejb-jar.xml cannot be returned
358:             */
359:            public InputStream getJonasEjbJarInputStream() throws IOException {
360:                InputStream is = null;
361:
362:                if (isPacked()) {
363:                    is = getInputStream("META-INF/jonas-ejb-jar.xml");
364:                } else {
365:                    is = getInputStream("META-INF" + File.separator
366:                            + "jonas-ejb-jar.xml");
367:                }
368:                if (is == null) {
369:                    throw new IOException(
370:                            "Cannot read jonas specific DD for EJB as the entry is not present");
371:                }
372:                return is;
373:            }
374:
375:            /**
376:             * Returns the InputStream of the jonas-webservices.xml file.
377:             *
378:             * @return the InputStream of the jonas-webservices.xml file.
379:             * @throws IOException When InputStream of jonas-webservices.xml cannot be returned
380:             */
381:            public InputStream getJonasWebservicesInputStream()
382:                    throws IOException {
383:                InputStream is = null;
384:
385:                if (isPacked()) {
386:                    is = getInputStream("META-INF/jonas-webservices.xml");
387:                } else {
388:                    is = getInputStream("META-INF" + File.separator
389:                            + "jonas-webservices.xml");
390:                }
391:                return is;
392:            }
393:
394:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.