1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.remoting.jaxws;
18
19 import java.io.IOException;
20 import java.net.URL;
21 import java.util.concurrent.Executor;
22 import javax.xml.namespace.QName;
23 import javax.xml.ws.Service;
24 import javax.xml.ws.WebServiceFeature;
25 import javax.xml.ws.handler.HandlerResolver;
26
27 import org.springframework.core.io.Resource;
28 import org.springframework.lang.UsesJava7;
29 import org.springframework.util.Assert;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class LocalJaxWsServiceFactory {
46
47 private URL wsdlDocumentUrl;
48
49 private String namespaceUri;
50
51 private String serviceName;
52
53 private WebServiceFeature[] serviceFeatures;
54
55 private Executor executor;
56
57 private HandlerResolver handlerResolver;
58
59
60
61
62
63
64 public void setWsdlDocumentUrl(URL wsdlDocumentUrl) {
65 this.wsdlDocumentUrl = wsdlDocumentUrl;
66 }
67
68
69
70
71
72
73 public void setWsdlDocumentResource(Resource wsdlDocumentResource) throws IOException {
74 Assert.notNull(wsdlDocumentResource, "WSDL Resource must not be null.");
75 this.wsdlDocumentUrl = wsdlDocumentResource.getURL();
76 }
77
78
79
80
81 public URL getWsdlDocumentUrl() {
82 return this.wsdlDocumentUrl;
83 }
84
85
86
87
88
89 public void setNamespaceUri(String namespaceUri) {
90 this.namespaceUri = (namespaceUri != null ? namespaceUri.trim() : null);
91 }
92
93
94
95
96 public String getNamespaceUri() {
97 return this.namespaceUri;
98 }
99
100
101
102
103
104 public void setServiceName(String serviceName) {
105 this.serviceName = serviceName;
106 }
107
108
109
110
111 public String getServiceName() {
112 return this.serviceName;
113 }
114
115
116
117
118
119
120
121
122 public void setServiceFeatures(WebServiceFeature... serviceFeatures) {
123 this.serviceFeatures = serviceFeatures;
124 }
125
126
127
128
129
130
131 public void setExecutor(Executor executor) {
132 this.executor = executor;
133 }
134
135
136
137
138
139
140 public void setHandlerResolver(HandlerResolver handlerResolver) {
141 this.handlerResolver = handlerResolver;
142 }
143
144
145
146
147
148
149
150 @UsesJava7
151 public Service createJaxWsService() {
152 Assert.notNull(this.serviceName, "No service name specified");
153 Service service;
154
155 if (this.serviceFeatures != null) {
156 service = (this.wsdlDocumentUrl != null ?
157 Service.create(this.wsdlDocumentUrl, getQName(this.serviceName), this.serviceFeatures) :
158 Service.create(getQName(this.serviceName), this.serviceFeatures));
159 }
160 else {
161 service = (this.wsdlDocumentUrl != null ?
162 Service.create(this.wsdlDocumentUrl, getQName(this.serviceName)) :
163 Service.create(getQName(this.serviceName)));
164 }
165
166 if (this.executor != null) {
167 service.setExecutor(this.executor);
168 }
169 if (this.handlerResolver != null) {
170 service.setHandlerResolver(this.handlerResolver);
171 }
172
173 return service;
174 }
175
176
177
178
179
180
181 protected QName getQName(String name) {
182 return (getNamespaceUri() != null ? new QName(getNamespaceUri(), name) : new QName(name));
183 }
184
185 }