1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.api.bus.support; |
17 | |
|
18 | |
import org.kuali.rice.core.api.CoreConstants; |
19 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
20 | |
import org.kuali.rice.core.api.security.credentials.CredentialsType; |
21 | |
import org.kuali.rice.core.api.util.jaxb.EnumStringAdapter; |
22 | |
import org.kuali.rice.core.api.util.jaxb.QNameAsStringAdapter; |
23 | |
import org.kuali.rice.ksb.api.bus.ServiceConfiguration; |
24 | |
import org.kuali.rice.ksb.api.bus.ServiceDefinition; |
25 | |
import org.w3c.dom.Element; |
26 | |
|
27 | |
import javax.xml.bind.annotation.XmlAccessType; |
28 | |
import javax.xml.bind.annotation.XmlAccessorType; |
29 | |
import javax.xml.bind.annotation.XmlAnyElement; |
30 | |
import javax.xml.bind.annotation.XmlElement; |
31 | |
import javax.xml.bind.annotation.XmlType; |
32 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
33 | |
import javax.xml.namespace.QName; |
34 | |
import java.io.Serializable; |
35 | |
import java.net.URL; |
36 | |
import java.util.Collection; |
37 | |
|
38 | |
@XmlAccessorType(XmlAccessType.NONE) |
39 | |
@XmlType(name = AbstractServiceConfiguration.Constants.TYPE_NAME, propOrder = { |
40 | |
AbstractServiceConfiguration.Elements.SERVICE_NAME, |
41 | |
AbstractServiceConfiguration.Elements.ENDPOINT_URL, |
42 | |
AbstractServiceConfiguration.Elements.APPLICATION_ID, |
43 | |
AbstractServiceConfiguration.Elements.INSTANCE_ID, |
44 | |
AbstractServiceConfiguration.Elements.SERVICE_VERSION, |
45 | |
AbstractServiceConfiguration.Elements.TYPE, |
46 | |
AbstractServiceConfiguration.Elements.QUEUE, |
47 | |
AbstractServiceConfiguration.Elements.PRIORITY, |
48 | |
AbstractServiceConfiguration.Elements.RETRY_ATTEMPTS, |
49 | |
AbstractServiceConfiguration.Elements.MILLIS_TO_LIVE, |
50 | |
AbstractServiceConfiguration.Elements.MESSAGE_EXCEPTION_HANDLER, |
51 | |
AbstractServiceConfiguration.Elements.BUS_SECURITY, |
52 | |
AbstractServiceConfiguration.Elements.CREDENTIALS_TYPE, |
53 | |
AbstractServiceConfiguration.Elements.CACHE_MANAGER, |
54 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
55 | |
}) |
56 | |
public abstract class AbstractServiceConfiguration extends AbstractDataTransferObject implements ServiceConfiguration { |
57 | |
|
58 | |
private static final long serialVersionUID = 2681595879406587302L; |
59 | |
|
60 | |
@XmlJavaTypeAdapter(QNameAsStringAdapter.class) |
61 | |
@XmlElement(name = Elements.SERVICE_NAME, required = true) |
62 | |
private final QName serviceName; |
63 | |
|
64 | |
@XmlElement(name = Elements.ENDPOINT_URL, required = true) |
65 | |
private final URL endpointUrl; |
66 | |
|
67 | |
@XmlElement(name = Elements.INSTANCE_ID, required = true) |
68 | |
private final String instanceId; |
69 | |
|
70 | |
@XmlElement(name = Elements.APPLICATION_ID, required = true) |
71 | |
private final String applicationId; |
72 | |
|
73 | |
@XmlElement(name = Elements.SERVICE_VERSION, required = true) |
74 | |
private final String serviceVersion; |
75 | |
|
76 | |
@XmlElement(name = Elements.TYPE, required = true) |
77 | |
private final String type; |
78 | |
|
79 | |
@XmlElement(name = Elements.QUEUE, required = false) |
80 | |
private final boolean queue; |
81 | |
|
82 | |
@XmlElement(name = Elements.PRIORITY, required = false) |
83 | |
private final Integer priority; |
84 | |
|
85 | |
@XmlElement(name = Elements.RETRY_ATTEMPTS, required = false) |
86 | |
private final Integer retryAttempts; |
87 | |
|
88 | |
@XmlElement(name = Elements.MILLIS_TO_LIVE, required = false) |
89 | |
private final Long millisToLive; |
90 | |
|
91 | |
@XmlElement(name = Elements.MESSAGE_EXCEPTION_HANDLER, required = false) |
92 | |
private final String messageExceptionHandler; |
93 | |
|
94 | |
@XmlElement(name = Elements.BUS_SECURITY, required = false) |
95 | |
private final Boolean busSecurity; |
96 | |
|
97 | |
@XmlJavaTypeAdapter(CredentialsTypeAdapter.class) |
98 | |
@XmlElement(name = Elements.CREDENTIALS_TYPE, required = false) |
99 | |
private final String credentialsType; |
100 | |
|
101 | |
@XmlElement(name = Elements.CACHE_MANAGER, required = false) |
102 | |
private final String cacheManager; |
103 | |
|
104 | 0 | @SuppressWarnings("unused") |
105 | |
@XmlAnyElement |
106 | |
private final Collection<Element> _futureElements = null; |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | 0 | protected AbstractServiceConfiguration() { |
112 | 0 | this.serviceName = null; |
113 | 0 | this.endpointUrl = null; |
114 | 0 | this.instanceId = null; |
115 | 0 | this.applicationId = null; |
116 | 0 | this.serviceVersion = null; |
117 | 0 | this.type = null; |
118 | 0 | this.queue = false; |
119 | 0 | this.priority = null; |
120 | 0 | this.retryAttempts = null; |
121 | 0 | this.millisToLive = null; |
122 | 0 | this.messageExceptionHandler = null; |
123 | 0 | this.busSecurity = null; |
124 | 0 | this.credentialsType = null; |
125 | 0 | this.cacheManager = null; |
126 | 0 | } |
127 | |
|
128 | 0 | protected AbstractServiceConfiguration(Builder<?> builder) { |
129 | 0 | this.serviceName = builder.getServiceName(); |
130 | 0 | this.endpointUrl = builder.getEndpointUrl(); |
131 | 0 | this.instanceId = builder.getInstanceId(); |
132 | 0 | this.applicationId = builder.getApplicationId(); |
133 | 0 | this.serviceVersion = builder.getServiceVersion(); |
134 | 0 | this.type = builder.getType(); |
135 | 0 | this.queue = builder.isQueue(); |
136 | 0 | this.priority = builder.getPriority(); |
137 | 0 | this.retryAttempts = builder.getRetryAttempts(); |
138 | 0 | this.millisToLive = builder.getMillisToLive(); |
139 | 0 | this.messageExceptionHandler = builder.getMessageExceptionHandler(); |
140 | 0 | this.busSecurity = builder.getBusSecurity(); |
141 | 0 | CredentialsType cred = builder.getCredentialsType(); |
142 | 0 | this.credentialsType = cred == null ? null : cred.name(); |
143 | 0 | this.cacheManager = builder.getCacheManager(); |
144 | 0 | } |
145 | |
|
146 | |
public QName getServiceName() { |
147 | 0 | return serviceName; |
148 | |
} |
149 | |
|
150 | |
public URL getEndpointUrl() { |
151 | 0 | return endpointUrl; |
152 | |
} |
153 | |
|
154 | |
public String getInstanceId() { |
155 | 0 | return instanceId; |
156 | |
} |
157 | |
|
158 | |
public String getApplicationId() { |
159 | 0 | return applicationId; |
160 | |
} |
161 | |
|
162 | |
public String getServiceVersion() { |
163 | 0 | return serviceVersion; |
164 | |
} |
165 | |
|
166 | |
public String getType() { |
167 | 0 | return type; |
168 | |
} |
169 | |
|
170 | |
public boolean isQueue() { |
171 | 0 | return queue; |
172 | |
} |
173 | |
|
174 | |
public Integer getPriority() { |
175 | 0 | return priority; |
176 | |
} |
177 | |
|
178 | |
public Integer getRetryAttempts() { |
179 | 0 | return retryAttempts; |
180 | |
} |
181 | |
|
182 | |
public Long getMillisToLive() { |
183 | 0 | return millisToLive; |
184 | |
} |
185 | |
|
186 | |
public String getMessageExceptionHandler() { |
187 | 0 | return messageExceptionHandler; |
188 | |
} |
189 | |
|
190 | |
public Boolean getBusSecurity() { |
191 | 0 | return busSecurity; |
192 | |
} |
193 | |
|
194 | |
public CredentialsType getCredentialsType() { |
195 | 0 | if (credentialsType == null) { |
196 | 0 | return null; |
197 | |
} |
198 | 0 | return CredentialsType.valueOf(credentialsType); |
199 | |
} |
200 | |
|
201 | |
public String getCacheManager() { |
202 | 0 | return cacheManager; |
203 | |
} |
204 | |
|
205 | 0 | protected static abstract class Builder<T> implements Serializable { |
206 | |
|
207 | |
private static final long serialVersionUID = -3002495884401672488L; |
208 | |
|
209 | |
private QName serviceName; |
210 | |
private URL endpointUrl; |
211 | |
private String instanceId; |
212 | |
private String applicationId; |
213 | |
private String serviceVersion; |
214 | |
private String type; |
215 | |
private boolean queue; |
216 | |
private Integer priority; |
217 | |
private Integer retryAttempts; |
218 | |
private Long millisToLive; |
219 | |
private String messageExceptionHandler; |
220 | |
private Boolean busSecurity; |
221 | |
private CredentialsType credentialsType; |
222 | |
private String cacheManager; |
223 | |
|
224 | |
public abstract T build(); |
225 | |
|
226 | |
protected void copyServiceDefinitionProperties(ServiceDefinition serviceDefinition) { |
227 | 0 | setServiceName(serviceDefinition.getServiceName()); |
228 | 0 | setEndpointUrl(serviceDefinition.getEndpointUrl()); |
229 | 0 | setApplicationId(serviceDefinition.getApplicationId()); |
230 | 0 | setInstanceId(serviceDefinition.getInstanceId()); |
231 | 0 | setServiceVersion(serviceDefinition.getServiceVersion()); |
232 | 0 | setType(serviceDefinition.getType()); |
233 | 0 | setQueue(serviceDefinition.isQueue()); |
234 | 0 | setPriority(serviceDefinition.getPriority()); |
235 | 0 | setRetryAttempts(serviceDefinition.getRetryAttempts()); |
236 | 0 | setMillisToLive(serviceDefinition.getMillisToLive()); |
237 | 0 | setMessageExceptionHandler(serviceDefinition.getMessageExceptionHandler()); |
238 | 0 | setBusSecurity(serviceDefinition.getBusSecurity()); |
239 | 0 | setCredentialsType(serviceDefinition.getCredentialsType()); |
240 | 0 | setCacheManager(serviceDefinition.getCacheManager()); |
241 | 0 | } |
242 | |
|
243 | |
public QName getServiceName() { |
244 | 0 | return serviceName; |
245 | |
} |
246 | |
public void setServiceName(QName serviceName) { |
247 | 0 | this.serviceName = serviceName; |
248 | 0 | } |
249 | |
public URL getEndpointUrl() { |
250 | 0 | return endpointUrl; |
251 | |
} |
252 | |
public void setEndpointUrl(URL endpointUrl) { |
253 | 0 | this.endpointUrl = endpointUrl; |
254 | 0 | } |
255 | |
public String getInstanceId() { |
256 | 0 | return instanceId; |
257 | |
} |
258 | |
public void setInstanceId(String instanceId) { |
259 | 0 | this.instanceId = instanceId; |
260 | 0 | } |
261 | |
public String getApplicationId() { |
262 | 0 | return applicationId; |
263 | |
} |
264 | |
public void setApplicationId(String applicationId) { |
265 | 0 | this.applicationId = applicationId; |
266 | 0 | } |
267 | |
public String getServiceVersion() { |
268 | 0 | return serviceVersion; |
269 | |
} |
270 | |
public void setServiceVersion(String serviceVersion) { |
271 | 0 | this.serviceVersion = serviceVersion; |
272 | 0 | } |
273 | |
public String getType() { |
274 | 0 | return type; |
275 | |
} |
276 | |
public void setType(String type) { |
277 | 0 | this.type = type; |
278 | 0 | } |
279 | |
public boolean isQueue() { |
280 | 0 | return queue; |
281 | |
} |
282 | |
public void setQueue(boolean queue) { |
283 | 0 | this.queue = queue; |
284 | 0 | } |
285 | |
public Integer getPriority() { |
286 | 0 | return priority; |
287 | |
} |
288 | |
public void setPriority(Integer priority) { |
289 | 0 | this.priority = priority; |
290 | 0 | } |
291 | |
public Integer getRetryAttempts() { |
292 | 0 | return retryAttempts; |
293 | |
} |
294 | |
public void setRetryAttempts(Integer retryAttempts) { |
295 | 0 | this.retryAttempts = retryAttempts; |
296 | 0 | } |
297 | |
public Long getMillisToLive() { |
298 | 0 | return millisToLive; |
299 | |
} |
300 | |
public void setMillisToLive(Long millisToLive) { |
301 | 0 | this.millisToLive = millisToLive; |
302 | 0 | } |
303 | |
public String getMessageExceptionHandler() { |
304 | 0 | return messageExceptionHandler; |
305 | |
} |
306 | |
public void setMessageExceptionHandler(String messageExceptionHandler) { |
307 | 0 | this.messageExceptionHandler = messageExceptionHandler; |
308 | 0 | } |
309 | |
public Boolean getBusSecurity() { |
310 | 0 | return busSecurity; |
311 | |
} |
312 | |
public void setBusSecurity(Boolean busSecurity) { |
313 | 0 | this.busSecurity = busSecurity; |
314 | 0 | } |
315 | |
public CredentialsType getCredentialsType() { |
316 | 0 | return credentialsType; |
317 | |
} |
318 | |
public void setCredentialsType(CredentialsType credentialsType) { |
319 | 0 | this.credentialsType = credentialsType; |
320 | 0 | } |
321 | |
|
322 | |
public String getCacheManager() { |
323 | 0 | return cacheManager; |
324 | |
} |
325 | |
|
326 | |
public void setCacheManager(String cacheManager) { |
327 | 0 | this.cacheManager = cacheManager; |
328 | 0 | } |
329 | |
} |
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | 0 | protected static class Constants { |
335 | |
protected final static String TYPE_NAME = "ServiceConfigurationType"; |
336 | |
} |
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | 0 | protected static class Elements { |
343 | |
protected final static String SERVICE_NAME = "serviceName"; |
344 | |
protected final static String ENDPOINT_URL = "endpointUrl"; |
345 | |
protected final static String INSTANCE_ID = "instanceId"; |
346 | |
protected final static String APPLICATION_ID = "applicationId"; |
347 | |
protected final static String SERVICE_VERSION = "serviceVersion"; |
348 | |
protected final static String TYPE = "type"; |
349 | |
protected final static String QUEUE = "queue"; |
350 | |
protected final static String PRIORITY = "priority"; |
351 | |
protected final static String RETRY_ATTEMPTS = "retryAttempts"; |
352 | |
protected final static String MILLIS_TO_LIVE = "millisToLive"; |
353 | |
protected final static String MESSAGE_EXCEPTION_HANDLER = "messageExceptionHandler"; |
354 | |
protected final static String BUS_SECURITY = "busSecurity"; |
355 | |
protected final static String CREDENTIALS_TYPE = "credentialsType"; |
356 | |
protected final static String CACHE_MANAGER = "cacheManager"; |
357 | |
} |
358 | |
|
359 | 0 | static final class CredentialsTypeAdapter extends EnumStringAdapter<CredentialsType> { |
360 | |
|
361 | |
protected Class<CredentialsType> getEnumClass() { |
362 | 0 | return CredentialsType.class; |
363 | |
} |
364 | |
|
365 | |
} |
366 | |
|
367 | |
} |