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.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 | |
|
28 | |
|
29 | |
|
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 | |
} |