org.abstracthorizon.mercury.smtp.command
Class SMTPCommandFactory

java.lang.Object
  extended by org.abstracthorizon.danube.service.server.ServerConnectionHandler
      extended by org.abstracthorizon.mercury.smtp.command.SMTPCommandFactory
All Implemented Interfaces:
org.abstracthorizon.danube.connection.ConnectionHandler
Direct Known Subclasses:
SMTPFilterCommandFactory

public class SMTPCommandFactory
extends org.abstracthorizon.danube.service.server.ServerConnectionHandler

SMTP command factory. This class is implementing parsing commands and invoking them.

Author:
Daniel Sendula

Field Summary
protected  Map<String,SMTPCommand> commands
          Map of commands
static String DATA
          DATA command
static String EHLO
          EHLO command
static String EXPN
          EXPN command
static String HELO
          HELO commmand
protected  int inactivityTimeout
          Inactivity timeout
protected static org.slf4j.Logger logger
          Logger
static String MAIL
          MAIL command
static String NOOP
          NOOP commmand
static String QUIT
          QUIT command
static String RCPT
          RCPT command
static String RSET
          RSET (reset) command
static String VRFY
          VRFY command
 
Fields inherited from class org.abstracthorizon.danube.service.server.ServerConnectionHandler
connectionHandler
 
Constructor Summary
SMTPCommandFactory()
          Constructor.
 
Method Summary
protected  org.abstracthorizon.danube.connection.Connection decorateConnection(org.abstracthorizon.danube.connection.Connection connection)
          Sets state to SMTPSession.STATE_READY
protected  void finishProcessingConnection(org.abstracthorizon.danube.connection.Connection connection, boolean closedConnection)
          Does nothing
 SMTPCommand getCommand(String mnemonic)
          Returns a command from the map of commands
 Map<String,SMTPCommand> getCommands()
          Returns commands
 int getInactivityTimeout()
          Returns inactivity timeout
 void invokeCommand(SMTPSession smtpConnection, String commandName, SMTPCommand command)
          Invokes command
protected  boolean postProcessing(org.abstracthorizon.danube.connection.Connection connection)
          Returns false only if state of connection is SMTPSession.STATE_CONNECTED
protected  void processConnection(org.abstracthorizon.danube.connection.Connection connection)
          Processes keywords
 void processKeywords(SMTPSession smtpConnection)
          Checks all defined commands in map of commands.
 void setCommands(Map<String,SMTPCommand> commands)
          Sets map of commands
 void setInactivityTimeout(int timeout)
          Sets inactivity timeout
 
Methods inherited from class org.abstracthorizon.danube.service.server.ServerConnectionHandler
closeConnection, getConnectionHandler, handleConnection, setConnectionHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HELO

public static String HELO
HELO commmand


EHLO

public static String EHLO
EHLO command


MAIL

public static String MAIL
MAIL command


RCPT

public static String RCPT
RCPT command


DATA

public static String DATA
DATA command


NOOP

public static String NOOP
NOOP commmand


RSET

public static String RSET
RSET (reset) command


QUIT

public static String QUIT
QUIT command


VRFY

public static String VRFY
VRFY command


EXPN

public static String EXPN
EXPN command


logger

protected static final org.slf4j.Logger logger
Logger


commands

protected Map<String,SMTPCommand> commands
Map of commands


inactivityTimeout

protected int inactivityTimeout
Inactivity timeout

Constructor Detail

SMTPCommandFactory

public SMTPCommandFactory()
Constructor. It updates the map.

Method Detail

getCommands

public Map<String,SMTPCommand> getCommands()
Returns commands

Returns:
commands

setCommands

public void setCommands(Map<String,SMTPCommand> commands)
Sets map of commands

Parameters:
commands - commands

setInactivityTimeout

public void setInactivityTimeout(int timeout)
Sets inactivity timeout

Parameters:
timeout - timeout

getInactivityTimeout

public int getInactivityTimeout()
Returns inactivity timeout

Returns:
inactivity timeout

processConnection

protected void processConnection(org.abstracthorizon.danube.connection.Connection connection)
Processes keywords

Overrides:
processConnection in class org.abstracthorizon.danube.service.server.ServerConnectionHandler
Parameters:
connection - connection

decorateConnection

protected org.abstracthorizon.danube.connection.Connection decorateConnection(org.abstracthorizon.danube.connection.Connection connection)
Sets state to SMTPSession.STATE_READY

Overrides:
decorateConnection in class org.abstracthorizon.danube.service.server.ServerConnectionHandler
Parameters:
connection - connection

postProcessing

protected boolean postProcessing(org.abstracthorizon.danube.connection.Connection connection)
Returns false only if state of connection is SMTPSession.STATE_CONNECTED

Overrides:
postProcessing in class org.abstracthorizon.danube.service.server.ServerConnectionHandler
Parameters:
connection - connection

finishProcessingConnection

protected void finishProcessingConnection(org.abstracthorizon.danube.connection.Connection connection,
                                          boolean closedConnection)
Does nothing

Overrides:
finishProcessingConnection in class org.abstracthorizon.danube.service.server.ServerConnectionHandler
Parameters:
connection - connection
closedConnection - is connection already closed.

getCommand

public SMTPCommand getCommand(String mnemonic)
                       throws CommandException
Returns a command from the map of commands

Parameters:
mnemonic - command name
Returns:
command or null
Throws:
CommandException

processKeywords

public void processKeywords(SMTPSession smtpConnection)
                     throws IOException
Checks all defined commands in map of commands. As soon as command is found it is executed.

Parameters:
smtpConnection - smtp connection
Throws:
IOException

invokeCommand

public void invokeCommand(SMTPSession smtpConnection,
                          String commandName,
                          SMTPCommand command)
                   throws IOException
Invokes command

Parameters:
smtpConnection - smtp connection
commandName - command name
command - command itself
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.