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