1 45 46 package org.exolab.jms.service; 47 48 import org.apache.commons.logging.LogFactory; 49 import org.apache.commons.logging.Log; 50 51 52 61 public abstract class BasicService extends Service implements Runnable { 62 63 66 private transient Thread _thread = null; 67 68 71 protected BasicService() { 72 } 73 74 79 protected BasicService(String name) { 80 super(name); 81 } 82 83 89 public synchronized void start() throws ServiceException { 90 super.start(); 91 _thread = new Thread (this, getName()); 92 _thread.start(); 93 } 94 95 101 public synchronized void stop() throws ServiceException { 102 if (_thread != null) { 103 setState(ServiceState.STOPPED); 104 _thread.interrupt(); 105 _thread = null; 106 } else { 107 throw new ServiceException("Failed to stop service " + this); 108 } 109 } 110 111 116 public String toString() { 117 StringBuffer buf = new StringBuffer ("BasicService:["); 118 buf.append("name="); 119 buf.append(getName()); 120 buf.append("thread="); 121 buf.append(_thread); 122 buf.append("state="); 123 buf.append(getState()); 124 buf.append("]"); 125 return buf.toString(); 126 } 127 128 } 129 | Popular Tags |