1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
31
32
33
34 public class BusAdminServiceImpl extends BaseLifecycle implements BusAdminService {
35
36 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
42 AsynchronousCall methodCall = message.getPayload().getMethodCall();
43 message.setMethodCall(methodCall);
44
45 new ForwardedCallHandlerImpl().handleCall(message);
46 }
47
48 public void ping() {
49 }
50
51 public void setCorePoolSize(int corePoolSize) {
52 LOG.info("Setting core pool size to " + corePoolSize);
53 KSBServiceLocator.getThreadPool().setCorePoolSize(corePoolSize);
54 }
55
56 public void setMaximumPoolSize(int maxPoolSize) {
57 LOG.info("Setting max pool size to " + maxPoolSize);
58 KSBThreadPool threadPool = KSBServiceLocator.getThreadPool();
59 if (maxPoolSize < threadPool.getCorePoolSize()) {
60 maxPoolSize = threadPool.getCorePoolSize();
61 }
62 threadPool.setMaximumPoolSize(maxPoolSize);
63 }
64
65 public void setConfigProperty(String propertyName, String propertyValue) {
66 String originalValue = ConfigContext.getCurrentContextConfig().getProperty(propertyName);
67 LOG.info("Changing config property '" + propertyName + "' from " + originalValue + " to " + propertyValue);
68 if (propertyValue == null) {
69 ConfigContext.getCurrentContextConfig().removeProperty(propertyName);
70 } else {
71 ConfigContext.getCurrentContextConfig().putProperty(propertyName, propertyValue);
72 }
73 }
74
75 public void start() throws Exception {
76 this.defRegisterer = new ServiceBasedServiceDefinitionRegisterer("ksb.busAdminServiceDefinition");
77 this.defRegisterer.registerServiceDefinition(false);
78 setStarted(true);
79 }
80
81 public void stop() throws Exception {
82 this.defRegisterer.unregisterServiceDefinition();
83 setStarted(false);
84 }
85
86 }