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