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