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.ksb.api.KsbApiServiceLocator; |
19 | |
import org.kuali.rice.ksb.api.bus.ServiceBus; |
20 | |
import org.kuali.rice.ksb.api.bus.ServiceDefinition; |
21 | |
import org.springframework.beans.factory.InitializingBean; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 0 | public class ServiceBusExporter implements InitializingBean { |
29 | |
|
30 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ServiceBusExporter.class); |
31 | |
|
32 | |
private ServiceDefinition serviceDefinition; |
33 | 0 | private boolean forceSync = false; |
34 | |
private ServiceBus serviceBus; |
35 | |
|
36 | |
public void afterPropertiesSet() { |
37 | 0 | if (getServiceDefinition() == null) { |
38 | 0 | throw new IllegalStateException("serviceDefinition must be set"); |
39 | |
} |
40 | 0 | getServiceDefinition().validate(); |
41 | 0 | if ( LOG.isInfoEnabled() ) { |
42 | 0 | LOG.info("Attempting to export service with service name '" + getServiceDefinition().getServiceName()); |
43 | |
} |
44 | 0 | if (getServiceBus() == null) { |
45 | 0 | setServiceBus(autoLocateServiceBus()); |
46 | |
} |
47 | 0 | if (getServiceBus() == null) { |
48 | 0 | throw new IllegalStateException("serviceBus could not be located and was not set, must not be null"); |
49 | |
} |
50 | 0 | getServiceBus().publishService(getServiceDefinition(), forceSync); |
51 | 0 | } |
52 | |
|
53 | |
protected ServiceBus autoLocateServiceBus() { |
54 | 0 | return KsbApiServiceLocator.getServiceBus(); |
55 | |
} |
56 | |
|
57 | |
public ServiceDefinition getServiceDefinition() { |
58 | 0 | return this.serviceDefinition; |
59 | |
} |
60 | |
|
61 | |
public void setServiceDefinition(ServiceDefinition serviceDefinition) { |
62 | 0 | this.serviceDefinition = serviceDefinition; |
63 | 0 | } |
64 | |
|
65 | |
public boolean isForceSync() { |
66 | 0 | return this.forceSync; |
67 | |
} |
68 | |
|
69 | |
public void setForceRefresh(boolean forceSync) { |
70 | 0 | this.forceSync = forceSync; |
71 | 0 | } |
72 | |
|
73 | |
public ServiceBus getServiceBus() { |
74 | 0 | return this.serviceBus; |
75 | |
} |
76 | |
|
77 | |
public void setServiceBus(ServiceBus serviceBus) { |
78 | 0 | this.serviceBus = serviceBus; |
79 | 0 | } |
80 | |
|
81 | |
} |