Package org.cristian.t4j
Class TelnetServer.Handler
- java.lang.Object
-
- java.lang.Thread
-
- org.cristian.t4j.TelnetServer.Handler
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
TelnetDefaultHandler
- Enclosing class:
- TelnetServer
public abstract static class TelnetServer.Handler extends java.lang.Thread
Absctract class used as template for handlers.
-
-
Constructor Summary
Constructors Constructor Description Handler(java.net.Socket Socket, TelnetServer Service)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static int
getNextThreadID()
Generate an ID for a handler thread.abstract void
handle(java.io.BufferedReader STDIN, java.io.PrintWriter STDOUT)
Executes the handling code in a loop until the connection is closed.abstract TelnetServer.Handler
newHandler(java.net.Socket Socket, TelnetServer Service)
Make a new server handler instance.void
run()
void
setup(java.io.BufferedReader STDIN, java.io.PrintWriter STDOUT)
Executes the setup code once after running the authenticator's code.void
terminate(boolean RemoveFromServer)
Terminate this handler.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
LOG
protected static final java.util.logging.Logger LOG
-
Socket
protected final java.net.Socket Socket
-
Service
protected final TelnetServer Service
-
Running
protected boolean Running
-
User
protected java.lang.String User
-
-
Constructor Detail
-
Handler
public Handler(java.net.Socket Socket, TelnetServer Service)
-
-
Method Detail
-
newHandler
public abstract TelnetServer.Handler newHandler(java.net.Socket Socket, TelnetServer Service)
Make a new server handler instance.- Parameters:
Socket
- The connection's socket instance.Service
- The current server instance.- Returns:
- A new Handler instance.
-
setup
public void setup(java.io.BufferedReader STDIN, java.io.PrintWriter STDOUT) throws java.io.IOException
Executes the setup code once after running the authenticator's code.- Parameters:
STDIN
- The standard input stream.STDOUT
- The standard output stream.- Throws:
java.io.IOException
- Raised mostly from trying to write or read from STDIN/OUT when the connection has been closed.
-
handle
public abstract void handle(java.io.BufferedReader STDIN, java.io.PrintWriter STDOUT) throws java.io.IOException
Executes the handling code in a loop until the connection is closed.- Parameters:
STDIN
- The standard input stream.STDOUT
- The standard output stream.- Throws:
java.io.IOException
- Raised mostly from trying to write or read from STDIN/OUT when the connection has been closed.
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
getNextThreadID
public static int getNextThreadID()
Generate an ID for a handler thread.- Returns:
- New ID for a thread.
-
terminate
public void terminate(boolean RemoveFromServer)
Terminate this handler.- Parameters:
RemoveFromServer
- If true, the handler thread will be removed from this server.
-
-