public abstract class IfsServerChannel extends Thread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
static String |
CONTROL_SOCKET
The Key for the ControlSocket.
|
protected InputStream |
m_ControlIn
The cntrl input.
|
protected OutputStream |
m_ControlOut
The cntrl output.
|
protected int |
m_ControlSocketTimeout
The default timeout for the channel socket.
|
protected SocketFactory |
m_SocketFactory
My socket factory.
|
protected Hashtable |
m_Sockets
My sockets.
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
IfsServerChannel(IfsProtocolServer server,
Socket controlSocket,
int key,
String threadName)
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeConnection()
Close outputstream, inputStream, and all sockets setting the memeber variables to null.
|
protected abstract ProtocolStreamParser |
createProtocolStreamParser()
Create the ProtocolStreamParser associated with this Channel.
|
protected SocketFactory |
createSocketFactory(InetAddress localhost,
int localControlPort,
InetAddress clientHost,
int clientContorlPort)
Creates a socket factory with the InetAddresses as given and the ports minus 1.
|
void |
disconnect()
Disconnects this Channel.
|
int |
getChannelKey()
Gets the channel Key given at instaniation.
|
int |
getControlSocketTimeout() |
IfsProtocolServer |
getProtocolServer()
Gets the ProtocolServer that started this Channel.
|
IfsProtocolSession |
getProtocolSession()
Gets the ProtocolSession associated with this Channel.
|
Socket |
getSocket(Object key)
Gets an active socket by key.
|
SocketFactory |
getSocketFactory()
Gets the SocketFactory associated with this Channel.
|
protected void |
handleCommandInvocationIfsException(IfsException e,
Object cmdkey)
Handles a Throwable while invoking command.
|
protected void |
handleCommandInvocationThrowable(Throwable e,
Object cmdkey)
Handles a Throwable while invoking command.
|
protected void |
handleInterruptedIOException(InterruptedIOException e)
Hanndles an InterruptedIOException in the command loop.
|
protected void |
handleIOException(IOException e)
Hanndles an IOException in the command loop.
|
protected void |
handleThrowable(Throwable e)
Hanndles a Throwable in the command loop.
|
void |
log(int level,
String s)
Prints a message to the log.
|
void |
log(int level,
Throwable e)
Prints an exception stack trace to the log.
|
protected void |
postCommandLoop()
Called after entering command loop.
|
protected void |
preCommandLoop()
Called before entering command loop.
|
Socket |
removeSocket(Object key)
Removes an active socket by key.
|
void |
run()
The control loop.
|
void |
setControlSocketTimeout(int timeout) |
void |
setProtocolSession(IfsProtocolSession protocolSession)
Sets the ProtocolSession associated with this Channel.
|
Socket |
setSocket(Object key,
Socket socket)
Sets an active socket to be accessable by a key.
|
protected void |
setupIO()
Obtains the input and output streams and then creates and initializes
the ProtocolStreamParser associated with this Channel.
|
Enumeration |
socketKeys()
Returns all keys associated with active sockets.
|
Enumeration |
sockets()
Returns all active sockets.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final String CONTROL_SOCKET
protected SocketFactory m_SocketFactory
protected Hashtable m_Sockets
protected int m_ControlSocketTimeout
protected InputStream m_ControlIn
protected OutputStream m_ControlOut
public IfsServerChannel(IfsProtocolServer server, Socket controlSocket, int key, String threadName) throws Exception
Exception
public void run()
public void setControlSocketTimeout(int timeout) throws SocketException
SocketException
public int getControlSocketTimeout()
public Socket setSocket(Object key, Socket socket)
public Socket removeSocket(Object key)
public Enumeration socketKeys()
public Enumeration sockets()
public SocketFactory getSocketFactory()
protected SocketFactory createSocketFactory(InetAddress localhost, int localControlPort, InetAddress clientHost, int clientContorlPort) throws IfsException
IfsException
protected void closeConnection()
protected void preCommandLoop() throws IfsException
IfsException
protected void postCommandLoop() throws IfsException
IfsException
protected void handleInterruptedIOException(InterruptedIOException e) throws IfsException
IfsException
protected void handleIOException(IOException e) throws IfsException
IfsException
protected void handleThrowable(Throwable e) throws IfsException
IfsException
protected void handleCommandInvocationThrowable(Throwable e, Object cmdkey) throws IfsException
IfsException
protected void handleCommandInvocationIfsException(IfsException e, Object cmdkey) throws IfsException
IfsException
protected void setupIO() throws Exception
Exception
protected abstract ProtocolStreamParser createProtocolStreamParser() throws IfsException
IfsException
public IfsProtocolServer getProtocolServer()
public IfsProtocolSession getProtocolSession()
public void setProtocolSession(IfsProtocolSession protocolSession)
public void disconnect()
public int getChannelKey()
public void log(int level, String s)
s
- the messagepublic void log(int level, Throwable e)
e
- The Throwable to trace to the log.Copyright © 2023. All rights reserved.