1 7 package org.jboss.jms.serverless; 8 9 import org.jboss.logging.Logger; 10 11 20 public class ConnectionState { 21 22 private static final Logger log = Logger.getLogger(ConnectionState.class); 23 24 public static final int DISCONNECTED = 0; 25 public static final int STOPPED = 1; 26 public static final int STARTED = 2; 27 public static final int CLOSED = 3; 28 29 private int state; 30 31 public ConnectionState() { 32 state = DISCONNECTED; 33 } 34 35 public synchronized boolean isDisconnected() { 36 return state == DISCONNECTED; 37 } 38 39 public synchronized boolean isStopped() { 40 return state == STOPPED; 41 } 42 43 public synchronized boolean isStarted() { 44 return state == STARTED; 45 } 46 47 public synchronized boolean isClosed() { 48 return state == CLOSED; 49 } 50 51 54 public synchronized void setStopped() { 55 state = STOPPED; 56 } 57 58 public synchronized void setStarted() { 59 state = STARTED; 60 } 61 62 public synchronized void setClosed() { 63 state = CLOSED; 64 } 65 66 public static String stateToString(ConnectionState cs) { 67 return 68 cs.state == DISCONNECTED ? "DISCONNECTED" : 69 cs.state == STOPPED ? "STOPPED" : 70 cs.state == STARTED ? "STARTED" : 71 cs.state == CLOSED ? "CLOSED" : "UNKNOWN"; 72 } 73 74 75 } 76 | Popular Tags |