Coverage Report - org.kuali.rice.ksb.messaging.service.impl.BusAdminServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BusAdminServiceImpl
0%
0/29
0%
0/4
1.286
 
 1  
 /*
 2  
  * Copyright 2007 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.messaging.service.impl;
 17  
 
 18  
 import org.kuali.rice.core.config.ConfigContext;
 19  
 import org.kuali.rice.core.lifecycle.BaseLifecycle;
 20  
 import org.kuali.rice.ksb.messaging.AsynchronousCall;
 21  
 import org.kuali.rice.ksb.messaging.PersistedMessage;
 22  
 import org.kuali.rice.ksb.messaging.callforwarding.ForwardedCallHandlerImpl;
 23  
 import org.kuali.rice.ksb.messaging.config.ServiceBasedServiceDefinitionRegisterer;
 24  
 import org.kuali.rice.ksb.messaging.service.BusAdminService;
 25  
 import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool;
 26  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 27  
 
 28  
 
 29  
 /**
 30  
  * Implementation of the Bus Admin service.
 31  
  *
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class BusAdminServiceImpl extends BaseLifecycle implements BusAdminService {
 35  
 
 36  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BusAdminServiceImpl.class);
 37  
 
 38  
     private ServiceBasedServiceDefinitionRegisterer defRegisterer;
 39  
 
 40  
     public void forward(PersistedMessage message) throws Exception {
 41  
         // this is just weird...
 42  0
         AsynchronousCall methodCall = message.getPayload().getMethodCall();
 43  0
         message.setMethodCall(methodCall);
 44  
         // TODO there's probably a better way to servisize or refactor this
 45  0
         new ForwardedCallHandlerImpl().handleCall(message);
 46  0
     }
 47  
 
 48  
     public void ping() {
 49  0
     }
 50  
 
 51  
     public void setCorePoolSize(int corePoolSize) {
 52  0
         LOG.info("Setting core pool size to " + corePoolSize);
 53  0
         KSBServiceLocator.getThreadPool().setCorePoolSize(corePoolSize);
 54  0
     }
 55  
 
 56  
     public void setMaximumPoolSize(int maxPoolSize) {
 57  0
         LOG.info("Setting max pool size to " + maxPoolSize);
 58  0
         KSBThreadPool threadPool = KSBServiceLocator.getThreadPool();
 59  0
         if (maxPoolSize < threadPool.getCorePoolSize()) {
 60  0
             maxPoolSize = threadPool.getCorePoolSize();
 61  
         }
 62  0
         threadPool.setMaximumPoolSize(maxPoolSize);
 63  0
     }
 64  
 
 65  
     public void setConfigProperty(String propertyName, String propertyValue) {
 66  0
         String originalValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
 67  0
         LOG.info("Changing config property '" + propertyName + "' from " + originalValue + " to " + propertyValue);
 68  0
         if (propertyValue == null) {
 69  0
             ConfigContext.getCurrentContextConfig().removeProperty(propertyName);
 70  
         } else {
 71  0
             ConfigContext.getCurrentContextConfig().putProperty(propertyName, propertyValue);
 72  
         }
 73  0
     }
 74  
 
 75  
     public void start() throws Exception {
 76  0
         this.defRegisterer = new ServiceBasedServiceDefinitionRegisterer("ksb.busAdminServiceDefinition");
 77  0
         this.defRegisterer.registerServiceDefinition(false);
 78  0
         setStarted(true);
 79  0
     }
 80  
 
 81  
     public void stop() throws Exception {
 82  0
         this.defRegisterer.unregisterServiceDefinition();
 83  0
         setStarted(false);
 84  0
     }
 85  
 
 86  
 }