Class 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.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.logging.Logger LOG  
      protected boolean Running  
      protected TelnetServer Service  
      protected java.net.Socket Socket  
      protected java.lang.String User  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOG

        protected static final java.util.logging.Logger LOG
      • Socket

        protected final java.net.Socket Socket
      • 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 interface java.lang.Runnable
        Overrides:
        run in class java.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.