org.subethamail.smtp.server
Class ConnectionHandler

java.lang.Object
  extended by java.lang.Thread
      extended by org.subethamail.smtp.server.ConnectionHandler
All Implemented Interfaces:
java.lang.Runnable, MessageContext, ConnectionContext

public class ConnectionHandler
extends java.lang.Thread
implements ConnectionContext, MessageContext

The thread that handles a connection. This class passes most of it's responsibilities off to the CommandHandler.

Author:
Jon Stevens

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ConnectionHandler(SMTPServer server, java.net.Socket socket)
           
 
Method Summary
 ConnectionHandler getConnection()
           
 java.io.InputStream getInput()
           
 long getLastActiveTime()
           
 java.io.OutputStream getOutput()
           
 java.net.SocketAddress getRemoteAddress()
           
 SMTPServer getServer()
           
 Session getSession()
           
 SMTPServer getSMTPServer()
           
 java.net.Socket getSocket()
           
 long getStartTime()
           
 void refreshLastActiveTime()
           
 void run()
           
 void sendResponse(java.lang.String response)
           
 void setSocket(java.net.Socket socket)
           
 void timeout()
           
 
Methods inherited from class java.lang.Thread
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionHandler

public ConnectionHandler(SMTPServer server,
                         java.net.Socket socket)
                  throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getSession

public Session getSession()
Specified by:
getSession in interface ConnectionContext

getConnection

public ConnectionHandler getConnection()
Specified by:
getConnection in interface ConnectionContext

getServer

public SMTPServer getServer()
Specified by:
getServer in interface ConnectionContext

timeout

public void timeout()
             throws java.io.IOException
Throws:
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setSocket

public void setSocket(java.net.Socket socket)
               throws java.io.IOException
Throws:
java.io.IOException

getSocket

public java.net.Socket getSocket()
Specified by:
getSocket in interface ConnectionContext

getInput

public java.io.InputStream getInput()

getOutput

public java.io.OutputStream getOutput()

sendResponse

public void sendResponse(java.lang.String response)
                  throws java.io.IOException
Specified by:
sendResponse in interface ConnectionContext
Throws:
java.io.IOException

getStartTime

public long getStartTime()

getLastActiveTime

public long getLastActiveTime()

refreshLastActiveTime

public void refreshLastActiveTime()

getRemoteAddress

public java.net.SocketAddress getRemoteAddress()
Specified by:
getRemoteAddress in interface MessageContext
Returns:
the IP address of the remote server.

getSMTPServer

public SMTPServer getSMTPServer()
Specified by:
getSMTPServer in interface MessageContext
Returns:
the SMTPServer object.