org.starhope.appius.net
Class AdminProcessor

java.lang.Object
  extended by java.lang.Thread
      extended by org.starhope.appius.net.AdminProcessor
All Implemented Interfaces:
Comparable<Thread>, Runnable, ServerProcessor

public class AdminProcessor
extends Thread
implements ServerProcessor, Comparable<Thread>

Processing thread for an administrative connection (normally port 2772)

Author:
brpocock@star-hope.org

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  BufferedReader in
          the input stream
private static int maxInputSize
          the maximum input line length accepted
private  PrintWriter out
          the output stream
private  Socket socket
          the socket against which we're acting
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AdminProcessor(Socket userSocket)
          create a new administrative processing thread
 
Method Summary
 int compareTo(Thread o)
           
 boolean equals(Object obj)
           
private  String grabInput()
           
 int hashCode()
           
private  String processInput(String inputLine)
           
 void run()
          This is an overriding method.
private  void setup()
          Set up this thread to execute
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.starhope.appius.net.ServerProcessor
start
 

Field Detail

maxInputSize

private static final int maxInputSize
the maximum input line length accepted

See Also:
Constant Field Values

in

private BufferedReader in
the input stream


out

private PrintWriter out
the output stream


socket

private final Socket socket
the socket against which we're acting

Constructor Detail

AdminProcessor

public AdminProcessor(Socket userSocket)
create a new administrative processing thread

Parameters:
userSocket - the socket to which the remote user is connected
Method Detail

compareTo

public int compareTo(Thread o)
Specified by:
compareTo in interface Comparable<Thread>
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

grabInput

private String grabInput()
Returns:
accept input from the admin

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

processInput

private String processInput(String inputLine)
                     throws PrivilegeRequiredException,
                            NotFoundException
Parameters:
inputLine - the input from the client
Returns:
output line to return to the client, or “null” to disconnect
Throws:
PrivilegeRequiredException - if the client doesn't specify the name of a Developer-level user
NotFoundException - if the data input is malformed

run

public void run()
This is an overriding method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.run()

setup

private void setup()
            throws IOException,
                   UserDeadException
Set up this thread to execute

Throws:
IOException - if the I/O streams can't be initialized
UserDeadException - if the user disconnects before setup is complete