You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Norman Maurer <nm...@byteaction.de> on 2006/07/04 20:10:16 UTC
Re: svn commit: r419010 - in /james/server/sandbox/handlerapi/src:
java/org/apache/james/smtpserver/
java/org/apache/james/smtpserver/basefilter/
java/org/apache/james/smtpserver/fastfailfilter/
test/org/apache/james/smtpserver/
Hi guys,
after reading the code a bit more i notice that the
setStopHandlerProcessing(boolean) and getStopHandlerProcessing() is not
needed on the current implementation. At the moment the
handlerProccessing get stoppen after a handler write a response to the
user. Anyway im not sure if it is the perfect behavior for a api.
Any ideas if we should keep my methods in the fastfail code ? or should
we remove it.
A Other nice solution ( which i had in mind) is to create an
AbstractCommandHandler which support all needed methods for a "real"
api. So the developer must extend it to implement a CommandHandler. I
will commit some code for this later. Then we can see what is better..
Any problems here with a Abstract class ?
Am Dienstag, den 04.07.2006, 14:03 +0000 schrieb norman@apache.org:
> Author: norman
> Date: Tue Jul 4 07:03:26 2006
> New Revision: 419010
>
> URL: http://svn.apache.org/viewvc?rev=419010&view=rev
> Log:
> Add method to session to set when proccessing of handlers should stop
>
> Modified:
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AuthCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/CommandHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DataCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/EhloCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ExpnCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HeloCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HelpCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MailCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/NoopCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/QuitCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RsetCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/UnknownCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/VrfyCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/DataBaseFilterCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/EhloBaseFilterCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/HeloBaseFilterCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/MailBaseFilterCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/RcptBaseFilterCmdHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java
> james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java
> james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
> james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AuthCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AuthCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AuthCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AuthCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -45,7 +45,6 @@
> */
> private final static String AUTH_TYPE_LOGIN = "LOGIN";
>
> -
> /**
> * handles AUTH command
> *
> @@ -281,5 +280,5 @@
> implCommands.add("AUTH");
>
> return implCommands;
> - }
> + }
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/CommandHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/CommandHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/CommandHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/CommandHandler.java Tue Jul 4 07:03:26 2006
> @@ -26,6 +26,7 @@
> * in the SMTPSession object
> */
> public interface CommandHandler {
> +
> /**
> * Handle the command
> **/
> @@ -37,4 +38,5 @@
> * @return List which contains implemented commands
> */
> List getImplCommands();
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DataCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DataCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DataCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DataCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -95,9 +95,7 @@
> * @param argument the argument passed in with the command by the SMTP client
> */
> private void doDATA(SMTPSession session, String argument) {
> -
> - if (session.getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null) return;
> -
> +
> String responseString = null;
> responseString = "354 Ok Send data ending with <CRLF>.<CRLF>";
> session.writeResponse(responseString);
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/EhloCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/EhloCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/EhloCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/EhloCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -53,9 +53,6 @@
> private void doEHLO(SMTPSession session, String argument) {
> StringBuffer responseBuffer = session.getResponseBuffer();
>
> - if (session.getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null)
> - return;
> -
> session.resetState();
> session.getState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME);
>
> @@ -107,5 +104,4 @@
>
> return implCommands;
> }
> -
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ExpnCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ExpnCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ExpnCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ExpnCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -31,7 +31,7 @@
> * The name of the command handled by the command handler
> */
> private final static String COMMAND_NAME = "EXPN";
> -
> +
> /**
> * Handler method called upon receipt of a EXPN command.
> * This method informs the client that the command is
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HeloCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HeloCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HeloCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HeloCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -32,7 +32,7 @@
> /**
> * The name of the command handled by the command handler
> */
> - private final static String COMMAND_NAME = "HELO";
> + private final static String COMMAND_NAME = "HELO";
>
> /**
> * process HELO command
> @@ -50,9 +50,6 @@
> private void doHELO(SMTPSession session, String argument) {
> String responseString = null;
>
> - if (session.getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null)
> - return;
> -
> session.resetState();
> session.getState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME);
> session.getResponseBuffer().append("250 ").append(
> @@ -72,6 +69,5 @@
> implCommands.add("HELO");
>
> return implCommands;
> - }
> -
> + }
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HelpCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HelpCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HelpCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/HelpCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -51,5 +51,4 @@
>
> return implCommands;
> }
> -
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MailCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MailCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MailCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MailCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -30,6 +30,7 @@
> public class MailCmdHandler
> extends AbstractLogEnabled
> implements CommandHandler {
> +
>
> /**
> * handles MAIL command
> @@ -49,10 +50,7 @@
> * @param argument the argument passed in with the command by the SMTP client
> */
> private void doMAIL(SMTPSession session, String argument) {
> -
> - if (session.getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null) return;
> -
> -
> +
> StringBuffer responseBuffer = session.getResponseBuffer();
> String responseString = null;
>
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/NoopCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/NoopCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/NoopCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/NoopCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -52,6 +52,4 @@
>
> return implCommands;
> }
> -
> -
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/QuitCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/QuitCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/QuitCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/QuitCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -75,7 +75,6 @@
>
> return implCommands;
> }
> -
> }
>
>
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RcptCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RcptCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RcptCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -50,9 +50,7 @@
> * @param argument the argument passed in with the command by the SMTP client
> */
> private void doRCPT(SMTPSession session, String argument) {
> -
> - if (session.getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null) return;
> -
> +
> String responseString = null;
> StringBuffer responseBuffer = session.getResponseBuffer();
>
> @@ -84,5 +82,5 @@
>
> return implCommands;
> }
> -
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RsetCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RsetCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RsetCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/RsetCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -74,4 +74,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java Tue Jul 4 07:03:26 2006
> @@ -158,6 +158,8 @@
> * The per-handler response buffer used to marshal responses.
> */
> private StringBuffer responseBuffer = new StringBuffer(256);
> +
> + private boolean stopHandlerProcessing = false;
>
> /**
> * Set the configuration data for the handler
> @@ -268,13 +270,13 @@
> } else {
> int count = commandHandlers.size();
> for(int i = 0; i < count; i++) {
> + setStopHandlerProcessing(false);
> ((CommandHandler)commandHandlers.get(i)).onCommand(this);
> +
> theWatchdog.reset();
> +
> //if the response is received, stop processing of command handlers
> - if(mode != COMMAND_MODE || getState().get(SMTPSession.STOP_HANDLER_PROCESSING) != null) {
> -
> - // remove the blockin state
> - getState().remove(SMTPSession.STOP_HANDLER_PROCESSING);
> + if(mode != COMMAND_MODE || getStopHandlerProcessing()) {
> break;
> }
> }
> @@ -568,6 +570,20 @@
> }
>
> return count;
> + }
> +
> + /**
> + * @see org.apache.james.smtpserver.SMTPSession#setStopHandlerProcessing(boolean)
> + */
> + public void setStopHandlerProcessing(boolean stopHandlerProcessing) {
> + this.stopHandlerProcessing = stopHandlerProcessing;
> + }
> +
> + /**
> + * @see org.apache.james.smtpserver.SMTPSession#getStopHandlerProcessing()
> + */
> + public boolean getStopHandlerProcessing() {
> + return stopHandlerProcessing;
> }
>
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPSession.java Tue Jul 4 07:03:26 2006
> @@ -37,8 +37,7 @@
> public final static String SENDER = "SENDER_ADDRESS"; // Sender's email address
> public final static String RCPT_LIST = "RCPT_LIST"; // The message recipients
> public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO
> - public final static String STOP_HANDLER_PROCESSING = "STOP_HANDLER_PROCESSING";
> - public static final Object CURRENT_RECIPIENT = "CURRENT_RECIPIENT";
> + public static final Object CURRENT_RECIPIENT = "CURRENT_RECIPIENT"; // Current recipient
>
> /**
> * Writes response string to the client
> @@ -242,6 +241,10 @@
> * @return recipient count
> */
> int getRcptCount();
> +
> + void setStopHandlerProcessing(boolean b);
> +
> + boolean getStopHandlerProcessing();
>
> }
>
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/UnknownCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/UnknownCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/UnknownCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/UnknownCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -31,6 +31,8 @@
> * The name of the command handled by the command handler
> */
> public static final String UNKNOWN_COMMAND = "UNKNOWN";
> +
> + private boolean stopHandlerProcessing = true;
>
> /**
> * Handler method called upon receipt of an unrecognized command.
> @@ -62,6 +64,13 @@
> implCommands.add("UNKNOWN");
>
> return implCommands;
> + }
> +
> + /**
> + * @see org.apache.james.smtpserver.CommandHandler#stopHandlerProcessing()
> + */
> + public boolean stopHandlerProcessing() {
> + return stopHandlerProcessing ;
> }
>
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/VrfyCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/VrfyCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/VrfyCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/VrfyCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -28,6 +28,7 @@
> public class VrfyCmdHandler implements CommandHandler {
>
> private final String COMMAND_NAME = "VRFY";
> + private boolean stopHandlerProcessing = true;
>
> /**
> * Handler method called upon receipt of a VRFY command.
> @@ -51,5 +52,11 @@
> return implCommands;
> }
>
> + /**
> + * @see org.apache.james.smtpserver.CommandHandler#stopHandlerProcessing()
> + */
> + public boolean stopHandlerProcessing() {
> + return stopHandlerProcessing ;
> + }
>
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/DataBaseFilterCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/DataBaseFilterCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/DataBaseFilterCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/DataBaseFilterCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -32,7 +32,7 @@
> public class DataBaseFilterCmdHandler
> extends AbstractLogEnabled
> implements CommandHandler {
> -
> +
> /**
> * process DATA command
> *
> @@ -54,22 +54,20 @@
> session.writeResponse(responseString);
>
> //TODO: Check if this should been!
> - // After this filter match we should not call any other handler!
> - //session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> }
> if (!session.getState().containsKey(SMTPSession.SENDER)) {
> responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" No sender specified";
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else if (!session.getState().containsKey(SMTPSession.RCPT_LIST)) {
> responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" No recipients specified";
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
> }
> }
>
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/EhloBaseFilterCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/EhloBaseFilterCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/EhloBaseFilterCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/EhloBaseFilterCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -56,7 +56,7 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
> }
> }
>
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/HeloBaseFilterCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/HeloBaseFilterCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/HeloBaseFilterCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/HeloBaseFilterCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -58,7 +58,7 @@
> getLogger().info(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> }
> }
> @@ -72,4 +72,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/MailBaseFilterCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/MailBaseFilterCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/MailBaseFilterCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/MailBaseFilterCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -38,7 +38,7 @@
> private final static String MAIL_OPTION_SIZE = "SIZE";
>
> private final static String MESG_SIZE = "MESG_SIZE"; // The size of the message
> -
> +
> /**
> * handles MAIL command
> *
> @@ -67,14 +67,14 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else if (!session.getState().containsKey(SMTPSession.CURRENT_HELO_MODE) && session.useHeloEhloEnforcement()) {
> responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Need HELO or EHLO before MAIL";
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else if (argument == null || !argument.toUpperCase(Locale.US).equals("FROM")
> || sender == null) {
> @@ -82,7 +82,7 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else {
> sender = sender.trim();
> @@ -139,7 +139,7 @@
> getLogger().error(errorBuffer.toString());
> }
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -170,7 +170,7 @@
> }
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -200,7 +200,7 @@
> getLogger().error("Rejected syntactically incorrect value for SIZE parameter.");
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return false;
> }
> @@ -233,7 +233,7 @@
> getLogger().error(errorBuffer.toString());
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return false;
> } else {
> @@ -253,6 +253,5 @@
>
> return implCommands;
> }
> -
>
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/RcptBaseFilterCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/RcptBaseFilterCmdHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/RcptBaseFilterCmdHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/basefilter/RcptBaseFilterCmdHandler.java Tue Jul 4 07:03:26 2006
> @@ -35,6 +35,7 @@
> public class RcptBaseFilterCmdHandler extends AbstractLogEnabled implements
> CommandHandler {
>
> +
> /**
> * handles RCPT command
> *
> @@ -63,7 +64,7 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else if (argument == null || !argument.toUpperCase(Locale.US).equals("TO")
> || recipient == null) {
> @@ -71,7 +72,7 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> } else {
> Collection rcptColl = (Collection) session.getState().get(SMTPSession.RCPT_LIST);
> @@ -102,7 +103,7 @@
> }
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -134,7 +135,7 @@
> }
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -152,7 +153,7 @@
> session.writeResponse(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -171,7 +172,7 @@
> getLogger().error(sb.toString());
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -197,7 +198,7 @@
> }
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -217,7 +218,7 @@
> getLogger().error(errorBuffer.toString());
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> return;
> }
> @@ -247,7 +248,7 @@
> }
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
>
> }
> optionTokenizer = null;
> @@ -280,4 +281,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/MaxRcptHandler.java Tue Jul 4 07:03:26 2006
> @@ -77,7 +77,7 @@
> getLogger().error(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
> }
> }
>
> @@ -90,4 +90,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java Tue Jul 4 07:03:26 2006
> @@ -105,8 +105,7 @@
> getLogger().info(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING,
> - "true");
> + session.setStopHandlerProcessing(true);
> }
> }
> }
> @@ -121,4 +120,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java Tue Jul 4 07:03:26 2006
> @@ -108,8 +108,7 @@
> getLogger().info(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING,
> - "true");
> + session.setStopHandlerProcessing(true);
> }
> } catch (UnknownHostException e) {
> responseString = "501 "
> @@ -121,8 +120,7 @@
> getLogger().info(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING,
> - "true");
> + session.setStopHandlerProcessing(true);
> }
> }
> }
> @@ -137,4 +135,5 @@
>
> return implCommands;
> }
> +
> }
>
> Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java (original)
> +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java Tue Jul 4 07:03:26 2006
> @@ -104,7 +104,7 @@
> getLogger().info(responseString);
>
> // After this filter match we should not call any other handler!
> - session.getState().put(SMTPSession.STOP_HANDLER_PROCESSING, "true");
> + session.setStopHandlerProcessing(true);
> }
> }
> }
>
> Modified: james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
> +++ james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Tue Jul 4 07:03:26 2006
> @@ -263,6 +263,16 @@
> "Unimplemented mock service");
> }
>
> + public void setStopHandlerProcessing(boolean b) {
> + throw new UnsupportedOperationException(
> + "Unimplemented mock service");
> + }
> +
> + public boolean getStopHandlerProcessing() {
> + throw new UnsupportedOperationException(
> + "Unimplemented mock service");
> + }
> +
> };
> }
>
>
> Modified: james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java?rev=419010&r1=419009&r2=419010&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java (original)
> +++ james/server/sandbox/handlerapi/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java Tue Jul 4 07:03:26 2006
> @@ -209,6 +209,16 @@
> throw new UnsupportedOperationException(
> "Unimplemented mock service");
> }
> +
> + public void setStopHandlerProcessing(boolean b) {
> + throw new UnsupportedOperationException(
> + "Unimplemented mock service");
> + }
> +
> + public boolean getStopHandlerProcessing() {
> + throw new UnsupportedOperationException(
> + "Unimplemented mock service");
> + }
> };
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
> !EXCUBATOR:1,44aa755148531709814846!
Re: svn commit: r419010 - in /james/server/sandbox/handlerapi/src:
java/org/apache/james/smtpserver/ java/org/apache/james/smtpserver/basefilter/
java/org/apache/james/smtpserver/fastfailfilter/ test/org/apache/james/smtpserver/
Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Hi guys,
>
> after reading the code a bit more i notice that the
> setStopHandlerProcessing(boolean) and getStopHandlerProcessing() is not
> needed on the current implementation. At the moment the
> handlerProccessing get stoppen after a handler write a response to the
> user. Anyway im not sure if it is the perfect behavior for a api.
>
> Any ideas if we should keep my methods in the fastfail code ? or should
> we remove it.
Imho the api should be as simple as possible: if we can't find a good
real use case that make use of that methods we should remove them.
We are at the beginning of the work for a major release, we can safely
experiment: we'll probably change this more while adding more handlers.
> A Other nice solution ( which i had in mind) is to create an
> AbstractCommandHandler which support all needed methods for a "real"
> api. So the developer must extend it to implement a CommandHandler. I
> will commit some code for this later. Then we can see what is better..
>
> Any problems here with a Abstract class ?
Abstract classes are good.
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r419010 - in /james/server/sandbox/handlerapi/src:
java/org/apache/james/smtpserver/ java/org/apache/james/smtpserver/basefilter/
java/org/apache/james/smtpserver/fastfailfilter/ test/org/apache/james/smtpserver/
Posted by Norman Maurer <nm...@byteaction.de>.
Am Mittwoch, den 05.07.2006, 10:09 +0200 schrieb Stefano Bagnara:
> Norman Maurer wrote:
> > Hi guys,
> >
> > after reading the code a bit more i notice that the
> > setStopHandlerProcessing(boolean) and getStopHandlerProcessing() is not
> > needed on the current implementation. At the moment the
> > handlerProccessing get stoppen after a handler write a response to the
> > user. Anyway im not sure if it is the perfect behavior for a api.
> >
> > Any ideas if we should keep my methods in the fastfail code ? or should
> > we remove it.
>
> Imho the api should be as simple as possible: if we can't find a good
> real use case that make use of that methods we should remove them.
> We are at the beginning of the work for a major release, we can safely
> experiment: we'll probably change this more while adding more handlers.
>
> > A Other nice solution ( which i had in mind) is to create an
> > AbstractCommandHandler which support all needed methods for a "real"
> > api. So the developer must extend it to implement a CommandHandler. I
> > will commit some code for this later. Then we can see what is better..
> >
> > Any problems here with a Abstract class ?
>
> Abstract classes are good.
>
> Stefano
>
Thx Stefano for answer. I did the last commit this mornin. Now i think
its more api like. Im not sure if we should maybe implement the
Configurable,Servicable and Initizisable interface in the Abstractclass
and provide the methods for extended classes from there. So the Handler
must not know about it.
Another think we could think about is to create methods in the Abstract
methods which return for example the dnserver. So the commandHandler
muts not know how to lookup it ( It could do this anyway if someone
want)
Something like:
public void service(ServiceManager serviceMan) throws ServiceException {
setDataSources((DataSourceSelector) serviceMan.lookup(DataSourceSelector.ROLE));
setDnsServer((DNSServer) serviceMan.lookup(DNSServer.ROLE));
}
public DNSService getDnsService() {
..
}
public void setDnsService(DNSService dnsService) {
this.dnsService = dnsService;
}
public DataSourceSelector getDataSourceSelector() {
..
}
public void setDataSourceSelector(DataSourceSelector dataSource) {
this.dataSource = dataSource;
}
IF someone need a special component he could use the norman service
method to access it. IMO that make sense.
Any comments ?
bye
Norman