Coverage Report - org.kuali.rice.ksb.messaging.service.impl.BusAdminServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BusAdminServiceImpl
0%
0/33
0%
0/12
2.25
 
 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.messaging.service.impl;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 20  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 21  
 import org.kuali.rice.core.api.lifecycle.BaseLifecycle;
 22  
 import org.kuali.rice.ksb.messaging.service.BusAdminService;
 23  
 import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool;
 24  
 
 25  
 
 26  
 /**
 27  
  * Implementation of the Bus Admin service.
 28  
  *
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  0
 public class BusAdminServiceImpl extends BaseLifecycle implements BusAdminService {
 32  
 
 33  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BusAdminServiceImpl.class);
 34  
 
 35  
     private KSBThreadPool threadPool;
 36  
 
 37  
     public void setThreadPool(KSBThreadPool threadPool) {
 38  0
             this.threadPool = threadPool;
 39  0
     }
 40  
     
 41  
     protected KSBThreadPool getThreadPool() {
 42  0
             return this.threadPool;
 43  
     }
 44  
 
 45  
     @Override
 46  
     public void ping() {
 47  0
         LOG.info("ping called");
 48  0
     }
 49  
 
 50  
     @Override
 51  
     public void setCorePoolSize(int corePoolSize) {
 52  0
             if (corePoolSize < 0) {
 53  0
             throw new RiceIllegalArgumentException("corePoolSize < 0");
 54  
         }
 55  
 
 56  0
         LOG.info("Setting core pool size to " + corePoolSize);
 57  0
             getThreadPool().setCorePoolSize(corePoolSize);
 58  0
     }
 59  
 
 60  
     @Override
 61  
     public void setMaximumPoolSize(int maxPoolSize) {
 62  0
             if (maxPoolSize < 0) {
 63  0
             throw new RiceIllegalArgumentException("maxPoolSize < 0");
 64  
         }
 65  0
             LOG.info("Setting max pool size to " + maxPoolSize);
 66  0
             if (maxPoolSize < getThreadPool().getCorePoolSize()) {
 67  0
                     maxPoolSize = getThreadPool().getCorePoolSize();
 68  
             }
 69  0
             getThreadPool().setMaximumPoolSize(maxPoolSize);
 70  0
     }
 71  
 
 72  
     @Override
 73  
     public void setConfigProperty(String propertyName, String propertyValue) {
 74  0
             if (StringUtils.isBlank(propertyName)) {
 75  0
             throw new RiceIllegalArgumentException("propertyName is null or blank");
 76  
         }
 77  
 
 78  0
         String originalValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
 79  0
             LOG.info("Changing config property '" + propertyName + "' from " + originalValue + " to " + propertyValue);
 80  0
             if (propertyValue == null) {
 81  0
                     ConfigContext.getCurrentContextConfig().removeProperty(propertyName);
 82  
             } else {
 83  0
                     ConfigContext.getCurrentContextConfig().putProperty(propertyName, propertyValue);
 84  
             }
 85  0
     }
 86  
 
 87  
     @Override
 88  
     public void start() throws Exception {
 89  0
             if (getThreadPool() == null) {
 90  0
                     throw new IllegalStateException("The threadPool has not been set on the busAdminService");
 91  
             }
 92  0
             setStarted(true);
 93  0
     }
 94  
 
 95  
     @Override
 96  
     public void stop() throws Exception {
 97  0
             setStarted(false);
 98  0
     }
 99  
 
 100  
 }