1 22 package org.jboss.mq.server.jmx; 23 24 import org.jboss.mq.server.JMSServerInterceptor; 25 26 33 public class ClientMonitorInterceptor 34 extends InterceptorMBeanSupport 35 implements ClientMonitorInterceptorMBean { 36 37 private org.jboss.mq.server.ClientMonitorInterceptor interceptor = 38 new org.jboss.mq.server.ClientMonitorInterceptor(); 39 40 long clientTimeout = 1000 * 60; 41 Thread serviceThread; 42 43 public JMSServerInterceptor getInterceptor() { 44 return interceptor; 45 } 46 47 52 public long getClientTimeout() { 53 return clientTimeout; 54 } 55 56 61 public void setClientTimeout(long clientTimeout) { 62 this.clientTimeout = clientTimeout; 63 } 64 65 68 protected void startService() throws Exception { 69 super.startService(); 70 if( serviceThread != null ) 71 return; 72 73 serviceThread = new Thread (new Runnable () { 74 public void run() { 75 try { 76 while(true) { 77 Thread.sleep(clientTimeout); 78 interceptor.disconnectInactiveClients( 79 System.currentTimeMillis() - clientTimeout); 80 } 81 } catch (InterruptedException e) { 82 } 83 } 84 }, "ClientMonitor Service Thread"); 85 serviceThread.setDaemon(true); 86 serviceThread.start(); 87 } 88 89 92 protected void stopService() throws Exception { 93 if (serviceThread != null) { 94 serviceThread.interrupt(); 95 serviceThread = null; 96 } 97 super.stopService(); 98 } 99 100 } 101 | Popular Tags |