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


001:        /*
002:         * Copyright 2001-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /**
017:         * JOnAS : Java(TM) OpenSource Application Server
018:         * Copyright (C) 2004 Bull S.A.
019:         * Contact: jonas-team@objectweb.org
020:         *
021:         * This library is free software; you can redistribute it and/or
022:         * modify it under the terms of the GNU Lesser General Public
023:         * License as published by the Free Software Foundation; either
024:         * version 2.1 of the License, or any later version.
025:         *
026:         * This library is distributed in the hope that it will be useful,
027:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
028:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
029:         * Lesser General Public License for more details.
030:         *
031:         * You should have received a copy of the GNU Lesser General Public
032:         * License along with this library; if not, write to the Free Software
033:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
034:         * USA
035:         *
036:         * --------------------------------------------------------------------------
037:         * $Id: J2EEClientDeployWriter.java 7560 2005-10-21 13:50:04Z sauthieg $
038:         * --------------------------------------------------------------------------
039:         */package org.objectweb.jonas_ws.wsgen.generator.ews.wsdltoj2ee.writer;
040:
041:        import java.io.IOException;
042:        import java.io.PrintWriter;
043:        import java.util.Iterator;
044:        import java.util.List;
045:
046:        import javax.wsdl.Definition;
047:        import javax.wsdl.Port;
048:        import javax.wsdl.Service;
049:        import javax.wsdl.extensions.UnknownExtensibilityElement;
050:        import javax.wsdl.extensions.soap.SOAPBinding;
051:        import javax.xml.namespace.QName;
052:
053:        import org.apache.axis.Constants;
054:        import org.apache.axis.constants.Style;
055:        import org.apache.axis.constants.Use;
056:        import org.apache.axis.utils.Messages;
057:        import org.apache.axis.wsdl.symbolTable.BindingEntry;
058:        import org.apache.axis.wsdl.symbolTable.SymbolTable;
059:        import org.apache.axis.wsdl.toJava.Emitter;
060:        import org.apache.axis.wsdl.toJava.Utils;
061:        import org.apache.ws.ews.context.webservices.client.ServiceReferenceContext;
062:        import org.apache.ws.ews.context.webservices.server.WSCFHandler;
063:        import org.apache.ws.ews.context.webservices.server.WSCFInitParam;
064:        import org.apache.ws.ews.context.webservices.server.WSCFSOAPHeader;
065:
066:        import org.objectweb.jonas_ws.wsgen.generator.ews.wsdltoj2ee.wscf.JOnASWSCFHandler;
067:
068:        /**
069:         * This is Wsdl2java's deploy Writer. It writes the deploy.wsdd file.
070:         * Based on J2eeDeployWriter from Ias
071:         * (http://cvs.apache.org/viewcvs.cgi/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java?rev=1.13&view=markup)
072:         */
073:        public class J2EEClientDeployWriter extends JOnASDeployWriter {
074:
075:            /**
076:             * WSDD Extension prefix
077:             */
078:            private static final String WSDD_PREFIX = "deploy-client-";
079:
080:            /**
081:             * Constructor.
082:             * @param emitter J2eeEmitter
083:             * @param definition wsdl:definition
084:             * @param symbolTable SymbolTable
085:             */
086:            public J2EEClientDeployWriter(Emitter emitter,
087:                    Definition definition, SymbolTable symbolTable) {
088:                super (emitter, definition, symbolTable);
089:            }
090:
091:            /**
092:             * Generate deploy.wsdd. Only generate it if the emitter is generating
093:             * server-side mappings.
094:             * @throws IOException When generation fails
095:             */
096:            public void generate() throws IOException {
097:
098:                if (!emitter.isServerSide()) {
099:                    super .generate();
100:                }
101:            }
102:
103:            /**
104:             * Write out deployment and undeployment instructions for each WSDL service
105:             * @param pw PrintWriter
106:             * @throws IOException IOException
107:             */
108:            protected void writeDeployServices(PrintWriter pw)
109:                    throws IOException {
110:
111:                int sRefIndex = getJonasWSContext()
112:                        .getServiceReferenceContextCount();
113:                // should only have 1 service-ref
114:                if (sRefIndex == 1) {
115:
116:                    ServiceReferenceContext ctx = getJonasWSContext()
117:                            .getServiceReferenceContext(0);
118:                    QName desiredServiceQName = ctx.getServiceQName();
119:
120:                    Service myService = getDefinition().getService(
121:                            desiredServiceQName);
122:
123:                    // Generate only if there is a Service
124:                    if (myService != null) {
125:                        pw.println();
126:                        pw.println("  <!-- "
127:                                + Messages.getMessage("wsdlService00",
128:                                        myService.getQName().getLocalPart())
129:                                + " -->");
130:                        pw.println();
131:
132:                        for (Iterator portIterator = myService.getPorts()
133:                                .values().iterator(); portIterator.hasNext();) {
134:                            Port myPort = (Port) portIterator.next();
135:                            BindingEntry bEntry = getSymbolTable()
136:                                    .getBindingEntry(
137:                                            myPort.getBinding().getQName());
138:
139:                            // If this isn't an SOAP binding, skip it
140:                            if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
141:                                continue;
142:                            }
143:
144:                            writeDeployPort(pw, myPort, bEntry, ctx);
145:                        }
146:                    }
147:                }
148:            }
149:
150:            /**
151:             * Write out deployment and undeployment instructions for given WSDL port
152:             * @param pw PrintWriter
153:             * @param port wsdl:port
154:             * @param bEntry Axis BindingEntry
155:             * @param ctx ServiceReferanceContext
156:             */
157:            protected void writeDeployPort(PrintWriter pw, Port port,
158:                    BindingEntry bEntry, ServiceReferenceContext ctx) {
159:
160:                String serviceName = port.getName();
161:                boolean hasLiteral = bEntry.hasLiteral();
162:                boolean hasMIME = Utils.hasMIME(bEntry);
163:
164:                Use use = Use.DEFAULT;
165:                String styleStr = "";
166:                Iterator iterator = bEntry.getBinding()
167:                        .getExtensibilityElements().iterator();
168:
169:                // iterate throught extensibilityElements of given Port's Binding
170:                while (iterator.hasNext()) {
171:                    Object obj = iterator.next();
172:
173:                    if (obj instanceof  SOAPBinding) {
174:                        use = Use.ENCODED;
175:                    } else if (obj instanceof  UnknownExtensibilityElement) {
176:
177:                        // TODO After WSDL4J supports soap12, change this code
178:                        UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj;
179:                        QName name = unkElement.getElementType();
180:
181:                        if (name.getNamespaceURI().equals(
182:                                Constants.URI_WSDL12_SOAP)
183:                                && name.getLocalPart().equals("binding")) {
184:                            use = Use.ENCODED;
185:                        }
186:                    }
187:                }
188:
189:                if (getSymbolTable().isWrapped()) {
190:                    styleStr = " style=\"" + Style.WRAPPED + "\"";
191:                    use = Use.LITERAL;
192:                } else {
193:                    styleStr = " style=\"" + bEntry.getBindingStyle().getName()
194:                            + "\"";
195:                    if (hasLiteral) {
196:                        use = Use.LITERAL;
197:                    }
198:                }
199:
200:                String useStr = " use=\"" + use + "\"";
201:
202:                pw.println("  <service name=\"" + serviceName + "\" "
203:                        + styleStr + useStr + " provider=\"java:Noop\">");
204:
205:                // MIME attachments don't work with multiref, so turn it off.
206:                if (hasMIME) {
207:                    pw
208:                            .println("      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
209:                }
210:                // force JAXRPC 1.1 Type Mapping
211:                pw
212:                        .println("      <parameter name=\"typeMappingVersion\" value=\""
213:                                + emitter.getTypeMappingVersion() + "\"/>");
214:
215:                //writeDeployBinding(pw, bEntry);
216:                writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME,
217:                        use);
218:
219:                WSCFHandler[] handlers = ctx.getHandlers();
220:                if (handlers != null && handlers.length != 0) {
221:                    pw.println("    <handlerInfoChain>");
222:                    for (int i = 0; i < handlers.length; i++) {
223:                        writeHandlerForPort(pw, (JOnASWSCFHandler) handlers[i],
224:                                port);
225:                    }
226:                    pw.println("    </handlerInfoChain>");
227:                }
228:                pw.println("  </service>");
229:            }
230:
231:            /**
232:             * Writes out a client-side handler
233:             * @param pw PrintWriter
234:             * @param handler EWS Handler description
235:             * @param port wsdl:port
236:             */
237:            private void writeHandlerForPort(PrintWriter pw,
238:                    JOnASWSCFHandler handler, Port port) {
239:
240:                /**
241:                 * If handler contains no port-names, add the handler
242:                 * else, check if the handler is applied to the current port
243:                 */
244:                List ports = handler.getPortNames();
245:                if (ports.isEmpty()) {
246:                    // handler applied for all ports
247:                    writeHandler(pw, handler);
248:                } else if (ports.contains(port.getName())) {
249:                    // handler applied for current port
250:                    writeHandler(pw, handler);
251:                }
252:            }
253:
254:            /**
255:             * Writes out a client-side handler
256:             * @param pw PrintWriter
257:             * @param handler EWS Handler description
258:             */
259:            private void writeHandler(PrintWriter pw, JOnASWSCFHandler handler) {
260:
261:                pw.println("      <handlerInfo classname=\""
262:                        + handler.getHandlerClass() + "\">");
263:                WSCFInitParam[] param = handler.getInitParam();
264:                for (int i = 0; i < param.length; i++) {
265:                    pw.println("        <parameter name=\""
266:                            + param[i].getParamName() + "\" value=\""
267:                            + param[i].getParamValue() + "\"/>");
268:                }
269:                WSCFSOAPHeader[] headers = handler.getSoapHeader();
270:                for (int i = 0; i < headers.length; i++) {
271:                    pw.println("        <header xmlns:ns=\""
272:                            + headers[i].getNamespaceURI() + "\" qname=\"ns:"
273:                            + headers[i].getLocalpart() + "\"/>");
274:                }
275:                pw.println("      </handlerInfo>");
276:                String[] roles = handler.getSoapRole();
277:                for (int i = 0; i < roles.length; i++) {
278:                    pw.println("      <role soapActorName=\"" + roles[i]
279:                            + "\"/>");
280:                }
281:            }
282:
283:            /**
284:             * @return Returns the filename prefix
285:             */
286:            protected String getPrefix() {
287:                return WSDD_PREFIX;
288:            }
289:        }
ww___w_.___ja__v___a2__s_.__c_o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.