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


001:        /**
002:         * JOnAS : Java(TM) OpenSource Application Server
003:         * Copyright (C) 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: AxisWsEndpointGenerator.java 6137 2005-01-21 13:35:50Z pelletib $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ws.wsgen.generator.axis;
025:
026:        import java.io.File;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import java.util.Vector;
030:
031:        import org.apache.velocity.VelocityContext;
032:
033:        import org.objectweb.jonas_lib.genbase.GenBaseException;
034:        import org.objectweb.jonas_lib.genbase.archive.Archive;
035:        import org.objectweb.jonas_lib.genbase.archive.WebApp;
036:        import org.objectweb.jonas_lib.genbase.generator.Config;
037:
038:        import org.objectweb.jonas_ws.deployment.api.JaxRpcPortComponentDesc;
039:        import org.objectweb.jonas_ws.deployment.api.PortComponentDesc;
040:        import org.objectweb.jonas_ws.deployment.api.ServiceDesc;
041:        import org.objectweb.jonas_ws.wsgen.WsGenException;
042:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WebServicesDDModifier;
043:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier;
044:        import org.objectweb.jonas_ws.wsgen.generator.WsEndpointGenerator;
045:
046:        import org.objectweb.jonas.common.Log;
047:
048:        import org.objectweb.util.monolog.api.BasicLevel;
049:        import org.objectweb.util.monolog.api.Logger;
050:
051:        /**
052:         * Generate Axis specific config files for Endpoint
053:         *
054:         * @author Guillaume Sauthier
055:         */
056:        public class AxisWsEndpointGenerator extends WsEndpointGenerator {
057:
058:            /**
059:             * unique JVelocity instance
060:             */
061:            private static JVelocity jvelocity = null;
062:
063:            /**
064:             * logger
065:             */
066:            private static Logger logger = Log
067:                    .getLogger(Log.JONAS_WSGEN_PREFIX);
068:
069:            /**
070:             * Axis Servlet classname
071:             */
072:            private static final String AXIS_SERVLET_CLASS = "org.objectweb.jonas.ws.axis.JAxisServlet";
073:
074:            /**
075:             * init-param name for declaring server configuration file
076:             */
077:            private static final String SERVER_CONFIG = "axis.serverConfigFile";
078:
079:            /**
080:             * WSDD Extension suffix
081:             */
082:            private static final String WSDD_SUFFIX = ".wsdd";
083:
084:            /**
085:             * WSDD Extension prefix
086:             */
087:            private static final String WSDD_PREFIX = "deploy-server-";
088:
089:            /**
090:             * count generated files
091:             */
092:            private static int count = 0;
093:
094:            /**
095:             * generated server-config file
096:             */
097:            private File generatedServerConfig;
098:
099:            /**
100:             * Creates a new AxisWsEndpointGenerator
101:             *
102:             * @param config Generator Configuration
103:             * @param serviceDesc WebService Endpoint description
104:             * @param ddm Web DD Modifier
105:             * @param wsddm webservices.xml DD modifier
106:             *
107:             * @throws GenBaseException When instanciation fails
108:             * @throws WsGenException When instanciation fails.
109:             */
110:            public AxisWsEndpointGenerator(Config config,
111:                    ServiceDesc serviceDesc, WsEndpointDDModifier ddm,
112:                    WebServicesDDModifier wsddm, Archive arch)
113:                    throws GenBaseException, WsGenException {
114:                super (config, serviceDesc, ddm, wsddm, arch);
115:
116:                // init velocity
117:                if (jvelocity == null) {
118:                    jvelocity = new JVelocity("deploy_endpoint.vm");
119:                }
120:            }
121:
122:            /**
123:             * Generate server side configuration file
124:             *
125:             * @throws WsGenException When generation fails
126:             */
127:            public void generate() throws WsGenException {
128:                String sName = getService().getName();
129:
130:                // construct VelocityContext
131:                VelocityContext vc = VContextFactory.getContext(getService());
132:
133:                // Generate file
134:                String filename = WSDD_PREFIX + (count++) + WSDD_SUFFIX;
135:                generatedServerConfig = new File(getSources(), filename);
136:                jvelocity.generate(generatedServerConfig, vc);
137:
138:                // remove existing servlets
139:                for (Iterator i = getService().getPortComponents().iterator(); i
140:                        .hasNext();) {
141:                    Object obj = i.next();
142:                    if (obj instanceof  JaxRpcPortComponentDesc) {
143:                        JaxRpcPortComponentDesc jax = (JaxRpcPortComponentDesc) obj;
144:
145:                        if (logger.isLoggable(BasicLevel.DEBUG)) {
146:                            logger.log(BasicLevel.DEBUG, "Removing servlet '"
147:                                    + jax.getSibLink() + "'");
148:                        }
149:
150:                        // remove servlet mapping
151:                        getModifier().removeServletMapping(jax.getSibLink());
152:                        // remove old servlet
153:                        getModifier().removeServlet(jax.getSibLink());
154:                        // change sib-link
155:                        getWsModifier().changeServletLink(sName,
156:                                jax.getSibLink(), sName);
157:                    }
158:                }
159:
160:                // and use our own
161:                getModifier().addServlet(sName, AXIS_SERVLET_CLASS);
162:                getModifier().addServletParam(sName, SERVER_CONFIG, filename);
163:
164:                // setup servlet-mappings
165:                boolean requireDefaultMapping = false;
166:                List usedServletMappings = new Vector();
167:                for (Iterator i = getService().getPortComponents().iterator(); i
168:                        .hasNext();) {
169:                    PortComponentDesc pcd = (PortComponentDesc) i.next();
170:                    String mapping = pcd.getMapping();
171:                    if (mapping != null) {
172:                        // port has specified an endpoint URI
173:                        // use it for servlet-mapping
174:                        if (!usedServletMappings.contains(mapping)) {
175:                            usedServletMappings.add(mapping);
176:
177:                            if (logger.isLoggable(BasicLevel.DEBUG)) {
178:                                logger.log(BasicLevel.DEBUG,
179:                                        "Adding servlet-mapping for '" + sName
180:                                                + "' -> '" + mapping + "'");
181:                            }
182:
183:                            getModifier().addServletMapping(sName, mapping);
184:                        }
185:                    } else {
186:                        // no specified endpoint uri for the port
187:                        requireDefaultMapping = true;
188:                    }
189:                }
190:                if (requireDefaultMapping) {
191:                    // try to set a default mapping
192:                    String defaultEndpointURI = getService().getEndpointURI();
193:                    if (defaultEndpointURI == null) {
194:                        // default behavior
195:                        getModifier().addServletMapping(sName,
196:                                "/" + sName + "/*");
197:                    } else {
198:                        // use retieved value
199:                        getModifier().addServletMapping(sName,
200:                                defaultEndpointURI);
201:                    }
202:                }
203:
204:            }
205:
206:            /**
207:             * Add generated files in given Archive
208:             *
209:             * @param archive WebApp archive
210:             *
211:             * @throws WsGenException When cannot add files in archive
212:             */
213:            public void addFiles(Archive archive) throws WsGenException {
214:                // archive must be a WebApp
215:                if (!(archive instanceof  WebApp)) {
216:                    String err = getI18n().getMessage(
217:                            "AxisWsEndpointGenerator.addFiles.illegal",
218:                            archive.getRootFile());
219:                    throw new IllegalArgumentException(err);
220:                }
221:
222:                WebApp web = (WebApp) archive;
223:                web.addFileIn("WEB-INF/", generatedServerConfig);
224:
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.