1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.wsdl.wsdl11.builder;
18
19 import javax.wsdl.Definition;
20 import javax.wsdl.WSDLException;
21 import javax.wsdl.extensions.ExtensibilityElement;
22 import javax.wsdl.extensions.ExtensionRegistry;
23 import javax.wsdl.factory.WSDLFactory;
24 import javax.xml.namespace.QName;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.springframework.ws.wsdl.WsdlDefinitionException;
30 import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
31 import org.springframework.ws.wsdl.wsdl11.Wsdl11DefinitionBuilder;
32 import org.springframework.ws.wsdl.wsdl11.Wsdl4jDefinition;
33 import org.springframework.ws.wsdl.wsdl11.Wsdl4jDefinitionException;
34
35
36
37
38
39
40
41
42
43
44 public abstract class AbstractWsdl4jDefinitionBuilder implements Wsdl11DefinitionBuilder {
45
46
47 protected final Log logger = LogFactory.getLog(getClass());
48
49
50 private Definition definition;
51
52 public final void buildDefinition() throws WsdlDefinitionException {
53 try {
54 WSDLFactory wsdlFactory = WSDLFactory.newInstance();
55 definition = wsdlFactory.newDefinition();
56 if (definition.getExtensionRegistry() == null) {
57 ExtensionRegistry extensionRegistry = wsdlFactory.newPopulatedExtensionRegistry();
58 definition.setExtensionRegistry(extensionRegistry);
59 }
60 populateExtensionRegistry(definition.getExtensionRegistry());
61 populateDefinition(definition);
62 }
63 catch (WSDLException ex) {
64 throw new Wsdl4jDefinitionException(ex);
65 }
66 }
67
68
69
70
71
72
73
74
75
76 protected void populateDefinition(Definition definition) throws WSDLException {
77 }
78
79 public final void buildImports() throws WsdlDefinitionException {
80 try {
81 buildImports(definition);
82 }
83 catch (WSDLException ex) {
84 throw new Wsdl4jDefinitionException(ex);
85 }
86 }
87
88
89
90
91
92
93
94 protected abstract void buildImports(Definition definition) throws WSDLException;
95
96 public final void buildTypes() throws WsdlDefinitionException {
97 try {
98 buildTypes(definition);
99 }
100 catch (WSDLException ex) {
101 throw new Wsdl4jDefinitionException(ex);
102 }
103 }
104
105
106
107
108
109
110
111 protected abstract void buildTypes(Definition definition) throws WSDLException;
112
113 public final void buildMessages() throws WsdlDefinitionException {
114 try {
115 buildMessages(definition);
116 }
117 catch (WSDLException ex) {
118 throw new Wsdl4jDefinitionException(ex);
119 }
120 }
121
122
123
124
125
126
127
128 protected abstract void buildMessages(Definition definition) throws WSDLException;
129
130 public final void buildPortTypes() throws WsdlDefinitionException {
131 try {
132 buildPortTypes(definition);
133 }
134 catch (WSDLException ex) {
135 throw new Wsdl4jDefinitionException(ex);
136 }
137 }
138
139
140
141
142
143
144
145 protected abstract void buildPortTypes(Definition definition) throws WSDLException;
146
147 public final void buildBindings() throws WsdlDefinitionException {
148 try {
149 buildBindings(definition);
150 }
151 catch (WSDLException ex) {
152 throw new Wsdl4jDefinitionException(ex);
153 }
154 }
155
156
157
158
159
160
161
162 protected abstract void buildBindings(Definition definition) throws WSDLException;
163
164 public final void buildServices() throws WsdlDefinitionException {
165 try {
166 buildServices(definition);
167 }
168 catch (WSDLException ex) {
169 throw new Wsdl4jDefinitionException(ex);
170 }
171 }
172
173
174
175
176
177
178
179 protected abstract void buildServices(Definition definition) throws WSDLException;
180
181 public final Wsdl11Definition getDefinition() throws WsdlDefinitionException {
182 return new Wsdl4jDefinition(definition);
183 }
184
185
186
187
188
189
190
191
192
193
194 protected ExtensibilityElement createExtension(Class parentType, QName elementType) throws WSDLException {
195 return definition.getExtensionRegistry().createExtension(parentType, elementType);
196 }
197
198
199 protected void populateExtensionRegistry(ExtensionRegistry extensionRegistry) {
200 }
201
202 }