1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.messaging.serviceconnectors; |
17 | |
|
18 | |
import java.net.URL; |
19 | |
|
20 | |
import org.kuali.rice.core.api.security.credentials.CredentialsSource; |
21 | |
import org.kuali.rice.ksb.api.bus.ServiceConfiguration; |
22 | |
import org.kuali.rice.ksb.messaging.BusClientFailureProxy; |
23 | |
import org.kuali.rice.ksb.messaging.bam.BAMClientProxy; |
24 | |
import org.springframework.util.Assert; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public abstract class AbstractServiceConnector implements ServiceConnector { |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
private ServiceConfiguration serviceConfiguration; |
41 | |
private URL alternateEndpointUrl; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
private CredentialsSource credentialsSource; |
47 | |
|
48 | |
public AbstractServiceConnector(final ServiceConfiguration serviceConfiguration) { |
49 | 0 | this(serviceConfiguration, null); |
50 | 0 | } |
51 | |
|
52 | 0 | public AbstractServiceConnector(final ServiceConfiguration serviceConfiguration, URL alternateEndpointUrl) { |
53 | 0 | Assert.notNull(serviceConfiguration, "serviceConfiguration cannot be null"); |
54 | 0 | this.serviceConfiguration = serviceConfiguration; |
55 | 0 | this.alternateEndpointUrl = alternateEndpointUrl; |
56 | 0 | } |
57 | |
|
58 | |
public URL getActualEndpointUrl() { |
59 | 0 | if (alternateEndpointUrl != null) { |
60 | 0 | return alternateEndpointUrl; |
61 | |
} |
62 | 0 | return getServiceConfiguration().getEndpointUrl(); |
63 | |
} |
64 | |
|
65 | |
public ServiceConfiguration getServiceConfiguration() { |
66 | 0 | return this.serviceConfiguration; |
67 | |
} |
68 | |
|
69 | |
public void setCredentialsSource(final CredentialsSource credentialsSource) { |
70 | 0 | this.credentialsSource = credentialsSource; |
71 | 0 | } |
72 | |
|
73 | |
protected CredentialsSource getCredentialsSource() { |
74 | 0 | return this.credentialsSource; |
75 | |
} |
76 | |
|
77 | |
protected Object getServiceProxyWithFailureMode(final Object service, |
78 | |
final ServiceConfiguration serviceConfiguration) { |
79 | 0 | Object bamWrappedClientProxy = BAMClientProxy.wrap(service, serviceConfiguration); |
80 | 0 | return BusClientFailureProxy.wrap(bamWrappedClientProxy, serviceConfiguration); |
81 | |
} |
82 | |
} |