1 17 18 package org.apache.geronimo.pool; 19 20 import EDU.oswego.cs.dl.util.concurrent.ClockDaemon; 21 import EDU.oswego.cs.dl.util.concurrent.ThreadFactory; 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 import org.apache.geronimo.gbean.GBeanInfo; 25 import org.apache.geronimo.gbean.GBeanInfoBuilder; 26 import org.apache.geronimo.gbean.GBeanLifecycle; 27 28 31 public class ClockPool implements GBeanLifecycle { 32 33 static private final Log log = LogFactory.getLog(ClockPool.class); 34 35 private String poolName; 36 37 41 protected ClockDaemon clockDaemon; 42 43 public String getPoolName() { 44 return poolName; 45 } 46 47 public void setPoolName(String poolName) { 48 this.poolName = poolName; 49 } 50 51 public ClockDaemon getClockDaemon() { 52 return clockDaemon; 53 } 54 55 public void doStart() throws Exception { 56 clockDaemon = new ClockDaemon(); 57 clockDaemon.setThreadFactory(new ThreadFactory() { 58 public Thread newThread(Runnable r) { 59 Thread t = new Thread (r, poolName + " "); 60 t.setDaemon(true); 61 return t; 62 } 63 }); 64 log.info("Clock pool " + poolName + " started"); 65 } 66 67 public void doStop() throws Exception { 68 clockDaemon.shutDown(); 69 log.info("Clock pool " + poolName + " stopped"); 70 } 71 72 public void doFail() { 73 } 74 75 private static final GBeanInfo GBEAN_INFO; 76 77 static { 78 GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(ClockPool.class); 79 80 infoFactory.addAttribute("poolName", String .class, true); 81 82 infoFactory.addOperation("getClockDaemon"); 83 84 GBEAN_INFO = infoFactory.getBeanInfo(); 85 } 86 87 public static GBeanInfo getGBeanInfo() { 88 return GBEAN_INFO; 89 } 90 } 91 | Popular Tags |