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 | 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 | |
|
42 | 0 | AsynchronousCall methodCall = message.getPayload().getMethodCall(); |
43 | 0 | message.setMethodCall(methodCall); |
44 | |
|
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 | |
} |