net.sf.hermesftp.parser.impl
Class FtpCmdReaderThread

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.hermesftp.parser.impl.FtpCmdReaderThread
All Implemented Interfaces:
java.lang.Runnable, Abortable, FtpCmdReader

public class FtpCmdReaderThread
extends java.lang.Thread
implements FtpCmdReader

This Command reader thread listens for client input and mantains an FIFO list of incoming command lines. The thread is active during the execution of transfer commands (STOR, RETR) and informs these commands asynchronously when a status or abort is requested by the client.

Author:
Lars Behnke

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
FtpCmdReaderThread()
          Constructor.
 
Method Summary
 void abort()
          Aborts the current process..
 FtpSessionContext getCtx()
          Getter method for the java bean ctx.
 FtpCmdParser getParser()
          Getter method for the java bean parser.
 boolean isTerminated()
          Checks if the current process has been aborted.
 void run()
          Reads commands issued by the client form the buffer.
 void setCtx(FtpSessionContext ctx)
          Setter method for the java bean ctx.
 void setParser(FtpCmdParser parser)
          Setter method for the java bean parser.
 FtpCmd waitForNextCommand(int timeout)
          Waits until another command is available.
 
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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.hermesftp.parser.FtpCmdReader
start
 

Constructor Detail

FtpCmdReaderThread

public FtpCmdReaderThread()
Constructor.

Method Detail

run

public void run()
Reads commands issued by the client form the buffer. There two commands - STAT and ABOR - that can be send during a file transfer operation. If the currently executed command (RETR, STOR,...) implements the AsyncAbortListener interface, the responsibility to handle these requests is delegated to this command.

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

waitForNextCommand

public FtpCmd waitForNextCommand(int timeout)
                          throws FtpIllegalCmdException,
                                 java.net.SocketTimeoutException
Waits until another command is available.

Specified by:
waitForNextCommand in interface FtpCmdReader
Parameters:
timeout - Timeout in milliseconds.
Returns:
The next FtpCmd to handle.
Throws:
FtpIllegalCmdException - Thrown if an unknown command token is encountered.
java.net.SocketTimeoutException - Timeout error.

getParser

public FtpCmdParser getParser()
Getter method for the java bean parser.

Specified by:
getParser in interface FtpCmdReader
Returns:
Returns the value of the java bean parser.

setParser

public void setParser(FtpCmdParser parser)
Setter method for the java bean parser.

Specified by:
setParser in interface FtpCmdReader
Parameters:
parser - The value of parser to set.

getCtx

public FtpSessionContext getCtx()
Getter method for the java bean ctx.

Returns:
Returns the value of the java bean ctx.

setCtx

public void setCtx(FtpSessionContext ctx)
Setter method for the java bean ctx.

Specified by:
setCtx in interface FtpCmdReader
Parameters:
ctx - The value of ctx to set.

isTerminated

public boolean isTerminated()
Checks if the current process has been aborted.

Specified by:
isTerminated in interface Abortable
Returns:
True, if process has been aborted.

abort

public void abort()
Aborts the current process..

Specified by:
abort in interface Abortable


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.