package org.jboss.mq.server.jmx;
import org.jboss.mq.server.JMSServerInterceptor;
public class ClientMonitorInterceptor
extends InterceptorMBeanSupport
implements ClientMonitorInterceptorMBean {
private org.jboss.mq.server.ClientMonitorInterceptor interceptor =
new org.jboss.mq.server.ClientMonitorInterceptor();
long clientTimeout = 1000 * 60;
Thread serviceThread;
public JMSServerInterceptor getInterceptor() {
return interceptor;
}
public long getClientTimeout() {
return clientTimeout;
}
public void setClientTimeout(long clientTimeout) {
this.clientTimeout = clientTimeout;
}
protected void startService() throws Exception {
super.startService();
if( serviceThread != null )
return;
serviceThread = new Thread(new Runnable() {
public void run() {
try {
while(true) {
Thread.sleep(clientTimeout);
interceptor.disconnectInactiveClients(
System.currentTimeMillis() - clientTimeout);
}
} catch (InterruptedException e) {
}
}
}, "ClientMonitor Service Thread");
serviceThread.setDaemon(true);
serviceThread.start();
}
protected void stopService() throws Exception {
if (serviceThread != null) {
serviceThread.interrupt();
serviceThread = null;
}
super.stopService();
}
}