1 4 package com.tc.net.core; 5 6 import com.tc.logging.TCLogger; 7 import com.tc.logging.TCLogging; 8 import com.tc.net.core.event.TCListenerEvent; 9 import com.tc.net.core.event.TCListenerEventListener; 10 11 16 abstract class AbstractTCComm implements TCComm, TCListenerEventListener { 17 protected static final TCLogger logger = TCLogging.getLogger(TCComm.class); 18 private volatile boolean started = false; 19 20 public final boolean isStarted() { 21 return started; 22 } 23 24 public final boolean isStopped() { 25 return !started; 26 } 27 28 public final synchronized void start() { 29 if (!started) { 30 started = true; 31 if (logger.isDebugEnabled()) { 32 logger.debug("Start requested"); 33 } 34 35 startImpl(); 36 } 37 } 38 39 public final synchronized void stop() { 40 if (started) { 41 started = false; 42 if (logger.isDebugEnabled()) { 43 logger.debug("Stop requested"); 44 } 45 46 stopImpl(); 47 } 48 } 49 50 public void closeEvent(TCListenerEvent event) { 51 } 53 54 void listenerAdded(TCListener listener) { 55 } 57 58 protected abstract void startImpl(); 59 60 protected abstract void stopImpl(); 61 } | Popular Tags |