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