Source Code Cross Referenced for EjbJarModifier.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ws » wsgen » modifier » 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_ws.wsgen.modifier 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2003-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: EjbJarModifier.java 9457 2006-08-24 12:58:41Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ws.wsgen.modifier;
025:
026:        import java.io.File;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import java.util.jar.Attributes;
030:
031:        import org.w3c.dom.Document;
032:
033:        import org.objectweb.jonas_lib.genbase.GenBaseException;
034:        import org.objectweb.jonas_lib.genbase.archive.Application;
035:        import org.objectweb.jonas_lib.genbase.archive.Archive;
036:        import org.objectweb.jonas_lib.genbase.archive.DummyApplication;
037:        import org.objectweb.jonas_lib.genbase.archive.DummyWebApp;
038:        import org.objectweb.jonas_lib.genbase.archive.Ejb;
039:        import org.objectweb.jonas_lib.genbase.archive.EjbJar;
040:        import org.objectweb.jonas_lib.genbase.archive.WebApp;
041:        import org.objectweb.jonas_lib.genbase.modifier.ArchiveModifier;
042:        import org.objectweb.jonas_lib.version.Version;
043:
044:        import org.objectweb.jonas_ws.deployment.api.ServiceDesc;
045:        import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
046:        import org.objectweb.jonas_ws.wsgen.ddmodifier.ContextDDModifier;
047:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WebJettyDDModifier;
048:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier;
049:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier;
050:        import org.objectweb.jonas_ws.wsgen.generator.Generator;
051:        import org.objectweb.jonas_ws.wsgen.generator.GeneratorFactory;
052:        import org.objectweb.jonas_ws.wsgen.generator.SecurityGenerator;
053:
054:        import org.objectweb.util.monolog.api.BasicLevel;
055:
056:        /**
057:         * Modify a given EjbJar.
058:         *
059:         * @author Guillaume Sauthier
060:         */
061:        public class EjbJarModifier extends ArchiveModifier {
062:
063:            /** modified ejbjar */
064:            private EjbJar ejbjar = null;
065:
066:            /**
067:             * Creates a new EjbJarModifier object.
068:             *
069:             * @param ejbjar EjbJar Archive
070:             */
071:            public EjbJarModifier(EjbJar ejbjar) {
072:                super (ejbjar);
073:                this .ejbjar = ejbjar;
074:            }
075:
076:            /**
077:             * modify the current EjbJar. If EjbJar is contained in not an application
078:             * and have webservices endpoints, A DummyApplication is created and
079:             * modification process launched against the newly created application. If
080:             * EjbJar is contained in an application + webservices endpoints, a
081:             * DummyWebApp is created to hold "facade" servlet managing SOAP processing.
082:             *
083:             * @return an EjbJar or an Application Archive
084:             *
085:             * @throws GenBaseException When generation or storing fails
086:             */
087:            public Archive modify() throws GenBaseException {
088:
089:                getLogger().log(BasicLevel.INFO,
090:                        "Processing EjbJar " + ejbjar.getName());
091:
092:                // Update MANIFEST with Version Number
093:                // used to say if WsGen has already been applied to this Module
094:                Attributes main = this .ejbjar.getManifest().getMainAttributes();
095:                main.put(new Attributes.Name(
096:                        WsGenModifierConstants.WSGEN_JONAS_VERSION_ATTR),
097:                        Version.getNumber());
098:
099:                GeneratorFactory gf = GeneratorFactory.getInstance();
100:                Document jejbjar = ejbjar.getJonasEjbJarDoc();
101:
102:                // Webservices endpoint
103:                List sds = ejbjar.getServiceDescs();
104:
105:                if (sds.size() != 0) {
106:                    if (ejbjar.getApplication() == null) {
107:                        // we have webservices outside of an application
108:
109:                        /**
110:                         * Process : - create a default Application - add EjbJar within -
111:                         * return ApplicationModifier.modify()
112:                         */
113:                        String ejbName = ejbjar.getRootFile().getName();
114:                        String earName = ejbName.substring(0, ejbName.length()
115:                                - ".jar".length())
116:                                + ".ear";
117:                        Application application = new DummyApplication(earName);
118:                        ejbjar.setApplication(application);
119:                        application.addEjbJar(ejbjar);
120:                        ApplicationModifier am = new ApplicationModifier(
121:                                application);
122:
123:                        return am.modify();
124:
125:                    } else {
126:                        // we have webservices inside of an application
127:
128:                        /**
129:                         * Process : - create a default WebApp - add in Application -
130:                         * iterate over the services - add files in web instead of
131:                         * ejbjar
132:                         */
133:
134:                        String warName = null;
135:                        String war = ejbjar.getWarName();
136:                        if (war != null) {
137:                            warName = war;
138:                        } else {
139:                            String ejbName = ejbjar.getRootFile().getName();
140:                            String contextName = ejbName.substring(0, ejbName
141:                                    .length()
142:                                    - ".jar".length());
143:                            warName = contextName + ".war";
144:                        }
145:
146:                        Application application = ejbjar.getApplication();
147:                        WebApp web = new DummyWebApp(application, warName);
148:
149:                        for (Iterator i = sds.iterator(); i.hasNext();) {
150:                            ServiceDesc sd = (ServiceDesc) i.next();
151:
152:                            // create dd modifier
153:                            WsEndpointDDModifier ddm = new WsEndpointDDModifier(
154:                                    web.getWebAppDoc());
155:
156:                            // launch generation
157:                            Generator g = gf
158:                                    .newGenerator(sd, ddm, null, ejbjar);
159:                            g.generate();
160:                            g.compile();
161:                            // add files in web archive
162:                            g.addFiles(web);
163:
164:                            //Now generate the security for the web app
165:                            Document context = web.getContextDoc();
166:                            if (context == null) {
167:                                context = web.newContextDoc();
168:                            }
169:                            ContextDDModifier cddm = new ContextDDModifier(
170:                                    context);
171:                            Document webJetty = web.getWebJettyDoc();
172:                            if (webJetty == null) {
173:                                webJetty = web.newWebJettyDoc();
174:                            }
175:                            WebJettyDDModifier wjddm = new WebJettyDDModifier(
176:                                    webJetty);
177:                            Document jonaswebservices = ejbjar
178:                                    .getJonasWebservicesDoc();
179:                            SecurityGenerator sm = new SecurityGenerator(
180:                                    jonaswebservices);
181:                            sm.generate(ddm, cddm, wjddm);
182:
183:                        }
184:                        // save webapp
185:                        application
186:                                .addWebApp(
187:                                        new WebApp(save(gf.getConfiguration(),
188:                                                "webapps" + File.separator
189:                                                        + web.getName(), web)),
190:                                        ejbjar.getContextRoot());
191:                    }
192:                }
193:
194:                // add client files
195:                List ejbs = ejbjar.getEjbs();
196:                for (Iterator i = ejbs.iterator(); i.hasNext();) {
197:                    Ejb ejb = (Ejb) i.next();
198:                    List refs = ejb.getServiceRefDescs();
199:                    for (Iterator j = refs.iterator(); j.hasNext();) {
200:                        ServiceRefDesc ref = (ServiceRefDesc) j.next();
201:
202:                        // create dd modifier
203:                        WsClientDDModifier ddm = new WsClientDDModifier(ref
204:                                .getServiceRefName(), jejbjar, ejb
205:                                .getJonasBeanElement());
206:
207:                        // launch generation
208:                        Generator g = gf.newGenerator(ref, ddm, ejbjar);
209:                        g.generate();
210:                        g.compile();
211:                        // add files in web archive
212:                        g.addFiles(ejbjar);
213:                    }
214:                }
215:
216:                return save(gf.getConfiguration(), "ejbjars" + File.separator
217:                        + ejbjar.getRootFile().getName());
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.