ikrs.yuccasrv
Class TCPAdapter

java.lang.Object
  extended by ikrs.yuccasrv.ConnectionHandler
      extended by ikrs.yuccasrv.TCPAdapter
All Implemented Interfaces:
ObjectWithUUID, BindListener
Direct Known Subclasses:
HTTPHandler

public abstract class TCPAdapter
extends ConnectionHandler


Constructor Summary
TCPAdapter()
           
 
Method Summary
abstract  void finalize(long time, java.util.concurrent.TimeUnit unit)
          This method will be called if the SocketManager is going to terminate.
abstract  void init(Environment<java.lang.String,BasicType> additionalSettings, Environment<java.lang.String,BasicType> optionalReturnValues)
          This method will be called after the connection handler was instantiated (usually using the Class.newInstance() method).
abstract  void serverAcceptedTCPConnection(BindManager source, java.util.UUID socketID, java.net.Socket sock, ConnectionUserID<ConnectionUserID> userID)
           
 void serverAcceptedUDPConnection(BindManager source, java.util.UUID socketID, java.net.DatagramSocket sock, ConnectionUserID<ConnectionUserID> userID)
          This method is not meant to be called as this is a _TCP_ handler.
 void serverClosed(BindManager source, java.util.UUID socketID)
          This method does nothing except forwarding the INFO to the global logger instance via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ...
 void serverCreated(BindManager source, java.util.UUID socketID)
          This method does nothing except forwarding an INFO/WARNING to the global logger instance via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ...
 void serverError(BindManager source, java.util.UUID socketID, java.lang.Exception e, boolean isTraumatic)
          This method simply logs a SEVERE error to the global Logger via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ...
 
Methods inherited from class ikrs.yuccasrv.ConnectionHandler
getUUID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPAdapter

public TCPAdapter()
Method Detail

init

public abstract void init(Environment<java.lang.String,BasicType> additionalSettings,
                          Environment<java.lang.String,BasicType> optionalReturnValues)
                   throws java.lang.InstantiationException
This method will be called after the connection handler was instantiated (usually using the Class.newInstance() method). Both params might be null or empty depending on the underlying interface implementation. This method must throw an InstantiationException if any required params are missing.

Specified by:
init in class ConnectionHandler
Parameters:
additionalSettings - An environment containing additional initialization params. Might be null or empty.
optionalReturnValues - An environment the method may use to store (optional) return values in. May be null.
Throws:
java.lang.InstantiationException

serverCreated

public void serverCreated(BindManager source,
                          java.util.UUID socketID)
This method does nothing except forwarding an INFO/WARNING to the global logger instance via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ... ).

Specified by:
serverCreated in interface BindListener
Overrides:
serverCreated in class ConnectionHandler
Parameters:
source - The BindManager that reports the event.
socketID - A unique ID to identify the created socket by the use of BindManager.getServer*( socketID ).

serverError

public void serverError(BindManager source,
                        java.util.UUID socketID,
                        java.lang.Exception e,
                        boolean isTraumatic)
This method simply logs a SEVERE error to the global Logger via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ... ).

Specified by:
serverError in interface BindListener
Overrides:
serverError in class ConnectionHandler
Parameters:
source - The BindManager that reports the event.
socketID - The server's unique ID.
e - The reported exception.
isTraumatic - This flag tell if the server socket can still be used or if it's (probably) broken and should be restarted. In the second case the BindManager will automatically close and remove the socket to free the resources.

serverAcceptedTCPConnection

public abstract void serverAcceptedTCPConnection(BindManager source,
                                                 java.util.UUID socketID,
                                                 java.net.Socket sock,
                                                 ConnectionUserID<ConnectionUserID> userID)
Specified by:
serverAcceptedTCPConnection in interface BindListener
Specified by:
serverAcceptedTCPConnection in class ConnectionHandler
Parameters:
source - The BindManager that reports the event.
sockedID - The server socket's unique ID.
sock - The accepted connection socket.

serverAcceptedUDPConnection

public final void serverAcceptedUDPConnection(BindManager source,
                                              java.util.UUID socketID,
                                              java.net.DatagramSocket sock,
                                              ConnectionUserID<ConnectionUserID> userID)
This method is not meant to be called as this is a _TCP_ handler. It simply logs a SEVERE error to the global Logger via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ... ).

Specified by:
serverAcceptedUDPConnection in interface BindListener
Specified by:
serverAcceptedUDPConnection in class ConnectionHandler
Parameters:
source - The BindManager that reports the event.
sockedID - The server socket's unique ID.
sock - The accepted connection socket.

serverClosed

public void serverClosed(BindManager source,
                         java.util.UUID socketID)
This method does nothing except forwarding the INFO to the global logger instance via LogManager.getLogManager().getLogger( Constants.DEFAULT_LOGGER_NAME ).log( ... ).

Specified by:
serverClosed in interface BindListener
Overrides:
serverClosed in class ConnectionHandler
Parameters:
source - The BindManager that reports the event.
sockedID - The server socket's unique ID.

finalize

public abstract void finalize(long time,
                              java.util.concurrent.TimeUnit unit)
This method will be called if the SocketManager is going to terminate. All associated BindListener MUST terminate within the given time.

Specified by:
finalize in interface BindListener
Specified by:
finalize in class ConnectionHandler
Parameters:
time - The time value all dependent child threads have to terminate in.
unit - The time unit.