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 <no...@apache.org> on 2009/08/23 20:51:50 UTC

Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Hi Robert,

I'm not sure if I like the idea of moving all this methods to the
SMTPSession. Things like the HelloName etc seems to make more sense to
resist in the ConfigurationData.These are stuff which belongs to the
config and will never change in the SMTPSession.

Bye,
Norman

2009/8/23  <rd...@apache.org>:
> Author: rdonkin
> Date: Sun Aug 23 14:13:55 2009
> New Revision: 806973
>
> URL: http://svn.apache.org/viewvc?rev=806973&view=rev
> Log:
> Replace getter for configuration data with direct calls
>
> Modified:
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/HeloCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/QuitCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/WelcomeMessageHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java
>    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
>    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AbstractSMTPSession.java
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java Sun Aug 23 14:13:55 2009
> @@ -28,9 +28,11 @@
>  import java.util.Map;
>  import java.util.Random;
>
> +import org.apache.james.api.user.UsersRepository;
>  import org.apache.james.socket.ProtocolHandler;
>  import org.apache.james.socket.ProtocolHandlerHelper;
>  import org.apache.james.socket.CRLFDelimitedByteBuffer;
> +import org.apache.james.services.MailServer;
>
>  /**
>  * Provides SMTP functionality by carrying out the server side of the SMTP
> @@ -397,5 +399,32 @@
>        public void setProtocolHandlerHelper(ProtocolHandlerHelper phh) {
>                helper = phh;
>        }
> +
> +    public String getHelloName() {
> +        return getConfigurationData().getHelloName();
> +    }
> +
> +    public MailServer getMailServer() {
> +        return getConfigurationData().getMailServer();
> +    }
>
> +    public long getMaxMessageSize() {
> +        return getConfigurationData().getMaxMessageSize();
> +    }
> +
> +    public String getSMTPGreeting() {
> +        return getConfigurationData().getSMTPGreeting();
> +    }
> +
> +    public UsersRepository getUsersRepository() {
> +        return getConfigurationData().getUsersRepository();
> +    }
> +
> +    public boolean useAddressBracketsEnforcement() {
> +        return getConfigurationData().useAddressBracketsEnforcement();
> +    }
> +
> +    public boolean useHeloEhloEnforcement() {
> +        return getConfigurationData().useAddressBracketsEnforcement();
> +    }
>  }
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java Sun Aug 23 14:13:55 2009
> @@ -21,6 +21,9 @@
>
>  import java.util.Map;
>
> +import org.apache.james.api.user.UsersRepository;
> +import org.apache.james.services.MailServer;
> +
>  /**
>  * All the handlers access this interface to communicate with
>  * SMTPHandler object
> @@ -63,13 +66,58 @@
>     void resetState();
>
>     /**
> -     * Returns SMTPHandler service wide configuration
> +     * Returns the MailServer interface for this service.
>      *
> -     * @return SMTPHandlerConfigurationData
> +     * @return the MailServer interface for this service
> +     * @deprecated this service should be injection
>      */
> -    SMTPHandlerConfigurationData getConfigurationData();
> +    MailServer getMailServer();
> +
> +    /**
> +     * Returns the UsersRepository for this service.
> +     *
> +     * @return the local users repository
> +     * @deprecated this service should be injection
> +     */
> +    UsersRepository getUsersRepository();
>
>     /**
> +     * Returns the service wide hello name
> +     *
> +     * @return the hello name
> +     */
> +    String getHelloName();
> +
> +    /**
> +     * Returns whether the remote server needs to send a HELO/EHLO
> +     * of its senders.
> +     *
> +     * @return whether SMTP authentication is on
> +     */
> +    boolean useHeloEhloEnforcement();
> +
> +    /**
> +     * Return the SMTPGreeting which should used.
> +     *
> +     * @return the SMTPGreeting
> +     */
> +    String getSMTPGreeting();
> +
> +    /**
> +     * Returns the service wide maximum message size in bytes.
> +     *
> +     * @return the maximum message size
> +     */
> +    long getMaxMessageSize();
> +
> +    /**
> +     * Return wheter the mailserver will accept addresses without brackets enclosed.
> +     *
> +     * @return true or false
> +     */
> +    boolean useAddressBracketsEnforcement();
> +
> +    /**
>      * Returns whether Relaying is allowed or not
>      *
>      * @return the relaying status
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java Sun Aug 23 14:13:55 2009
> @@ -41,7 +41,7 @@
>             MailAddress rcpt) {
>         if (!session.isRelayingAllowed()) {
>             String toDomain = rcpt.getDomain();
> -            if (!session.getConfigurationData().getMailServer().isLocalServer(toDomain)) {
> +            if (!session.getMailServer().isLocalServer(toDomain)) {
>                 if (session.isAuthSupported()) {
>                     return new HookResult(HookReturnCode.DENY,
>                             SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -131,7 +131,7 @@
>  //        }
>
>         try {
> -            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(session.getConfigurationData().getMailServer().getId());
> +            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(session.getMailServer().getId());
>             OutputStream out = mmiss.getWritableOutputStream();
>
>             // Prepend output headers with out Received
> @@ -226,7 +226,7 @@
>         headerLineBuffer.delete(0, headerLineBuffer.length());
>
>         headerLineBuffer.append("          by ")
> -                        .append(session.getConfigurationData().getHelloName())
> +                        .append(session.getHelloName())
>                         .append(" (")
>                         .append(SOFTWARE_TYPE)
>                         .append(") with ");
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java Sun Aug 23 14:13:55 2009
> @@ -67,7 +67,7 @@
>
>                 List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
>                 MailImpl mail =
> -                    new MailImpl(session.getConfigurationData().getMailServer().getId(),
> +                    new MailImpl(session.getMailServer().getId(),
>                                  (MailAddress) session.getState().get(SMTPSession.SENDER),
>                                  recipientCollection);
>                 MimeMessageCopyOnWriteProxy mimeMessageCopyOnWriteProxy = null;
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/HeloCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/HeloCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/HeloCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/HeloCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -60,7 +60,7 @@
>         session.getConnectionState().put(SMTPSession.CURRENT_HELO_MODE,
>                 COMMAND_NAME);
>         StringBuffer response = new StringBuffer();
> -        response.append(session.getConfigurationData().getHelloName()).append(
> +        response.append(session.getHelloName()).append(
>                 " Hello ").append(parameters).append(" (").append(
>                 session.getRemoteHost()).append(" [").append(
>                 session.getRemoteIPAddress()).append("])");
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -135,7 +135,7 @@
>                     + " Sender already specified");
>         } else if (!session.getConnectionState().containsKey(
>                 SMTPSession.CURRENT_HELO_MODE)
> -                && session.getConfigurationData().useHeloEhloEnforcement()) {
> +                && session.useHeloEhloEnforcement()) {
>             return new SMTPResponse(SMTPRetCode.BAD_SEQUENCE, DSNStatus
>                     .getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_OTHER)
>                     + " Need HELO or EHLO before MAIL");
> @@ -195,7 +195,7 @@
>                     }
>                 }
>             }
> -            if (session.getConfigurationData().useAddressBracketsEnforcement()
> +            if (session.useAddressBracketsEnforcement()
>                     && (!sender.startsWith("<") || !sender.endsWith(">"))) {
>                 if (getLogger().isErrorEnabled()) {
>                     StringBuffer errorBuffer = new StringBuffer(128).append(
> @@ -210,7 +210,7 @@
>             }
>             MailAddress senderAddress = null;
>
> -            if (session.getConfigurationData().useAddressBracketsEnforcement()
> +            if (session.useAddressBracketsEnforcement()
>                     || (sender.startsWith("<") && sender.endsWith(">"))) {
>                 // Remove < and >
>                 sender = sender.substring(1, sender.length() - 1);
> @@ -223,7 +223,7 @@
>                 if (sender.indexOf("@") < 0) {
>                     sender = sender
>                             + "@"
> -                            + session.getConfigurationData().getMailServer()
> +                            + session.getMailServer()
>                                     .getDefaultDomain();
>                 }
>
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/QuitCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/QuitCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/QuitCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/QuitCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -55,7 +55,7 @@
>             response.append(
>                     DSNStatus.getStatus(DSNStatus.SUCCESS,
>                             DSNStatus.UNDEFINED_STATUS)).append(" ").append(
> -                    session.getConfigurationData().getHelloName()).append(
> +                    session.getHelloName()).append(
>                     " Service closing transmission channel");
>             ret = new SMTPResponse(SMTPRetCode.SYSTEM_QUIT, response);
>         } else {
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -117,7 +117,7 @@
>             // Remove the options from the recipient
>             recipient = recipient.substring(0, lastChar + 1);
>         }
> -        if (session.getConfigurationData().useAddressBracketsEnforcement()
> +        if (session.useAddressBracketsEnforcement()
>                 && (!recipient.startsWith("<") || !recipient.endsWith(">"))) {
>             if (getLogger().isErrorEnabled()) {
>                 StringBuffer errorBuffer = new StringBuffer(192).append(
> @@ -133,7 +133,7 @@
>         }
>         MailAddress recipientAddress = null;
>         // Remove < and >
> -        if (session.getConfigurationData().useAddressBracketsEnforcement()
> +        if (session.useAddressBracketsEnforcement()
>                 || (recipient.startsWith("<") && recipient.endsWith(">"))) {
>             recipient = recipient.substring(1, recipient.length() - 1);
>         }
> @@ -142,8 +142,7 @@
>             // set the default domain
>             recipient = recipient
>                     + "@"
> -                    + session.getConfigurationData().getMailServer()
> -                            .getDefaultDomain();
> +                    + session.getMailServer().getDefaultDomain();
>         }
>
>         try {
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java Sun Aug 23 14:13:55 2009
> @@ -48,7 +48,7 @@
>
>             if ((senderAddress == null)
>                     || (!authUser.equals(senderAddress.getLocalPart()))
> -                    || (!session.getConfigurationData().getMailServer()
> +                    || (!session.getMailServer()
>                             .isLocalServer(senderAddress.getDomain()))) {
>                 return new HookResult(HookReturnCode.DENY,
>                         SMTPRetCode.BAD_SEQUENCE,
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java Sun Aug 23 14:13:55 2009
> @@ -31,7 +31,7 @@
>      * @see org.apache.james.smtpserver.hook.AuthHook#doAuth(org.apache.james.smtpserver.SMTPSession, java.lang.String, java.lang.String)
>      */
>     public HookResult doAuth(SMTPSession session, String username, String password) {
> -        if (session.getConfigurationData().getUsersRepository().test(username, password)) {
> +        if (session.getUsersRepository().test(username, password)) {
>             session.setUser(username);
>             session.setRelayingAllowed(true);
>             return new HookResult(HookReturnCode.OK, "Authentication Successful");
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/WelcomeMessageHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/WelcomeMessageHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/WelcomeMessageHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/WelcomeMessageHandler.java Sun Aug 23 14:13:55 2009
> @@ -49,7 +49,7 @@
>      * @see org.apache.james.smtpserver.ConnectHandler#onConnect(SMTPSession)
>      */
>     public void onConnect(SMTPSession session) {
> -        String smtpGreeting = session.getConfigurationData().getSMTPGreeting();
> +        String smtpGreeting = session.getSMTPGreeting();
>
>         SMTPResponse welcomeResponse;
>         // if no greeting was configured use a default
> @@ -58,7 +58,7 @@
>             // Format is:  Sat, 24 Jan 1998 13:16:09 -0500
>             welcomeResponse = new SMTPResponse(SMTPRetCode.SERVICE_READY,
>                           new StringBuffer(256)
> -                          .append(session.getConfigurationData().getHelloName())
> +                          .append(session.getHelloName())
>                           .append(" SMTP Server (")
>                           .append(SOFTWARE_TYPE)
>                           .append(") ready ")
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java Sun Aug 23 14:13:55 2009
> @@ -62,8 +62,7 @@
>         session.getConnectionState().put(SMTPSession.CURRENT_HELO_MODE,
>                 COMMAND_NAME);
>
> -        resp.appendLine(new StringBuffer(session.getConfigurationData()
> -                .getHelloName()).append(" Hello ").append(argument)
> +        resp.appendLine(new StringBuffer(session.getHelloName()).append(" Hello ").append(argument)
>                 .append(" (").append(session.getRemoteHost()).append(" [")
>                 .append(session.getRemoteIPAddress()).append("])"));
>
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java Sun Aug 23 14:13:55 2009
> @@ -51,8 +51,7 @@
>     public List<String> getImplementedEsmtpFeatures(SMTPSession session) {
>         LinkedList<String> resp = new LinkedList<String>();
>         // Extension defined in RFC 1870
> -        long maxMessageSize = session.getConfigurationData()
> -                .getMaxMessageSize();
> +        long maxMessageSize = session.getMaxMessageSize();
>         if (maxMessageSize > 0) {
>             resp.add("SIZE " + maxMessageSize);
>         }
> @@ -93,8 +92,7 @@
>                     size).append(".");
>             getLogger().debug(debugBuffer.toString());
>         }
> -        long maxMessageSize = session.getConfigurationData()
> -                .getMaxMessageSize();
> +        long maxMessageSize = session.getMaxMessageSize();
>         if ((maxMessageSize > 0) && (size > maxMessageSize)) {
>             // Let the client know that the size limit has been hit.
>             StringBuffer errorBuffer = new StringBuffer(256).append(
> @@ -140,7 +138,7 @@
>                     newSize = new Long(currentSize.intValue()+line.length);
>                 }
>
> -                if (session.getConfigurationData().getMaxMessageSize() > 0 && newSize.intValue() > session.getConfigurationData().getMaxMessageSize()) {
> +                if (session.getMaxMessageSize() > 0 && newSize.intValue() > session.getMaxMessageSize()) {
>                     // Add an item to the state to suppress
>                     // logging of extra lines of data
>                     // that are sent after the size limit has
> @@ -174,8 +172,7 @@
>                     .append(" (").append(session.getRemoteIPAddress())
>                     .append(") exceeding system maximum message size of ")
>                     .append(
> -                            session.getConfigurationData()
> -                                    .getMaxMessageSize());
> +                            session.getMaxMessageSize());
>             getLogger().error(errorBuffer.toString());
>             // TODO ???
>             // session.pushLineHandler(new DataCmdHandler.DataConsumerLineHandler());
>
> Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java (original)
> +++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java Sun Aug 23 14:13:55 2009
> @@ -171,7 +171,7 @@
>         if (!session.isRelayingAllowed()) {
>             boolean invalidUser = true;
>
> -            if (session.getConfigurationData().getUsersRepository().contains(rcpt.getLocalPart()) == true || recipients.contains(rcpt.toString().toLowerCase()) || domains.contains(rcpt.getDomain().toLowerCase())) {
> +            if (session.getUsersRepository().contains(rcpt.getLocalPart()) == true || recipients.contains(rcpt.toString().toLowerCase()) || domains.contains(rcpt.getDomain().toLowerCase())) {
>                 invalidUser = false;
>             }
>
>
> Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AbstractSMTPSession.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AbstractSMTPSession.java?rev=806973&r1=806972&r2=806973&view=diff
> ==============================================================================
> --- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AbstractSMTPSession.java (original)
> +++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AbstractSMTPSession.java Sun Aug 23 14:13:55 2009
> @@ -22,6 +22,9 @@
>
>  import java.util.Map;
>
> +import org.apache.james.api.user.UsersRepository;
> +import org.apache.james.services.MailServer;
> +
>  /**
>  * Abstract class to simplify the mocks
>  */
> @@ -148,4 +151,32 @@
>         throw new UnsupportedOperationException("Unimplemented Stub Method");
>     }
>
> +    public String getHelloName() {
> +        return getConfigurationData().getHelloName();
> +    }
> +
> +    public MailServer getMailServer() {
> +        return getConfigurationData().getMailServer();
> +    }
> +
> +    public long getMaxMessageSize() {
> +        return getConfigurationData().getMaxMessageSize();
> +    }
> +
> +    public String getSMTPGreeting() {
> +        return getConfigurationData().getSMTPGreeting();
> +    }
> +
> +    public UsersRepository getUsersRepository() {
> +        return getConfigurationData().getUsersRepository();
> +    }
> +
> +    public boolean useAddressBracketsEnforcement() {
> +        return getConfigurationData().useAddressBracketsEnforcement();
> +    }
> +
> +    public boolean useHeloEhloEnforcement() {
> +        return getConfigurationData().useAddressBracketsEnforcement();
> +    }
> +
>  }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Sun, Aug 30, 2009 at 8:38 PM, Robert Burrell
Donkin<ro...@gmail.com> wrote:
> On Wed, Aug 26, 2009 at 9:12 PM, Norman Maurer<no...@apache.org> wrote:
>> Im still thinkin we should just inject the "full" service if its needed.
>
> agreed: it's just hard to do ATM
>
> i'll try to take a look at doing this tomorrow

i've started to take a look at this now

it's going to require a number of preliminary changes to allow me to
use the LoaderService to construct the hooks. the integration relies
on the annotations to inject LoaderService into the SMTPServer, so i'm
going to need to switch AbstractJamesService to use them for
initialisation and inject the loader. this reference can then be
injected into the handler to construct the hooks. once this is done,
then the references can be injected by annotated setters.

- robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Wed, Aug 26, 2009 at 9:12 PM, Norman Maurer<no...@apache.org> wrote:
> Im still thinkin we should just inject the "full" service if its needed.

agreed: it's just hard to do ATM

i'll try to take a look at doing this tomorrow

- robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Posted by Norman Maurer <no...@apache.org>.
Im still thinkin we should just inject the "full" service if its needed.

Bye,
Norman

2009/8/23 Robert Burrell Donkin <ro...@gmail.com>:
> On Sun, Aug 23, 2009 at 7:51 PM, Norman Maurer<no...@apache.org> wrote:
>> Hi Robert,
>>
>> I'm not sure if I like the idea of moving all this methods to the
>> SMTPSession. Things like the HelloName etc seems to make more sense to
>> resist in the ConfigurationData.These are stuff which belongs to the
>> config and will never change in the SMTPSession.
>
> UserRepository and MailServer are coursely grained services. i've been
> taking a look at what's actually used from each.
>
> UserRepository:
>   boolean contains(String name)
>   boolean test(String name, String password)
>
> MailServer
>   boolean isLocalServer(String serverName);
>   String getId();
>   String getDefaultDomain();
>
> so most of the calls in these services aren't used
>
> the full services or new, more finely grained APIs could be injected,
> or these calls could just be pushed into the session
>
> opinions?
>
> - robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Sun, Aug 23, 2009 at 7:51 PM, Norman Maurer<no...@apache.org> wrote:
> Hi Robert,
>
> I'm not sure if I like the idea of moving all this methods to the
> SMTPSession. Things like the HelloName etc seems to make more sense to
> resist in the ConfigurationData.These are stuff which belongs to the
> config and will never change in the SMTPSession.

UserRepository and MailServer are coursely grained services. i've been
taking a look at what's actually used from each.

UserRepository:
   boolean contains(String name)
   boolean test(String name, String password)

MailServer
   boolean isLocalServer(String serverName);
   String getId();
   String getDefaultDomain();

so most of the calls in these services aren't used

the full services or new, more finely grained APIs could be injected,
or these calls could just be pushed into the session

opinions?

- robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r806973 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/ main/java/org/apache/james/smtpserver/core/ main/java/org/apache/james/smtpserver/core/esmtp/ main/java/org/apache/james/smtpserver/core/

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Sun, Aug 23, 2009 at 7:51 PM, Norman Maurer<no...@apache.org> wrote:
> Hi Robert,
>
> I'm not sure if I like the idea of moving all this methods to the
> SMTPSession. Things like the HelloName etc seems to make more sense to
> resist in the ConfigurationData.These are stuff which belongs to the
> config and will never change in the SMTPSession.

i agree

i would prefer to move all information that is set at configuration
time out from SMTPSession

these were included in the SMTPSession indirectly by the configuration
getter and are accessed as if they might change. the configuration
getter hide these references and prevented this being sorted out
properly.

one option would be to move the static configuration into a POJO
(SMTPConfiguration, say) and either use injection or a configuration
interface.

opinions?

- robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org