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 this(serviceConfiguration, null);
50 }
51
52 public AbstractServiceConnector(final ServiceConfiguration serviceConfiguration, URL alternateEndpointUrl) {
53 Assert.notNull(serviceConfiguration, "serviceConfiguration cannot be null");
54 this.serviceConfiguration = serviceConfiguration;
55 this.alternateEndpointUrl = alternateEndpointUrl;
56 }
57
58 public URL getActualEndpointUrl() {
59 if (alternateEndpointUrl != null) {
60 return alternateEndpointUrl;
61 }
62 return getServiceConfiguration().getEndpointUrl();
63 }
64
65 public ServiceConfiguration getServiceConfiguration() {
66 return this.serviceConfiguration;
67 }
68
69 public void setCredentialsSource(final CredentialsSource credentialsSource) {
70 this.credentialsSource = credentialsSource;
71 }
72
73 protected CredentialsSource getCredentialsSource() {
74 return this.credentialsSource;
75 }
76
77 protected Object getServiceProxyWithFailureMode(final Object service,
78 final ServiceConfiguration serviceConfiguration) {
79 Object bamWrappedClientProxy = BAMClientProxy.wrap(service, serviceConfiguration);
80 return BusClientFailureProxy.wrap(bamWrappedClientProxy, serviceConfiguration);
81 }
82 }