ikrs.yuccasrv
Class ConnectionHandler
java.lang.Object
ikrs.yuccasrv.ConnectionHandler
- All Implemented Interfaces:
- ObjectWithUUID, BindListener
- Direct Known Subclasses:
- TCPAdapter
public abstract class ConnectionHandler
- extends java.lang.Object
- implements BindListener, ObjectWithUUID
Method Summary |
abstract void |
finalize(long time,
java.util.concurrent.TimeUnit unit)
This method will be called if the SocketManager is going to terminate. |
java.util.UUID |
getUUID()
Get the unique and final UUID for this object. |
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)
|
abstract void |
serverAcceptedUDPConnection(BindManager source,
java.util.UUID socketID,
java.net.DatagramSocket sock,
ConnectionUserID<ConnectionUserID> userID)
|
void |
serverClosed(BindManager source,
java.util.UUID socketID)
|
void |
serverCreated(BindManager source,
java.util.UUID socketID)
|
void |
serverError(BindManager source,
java.util.UUID socketID,
java.lang.Exception e,
boolean isTraumatic)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConnectionHandler
public ConnectionHandler()
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.
- 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)
- Specified by:
serverCreated
in interface BindListener
- 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)
- Specified by:
serverError
in interface BindListener
- 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
- Parameters:
source
- The BindManager that reports the event.sockedID
- The server socket's unique ID.sock
- The accepted connection socket.
serverAcceptedUDPConnection
public abstract void serverAcceptedUDPConnection(BindManager source,
java.util.UUID socketID,
java.net.DatagramSocket sock,
ConnectionUserID<ConnectionUserID> userID)
- Specified by:
serverAcceptedUDPConnection
in interface BindListener
- 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)
- Specified by:
serverClosed
in interface BindListener
- 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
- Parameters:
time
- The time value all dependent child threads have to terminate in.unit
- The time unit.
getUUID
public java.util.UUID getUUID()
- Get the unique and final UUID for this object.
The returned UUID must never change!
- Specified by:
getUUID
in interface ObjectWithUUID
- Returns:
- The UUID of this object.