Coverage Report - org.kuali.rice.ksb.api.bus.support.ServiceBusExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceBusExporter
0%
0/24
0%
0/8
1.75
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
  * Used from Spring to register service definitions from an already configured and started KSB.
 25  
  * 
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
 }