org.apache.james.protocols.smtp.core
Class AbstractHookableCmdHandler<Hook extends Hook>

java.lang.Object
  extended by org.apache.james.protocols.smtp.core.AbstractHookableCmdHandler<Hook>
All Implemented Interfaces:
CommandHandler<SMTPSession>, ExtensibleHandler, ProtocolHandler
Direct Known Subclasses:
EhloCmdHandler, HeloCmdHandler, MailCmdHandler, QuitCmdHandler, RcptCmdHandler, UnknownCmdHandler

public abstract class AbstractHookableCmdHandler<Hook extends Hook>
extends Object
implements CommandHandler<SMTPSession>, ExtensibleHandler

Abstract class which Handle hook-aware CommanHandler.


Constructor Summary
AbstractHookableCmdHandler()
           
 
Method Summary
static SMTPResponse calcDefaultSMTPResponse(HookResult result)
          Convert the HookResult to SMTPResponse using default values.
protected abstract  HookResult callHook(Hook rawHook, SMTPSession session, String parameters)
          Must be implemented by hookable cmd handlers to make the effective call to an hook.
protected abstract  SMTPResponse doCoreCmd(SMTPSession session, String command, String parameters)
          Execute the core commandHandling.
protected abstract  SMTPResponse doFilterChecks(SMTPSession session, String command, String parameters)
          Execute Syntax checks and return a SMTPResponse if a syntax error was detected, otherwise null.
protected abstract  Class<Hook> getHookInterface()
          Return the interface which hooks need to implement to hook in
protected  List<Hook> getHooks()
          Return a list which holds all hooks for the cmdHandler
 List<Class<?>> getMarkerInterfaces()
           
 Response onCommand(SMTPSession session, Request request)
          Handle command processing
 void wireExtensions(Class interfaceName, List extension)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.james.protocols.api.handler.CommandHandler
getImplCommands
 

Constructor Detail

AbstractHookableCmdHandler

public AbstractHookableCmdHandler()
Method Detail

onCommand

public Response onCommand(SMTPSession session,
                          Request request)
Handle command processing

Specified by:
onCommand in interface CommandHandler<SMTPSession>
See Also:
#onCommand(org.apache.james.protocols.api.ProtocolSession, Request)

callHook

protected abstract HookResult callHook(Hook rawHook,
                                       SMTPSession session,
                                       String parameters)
Must be implemented by hookable cmd handlers to make the effective call to an hook.

Parameters:
rawHook - the hook
session - the session
parameters - the parameters
Returns:
the HookResult, will be calculated using HookResultToSMTPResponse.

calcDefaultSMTPResponse

public static SMTPResponse calcDefaultSMTPResponse(HookResult result)
Convert the HookResult to SMTPResponse using default values. Should be override for using own values

Parameters:
result - HookResult
Returns:
SMTPResponse

doFilterChecks

protected abstract SMTPResponse doFilterChecks(SMTPSession session,
                                               String command,
                                               String parameters)
Execute Syntax checks and return a SMTPResponse if a syntax error was detected, otherwise null.

Parameters:
session -
command -
parameters -
Returns:
smtp response if a syntax error was detected, otherwise null

doCoreCmd

protected abstract SMTPResponse doCoreCmd(SMTPSession session,
                                          String command,
                                          String parameters)
Execute the core commandHandling.

Parameters:
session -
command -
parameters -
Returns:
smtp response

getMarkerInterfaces

public List<Class<?>> getMarkerInterfaces()
Specified by:
getMarkerInterfaces in interface ExtensibleHandler
See Also:
ExtensibleHandler.getMarkerInterfaces()

getHookInterface

protected abstract Class<Hook> getHookInterface()
Return the interface which hooks need to implement to hook in

Returns:
interface

wireExtensions

public void wireExtensions(Class interfaceName,
                           List extension)
Specified by:
wireExtensions in interface ExtensibleHandler
See Also:
ExtensibleHandler.wireExtensions(java.lang.Class, java.util.List)

getHooks

protected List<Hook> getHooks()
Return a list which holds all hooks for the cmdHandler

Returns:
list containing all hooks for the cmd handler


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.