1 18 package org.apache.activemq.transport; 19 20 21 import org.apache.activemq.ThreadPriorities; 22 import org.apache.activemq.util.ServiceStopper; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 import java.net.URI ; 27 28 34 public abstract class TransportServerThreadSupport extends TransportServerSupport implements Runnable { 35 private static final Log log = LogFactory.getLog(TransportServerThreadSupport.class); 36 37 private boolean daemon = true; 38 private boolean joinOnStop = true; 39 private Thread runner; 40 private long stackSize=0; 42 public TransportServerThreadSupport() { 43 } 44 45 public TransportServerThreadSupport(URI location) { 46 super(location); 47 } 48 49 public boolean isDaemon() { 50 return daemon; 51 } 52 53 56 public void setDaemon(boolean daemon) { 57 this.daemon = daemon; 58 } 59 60 61 public boolean isJoinOnStop() { 62 return joinOnStop; 63 } 64 65 68 public void setJoinOnStop(boolean joinOnStop) { 69 this.joinOnStop = joinOnStop; 70 } 71 72 protected void doStart() throws Exception { 73 log.info("Listening for connections at: " + getConnectURI()); 74 runner = new Thread (null,this, "ActiveMQ Transport Server: "+toString(),stackSize); 75 runner.setDaemon(daemon); 76 runner.setPriority(ThreadPriorities.BROKER_MANAGEMENT); 77 runner.start(); 78 } 79 80 protected void doStop(ServiceStopper stopper) throws Exception { 81 if (runner != null && joinOnStop) { 82 runner.join(); 83 runner = null; 84 } 85 } 86 87 88 91 public long getStackSize(){ 92 return this.stackSize; 93 } 94 95 96 99 public void setStackSize(long stackSize){ 100 this.stackSize=stackSize; 101 } 102 } 103 | Popular Tags |