01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.iu.uis.eden.messaging.threadpool;
17:
18: import org.apache.log4j.Logger;
19: import org.kuali.rice.RiceConstants;
20: import org.kuali.rice.core.Core;
21:
22: import edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor;
23:
24: public class KSBScheduledThreadPoolExecutor extends
25: ScheduledThreadPoolExecutor implements KSBScheduledPool {
26:
27: private static final Logger LOG = Logger
28: .getLogger(KSBScheduledThreadPoolExecutor.class);
29:
30: private boolean started;
31: private static final int DEFAULT_SIZE = 2;
32:
33: public KSBScheduledThreadPoolExecutor() {
34: super (DEFAULT_SIZE);
35: }
36:
37: public boolean isStarted() {
38: return started;
39: }
40:
41: public void start() throws Exception {
42: LOG.info("starting "
43: + KSBScheduledThreadPoolExecutor.class.getSimpleName());
44: try {
45: Integer size = new Integer(Core.getCurrentContextConfig()
46: .getProperty(RiceConstants.FIXED_POOL_SIZE));
47: this .setCorePoolSize(size);
48: } catch (NumberFormatException nfe) {
49:
50: }
51: }
52:
53: public void stop() throws Exception {
54: LOG.info("stopping "
55: + KSBScheduledThreadPoolExecutor.class.getSimpleName());
56: try {
57: this .shutdownNow();
58: } catch (Exception e) {
59: LOG.warn("Exception thrown shutting down "
60: + KSBScheduledThreadPoolExecutor.class
61: .getSimpleName(), e);
62: }
63:
64: }
65:
66: }
|