com.javageeks.gjas.services
Class HeartbeatService

java.lang.Object
  |
  +--com.javageeks.gjas.services.ThreadedServer
        |
        +--com.javageeks.gjas.services.SocketServer
              |
              +--com.javageeks.gjas.services.HeartbeatService
All Implemented Interfaces:
java.io.Serializable, Service

public class HeartbeatService
extends SocketServer

HeartbeatService sends a message to any listening clients every n milliseconds. Put basically, this is the same publish- subscribe behavior found in a variety of other places, such as AWT/Swing's Event-EventListener system. This concept isn't necessarily limited solely to socket-based communication--this could easily be adapted to other forms of communicative technology, like RMI, CORBA, JMS, Mobile Objects, and so on.

See Also:
Serialized Form

Fields inherited from class com.javageeks.gjas.services.SocketServer
m_serverSocket, PORT_PROP, TIMEOUT_PROP
 
Fields inherited from class com.javageeks.gjas.services.ThreadedServer
m_paused, m_shouldStop
 
Fields inherited from interface com.javageeks.gjas.Service
PAUSED, PAUSING, RESUMING, RUNNING, STARTING, STOPPED, STOPPING
 
Constructor Summary
HeartbeatService()
           
HeartbeatService(int port, int interval, java.lang.String pingMsg)
           
 
Method Summary
 ConfigProperties getConfigInfo()
          Return the Properties configuration information
 void serve(java.net.Socket socket)
          Derived services must override this method.
 void setConfigInfo(ConfigProperties props)
          Set the Properties configuration information
 void start()
          Start the SocketServer
 void stop()
          Stop the Service.
 
Methods inherited from class com.javageeks.gjas.services.SocketServer
getPort, setPort
 
Methods inherited from class com.javageeks.gjas.services.ThreadedServer
getInstanceID, getState, getThread, isPaused, kill, pause, resume, setRunnable, setState, setThread, shouldStop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeartbeatService

public HeartbeatService(int port,
                        int interval,
                        java.lang.String pingMsg)

HeartbeatService

public HeartbeatService()
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from class: SocketServer
Start the SocketServer
Overrides:
start in class SocketServer

stop

public void stop()
          throws java.lang.Exception
Description copied from interface: Service
Stop the Service.
Overrides:
stop in class SocketServer

getConfigInfo

public ConfigProperties getConfigInfo()
Description copied from interface: Service
Return the Properties configuration information
Overrides:
getConfigInfo in class SocketServer

setConfigInfo

public void setConfigInfo(ConfigProperties props)
Description copied from interface: Service
Set the Properties configuration information
Overrides:
setConfigInfo in class SocketServer

serve

public void serve(java.net.Socket socket)
           throws java.lang.Exception
Derived services must override this method. Once a client has connected to us, this method is called to "do the work" of handling the connection.
Overrides:
serve in class SocketServer