Source Code Cross Referenced for AbstractBindingWsdl4jDefinitionBuilder.java in  » Web-Services » spring-ws-1.0.0 » org » springframework » ws » wsdl » wsdl11 » builder » 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 » Web Services » spring ws 1.0.0 » org.springframework.ws.wsdl.wsdl11.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 the original author or authors.
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:        package org.springframework.ws.wsdl.wsdl11.builder;
018:
019:        import java.util.Iterator;
020:        import javax.wsdl.Binding;
021:        import javax.wsdl.BindingFault;
022:        import javax.wsdl.BindingInput;
023:        import javax.wsdl.BindingOperation;
024:        import javax.wsdl.BindingOutput;
025:        import javax.wsdl.Definition;
026:        import javax.wsdl.Fault;
027:        import javax.wsdl.Input;
028:        import javax.wsdl.Operation;
029:        import javax.wsdl.Output;
030:        import javax.wsdl.Port;
031:        import javax.wsdl.PortType;
032:        import javax.wsdl.Service;
033:        import javax.wsdl.WSDLException;
034:        import javax.xml.namespace.QName;
035:
036:        import org.springframework.ws.wsdl.wsdl11.Wsdl4jDefinitionException;
037:
038:        /**
039:         * Abstract base class for <code>Wsdl11DefinitionBuilder</code> implementations that use WSDL4J and contain a concrete
040:         * part. Creates a <code>binding</code> that matches any present <code>portType</code>, and a service containing
041:         * <code>port</code>s that match the <code>binding</code>s. Lets subclasses populate these through template methods.
042:         *
043:         * @author Arjen Poutsma
044:         * @since 1.0.0
045:         */
046:        public abstract class AbstractBindingWsdl4jDefinitionBuilder extends
047:                AbstractWsdl4jDefinitionBuilder {
048:
049:            /** The suffix used to create a binding name from a port type name. */
050:            private static final String BINDING_SUFFIX = "Binding";
051:
052:            /** The suffix used to create a binding name from a port type name. */
053:            private static final String PORT_SUFFIX = "Port";
054:
055:            /**
056:             * Creates a <code>Binding</code> for each <code>PortType</code> in the definition, and calls
057:             * <code>populateBinding</code> with it. Creates a <code>BindingOperation</code> for each <code>Operation</code> in
058:             * the port type, a <code>BindingInput</code> for each <code>Input</code> in the operation, etc.
059:             * <p/>
060:             * Calls the various <code>populate</code> methods with the created WSDL4J objects.
061:             *
062:             * @param definition the WSDL4J <code>Definition</code>
063:             * @throws WSDLException in case of errors
064:             * @see javax.wsdl.Binding
065:             * @see javax.wsdl.extensions.soap.SOAPBinding
066:             * @see #populateBinding(javax.wsdl.Binding,javax.wsdl.PortType)
067:             * @see javax.wsdl.BindingOperation
068:             * @see #populateBindingOperation(javax.wsdl.BindingOperation,javax.wsdl.Operation)
069:             * @see javax.wsdl.BindingInput
070:             * @see #populateBindingInput(javax.wsdl.BindingInput,javax.wsdl.Input)
071:             * @see javax.wsdl.BindingOutput
072:             * @see #populateBindingOutput(javax.wsdl.BindingOutput,javax.wsdl.Output)
073:             * @see javax.wsdl.BindingFault
074:             * @see #populateBindingFault(javax.wsdl.BindingFault,javax.wsdl.Fault)
075:             */
076:            public void buildBindings(Definition definition)
077:                    throws WSDLException {
078:                try {
079:                    for (Iterator iterator = definition.getPortTypes().values()
080:                            .iterator(); iterator.hasNext();) {
081:                        PortType portType = (PortType) iterator.next();
082:                        Binding binding = definition.createBinding();
083:                        binding.setPortType(portType);
084:                        populateBinding(binding, portType);
085:                        createBindingOperations(definition, binding, portType);
086:                        binding.setUndefined(false);
087:                        definition.addBinding(binding);
088:                    }
089:                } catch (WSDLException ex) {
090:                    throw new Wsdl4jDefinitionException(ex);
091:                }
092:            }
093:
094:            /**
095:             * Called after the <code>Binding</code> has been created, but before any sub-elements are added. Subclasses can
096:             * implement this method to define the binding name, or add extensions to it.
097:             * <p/>
098:             * Default implementation sets the binding name to the port type name with the suffix <code>Binding</code> appended
099:             * to it.
100:             *
101:             * @param binding  the WSDL4J <code>Binding</code>
102:             * @param portType the corresponding <code>PortType</code>
103:             * @throws WSDLException in case of errors
104:             */
105:            protected void populateBinding(Binding binding, PortType portType)
106:                    throws WSDLException {
107:                QName portTypeName = portType.getQName();
108:                if (portTypeName != null) {
109:                    binding.setQName(new QName(portTypeName.getNamespaceURI(),
110:                            portTypeName.getLocalPart() + BINDING_SUFFIX));
111:                }
112:            }
113:
114:            private void createBindingOperations(Definition definition,
115:                    Binding binding, PortType portType) throws WSDLException {
116:                for (Iterator operationIterator = portType.getOperations()
117:                        .iterator(); operationIterator.hasNext();) {
118:                    Operation operation = (Operation) operationIterator.next();
119:                    BindingOperation bindingOperation = definition
120:                            .createBindingOperation();
121:                    bindingOperation.setOperation(operation);
122:                    populateBindingOperation(bindingOperation, operation);
123:                    if (operation.getInput() != null) {
124:                        BindingInput bindingInput = definition
125:                                .createBindingInput();
126:                        populateBindingInput(bindingInput, operation.getInput());
127:                        bindingOperation.setBindingInput(bindingInput);
128:                    }
129:                    if (operation.getOutput() != null) {
130:                        BindingOutput bindingOutput = definition
131:                                .createBindingOutput();
132:                        populateBindingOutput(bindingOutput, operation
133:                                .getOutput());
134:                        bindingOperation.setBindingOutput(bindingOutput);
135:                    }
136:                    for (Iterator faultIterator = operation.getFaults()
137:                            .values().iterator(); faultIterator.hasNext();) {
138:                        Fault fault = (Fault) faultIterator.next();
139:                        BindingFault bindingFault = definition
140:                                .createBindingFault();
141:                        populateBindingFault(bindingFault, fault);
142:                        bindingOperation.addBindingFault(bindingFault);
143:                    }
144:                    binding.addBindingOperation(bindingOperation);
145:                }
146:            }
147:
148:            /**
149:             * Called after the <code>BindingOperation</code> has been created, but before any sub-elements are added.
150:             * Subclasses can implement this method to define the binding name, or add extensions to it.
151:             * <p/>
152:             * Default implementation sets the name of the binding operation to the name of the operation.
153:             *
154:             * @param bindingOperation the WSDL4J <code>BindingOperation</code>
155:             * @param operation        the corresponding WSDL4J <code>Operation</code>
156:             * @throws WSDLException in case of errors
157:             */
158:            protected void populateBindingOperation(
159:                    BindingOperation bindingOperation, Operation operation)
160:                    throws WSDLException {
161:                bindingOperation.setName(operation.getName());
162:            }
163:
164:            /**
165:             * Called after the <code>BindingInput</code> has been created. Subclasses can implement this method to define the
166:             * name, or add extensions to it.
167:             * <p/>
168:             * Default implementation set the name of the binding input to the name of the input.
169:             *
170:             * @param bindingInput the WSDL4J <code>BindingInput</code>
171:             * @param input        the corresponding WSDL4J <code>Input</code>
172:             * @throws WSDLException in case of errors
173:             */
174:            protected void populateBindingInput(BindingInput bindingInput,
175:                    Input input) throws WSDLException {
176:                bindingInput.setName(input.getName());
177:            }
178:
179:            /**
180:             * Called after the <code>BindingOutput</code> has been created. Subclasses can implement this method to define the
181:             * name, or add extensions to it.
182:             * <p/>
183:             * Default implementation set the name of the binding output to the name of the output.
184:             *
185:             * @param bindingOutput the WSDL4J <code>BindingOutput</code>
186:             * @param output        the corresponding WSDL4J <code>Output</code>
187:             * @throws WSDLException in case of errors
188:             */
189:            protected void populateBindingOutput(BindingOutput bindingOutput,
190:                    Output output) throws WSDLException {
191:                bindingOutput.setName(output.getName());
192:            }
193:
194:            /**
195:             * Called after the <code>BindingFault</code> has been created. Subclasses can implement this method to define the
196:             * name, or add extensions to it.
197:             * <p/>
198:             * Default implementation set the name of the binding fault to the name of the fault.
199:             *
200:             * @param bindingFault the WSDL4J <code>BindingFault</code>
201:             * @param fault        the corresponding WSDL4J <code>Fault</code>
202:             * @throws WSDLException in case of errors
203:             */
204:            protected void populateBindingFault(BindingFault bindingFault,
205:                    Fault fault) throws WSDLException {
206:                bindingFault.setName(fault.getName());
207:            }
208:
209:            /**
210:             * Creates a single <code>Service</code>, and calls <code>populateService()</code> with it. Creates a corresponding
211:             * <code>Port</code> for each <code>Binding</code>, which is passed to <code>populatePort()</code>.
212:             *
213:             * @param definition the WSDL4J <code>Definition</code>
214:             * @throws WSDLException in case of errors
215:             * @see javax.wsdl.Service
216:             * @see javax.wsdl.Port
217:             * @see #populatePort(javax.wsdl.Port,javax.wsdl.Binding)
218:             */
219:            public void buildServices(Definition definition)
220:                    throws WSDLException {
221:                Service service = definition.createService();
222:                populateService(service);
223:                createPorts(definition, service);
224:                definition.addService(service);
225:            }
226:
227:            /**
228:             * Called after the <code>Binding</code> has been created, but before any sub-elements are added. Subclasses can
229:             * implement this method to define the binding name, or add extensions to it.
230:             * <p/>
231:             * Default implementation is empty.
232:             *
233:             * @param service the WSDL4J <code>Service</code>
234:             * @throws WSDLException in case of errors
235:             */
236:            protected void populateService(Service service)
237:                    throws WSDLException {
238:            }
239:
240:            private void createPorts(Definition definition, Service service)
241:                    throws WSDLException {
242:                for (Iterator iterator = definition.getBindings().values()
243:                        .iterator(); iterator.hasNext();) {
244:                    Binding binding = (Binding) iterator.next();
245:                    Port port = definition.createPort();
246:                    port.setBinding(binding);
247:                    populatePort(port, binding);
248:                    service.addPort(port);
249:                }
250:            }
251:
252:            /**
253:             * Called after the <code>Port</code> has been created, but before any sub-elements are added. Subclasses can
254:             * implement this method to define the port name, or add extensions to it.
255:             * <p/>
256:             * <p/>
257:             * Default implementation sets the port name to the port type name with the suffix <code>Port</code> appended to
258:             * it.
259:             *
260:             * @param port    the WSDL4J <code>Port</code>
261:             * @param binding the corresponding WSDL4J <code>Binding</code>
262:             * @throws WSDLException in case of errors
263:             */
264:            protected void populatePort(Port port, Binding binding)
265:                    throws WSDLException {
266:                if (binding.getPortType() != null
267:                        && binding.getPortType().getQName() != null) {
268:                    port.setName(binding.getPortType().getQName()
269:                            .getLocalPart()
270:                            + PORT_SUFFIX);
271:                }
272:            }
273:
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.