| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.ksb.messaging.service.impl; |
| 18 | |
|
| 19 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 20 | |
import org.kuali.rice.core.api.lifecycle.BaseLifecycle; |
| 21 | |
import org.kuali.rice.core.api.lifecycle.BaseLifecycle; |
| 22 | |
import org.kuali.rice.ksb.messaging.AsynchronousCall; |
| 23 | |
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
| 24 | |
import org.kuali.rice.ksb.messaging.callforwarding.ForwardedCallHandlerImpl; |
| 25 | |
import org.kuali.rice.ksb.messaging.config.ServiceBasedServiceDefinitionRegisterer; |
| 26 | |
import org.kuali.rice.ksb.messaging.service.BusAdminService; |
| 27 | |
import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool; |
| 28 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | 0 | public class BusAdminServiceImpl extends BaseLifecycle implements BusAdminService { |
| 37 | |
|
| 38 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BusAdminServiceImpl.class); |
| 39 | |
|
| 40 | |
private ServiceBasedServiceDefinitionRegisterer defRegisterer; |
| 41 | |
|
| 42 | |
public void forward(PersistedMessageBO message) throws Exception { |
| 43 | |
|
| 44 | 0 | AsynchronousCall methodCall = message.getPayload().getMethodCall(); |
| 45 | 0 | message.setMethodCall(methodCall); |
| 46 | |
|
| 47 | 0 | new ForwardedCallHandlerImpl().handleCall(message); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
public void ping() { |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
public void setCorePoolSize(int corePoolSize) { |
| 54 | 0 | LOG.info("Setting core pool size to " + corePoolSize); |
| 55 | 0 | KSBServiceLocator.getThreadPool().setCorePoolSize(corePoolSize); |
| 56 | 0 | } |
| 57 | |
|
| 58 | |
public void setMaximumPoolSize(int maxPoolSize) { |
| 59 | 0 | LOG.info("Setting max pool size to " + maxPoolSize); |
| 60 | 0 | KSBThreadPool threadPool = KSBServiceLocator.getThreadPool(); |
| 61 | 0 | if (maxPoolSize < threadPool.getCorePoolSize()) { |
| 62 | 0 | maxPoolSize = threadPool.getCorePoolSize(); |
| 63 | |
} |
| 64 | 0 | threadPool.setMaximumPoolSize(maxPoolSize); |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
public void setConfigProperty(String propertyName, String propertyValue) { |
| 68 | 0 | String originalValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName); |
| 69 | 0 | LOG.info("Changing config property '" + propertyName + "' from " + originalValue + " to " + propertyValue); |
| 70 | 0 | if (propertyValue == null) { |
| 71 | 0 | ConfigContext.getCurrentContextConfig().removeProperty(propertyName); |
| 72 | |
} else { |
| 73 | 0 | ConfigContext.getCurrentContextConfig().putProperty(propertyName, propertyValue); |
| 74 | |
} |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
public void start() throws Exception { |
| 78 | 0 | this.defRegisterer = new ServiceBasedServiceDefinitionRegisterer("ksb.busAdminServiceDefinition"); |
| 79 | 0 | this.defRegisterer.registerServiceDefinition(false); |
| 80 | 0 | setStarted(true); |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
public void stop() throws Exception { |
| 84 | 0 | this.defRegisterer.unregisterServiceDefinition(); |
| 85 | 0 | setStarted(false); |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
} |