com.kuka.comm
Class AbstractThreadedServer

java.lang.Object
  extended by com.kuka.comm.AbstractServer
      extended by com.kuka.comm.AbstractThreadedServer
All Implemented Interfaces:
Server
Direct Known Subclasses:
TcpServer, UdpServer

public abstract class AbstractThreadedServer
extends AbstractServer

Abstract class to implement interface methods for a Server. Needs to be derived by a more Connection -specific version of server.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.kuka.comm.AbstractServer
AbstractServer.ConnectionConsumer
 
Constructor Summary
AbstractThreadedServer()
           
 
Method Summary
 boolean isRunning()
          Checks whenever the server thread is currently active.
protected  boolean isStopRequested()
          Server specific method to check if server is going to stop.
protected  boolean isThreadAlive()
          Return true of the server thread is running.
protected abstract  void serverThread()
          Implement the server thread!
protected  void setStopRequested(boolean stopRequested)
          Server method to stop during next cycle.
 void start()
          Starts the server as a separate thread.
 void stop()
          Stops the server closes all created connections listed in its internal list of connections.
 
Methods inherited from class com.kuka.comm.AbstractServer
addConnection, addServerListener, closeAllConnections, countConnections, fireAcceptedConnection, fireIncomingConnection, fireRejectedConnection, forEachConnection, getConnections, hasConnections, removeConnection, removeServerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractThreadedServer

public AbstractThreadedServer()
Method Detail

start

public void start()
Description copied from interface: Server
Starts the server as a separate thread.


stop

public void stop()
Description copied from interface: Server
Stops the server closes all created connections listed in its internal list of connections.


isRunning

public boolean isRunning()
Checks whenever the server thread is currently active.

The default way of determining if the server is running, is to check if the thread is running. Subclasses may overwrite this, if their thread could also be running even if they are not 'officially' running (e.g. 'stop' as been requested, but their thread needs to keep running).

Returns:
true if server thread is running, false otherwise.

isThreadAlive

protected final boolean isThreadAlive()
Return true of the server thread is running.

Returns:
true of the server thread is running

setStopRequested

protected final void setStopRequested(boolean stopRequested)
Server method to stop during next cycle.

Parameters:
stopRequested - true if server should stop.

isStopRequested

protected final boolean isStopRequested()
Server specific method to check if server is going to stop.

Returns:
True if server is going to stop, false otherwise.

serverThread

protected abstract void serverThread()
Implement the server thread!



Copyright © 2019. All rights reserved.