Author: norman Date: Sun Sep 25 17:36:43 2011 New Revision: 1175439 URL: http://svn.apache.org/viewvc?rev=1175439&view=rev Log: Move getConnectionState() to the ProtocolSession and add implementation to AbstractSession
Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/AbstractSession.java james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/AbstractSession.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/AbstractSession.java?rev=1175439&r1=1175438&r2=1175439&view=diff ============================================================================== --- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/AbstractSession.java (original) +++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/AbstractSession.java Sun Sep 25 17:36:43 2011 @@ -20,6 +20,8 @@ package org.apache.james.protocols.api; import java.net.InetSocketAddress; +import java.util.HashMap; +import java.util.Map; import org.apache.james.protocols.api.FutureResponse.ResponseListener; @@ -33,6 +35,9 @@ import org.slf4j.Logger; * */ public abstract class AbstractSession implements ProtocolSession { + /** the Session state */ + final static String SESSION_STATE_MAP = "SESSION_STATE_MAP"; + protected InetSocketAddress socketAddress; private Logger logger; private SessionLog pLog = null; @@ -42,12 +47,15 @@ public abstract class AbstractSession im private String id; protected ProtocolTransport transport; + private Map<String, Object> connectionState; + public AbstractSession(Logger logger, ProtocolTransport transport) { this.transport = transport; this.socketAddress = transport.getRemoteAddress(); this.logger = logger; this.id = transport.getId(); + this.connectionState = new HashMap<String, Object>(); } /** @@ -138,5 +146,24 @@ public abstract class AbstractSession im } + /** + * @see org.apache.james.protocols.smtp.SMTPSession#getConnectionState() + */ + public Map<String, Object> getConnectionState() { + return connectionState; + } + + /** + * @see org.apache.james.protocols.smtp.SMTPSession#getState() + */ + @SuppressWarnings("unchecked") + public Map<String, Object> getState() { + Map<String, Object> res = (Map<String, Object>) getConnectionState().get(SESSION_STATE_MAP); + if (res == null) { + res = new HashMap<String, Object>(); + getConnectionState().put(SESSION_STATE_MAP, res); + } + return res; + } } Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java?rev=1175439&r1=1175438&r2=1175439&view=diff ============================================================================== --- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java (original) +++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java Sun Sep 25 17:36:43 2011 @@ -44,6 +44,15 @@ public interface ProtocolSession { */ Map<String, Object> getState(); + + /** + * Returns Map that consists of the state of the {@link ProtocolSession} per connection + * + * @return map of the current {@link ProtocolSession} state per connection + */ + Map<String,Object> getConnectionState(); + + /** * Reset the state */ Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java?rev=1175439&r1=1175438&r2=1175439&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java Sun Sep 25 17:36:43 2011 @@ -19,8 +19,6 @@ package org.apache.james.protocols.smtp; -import java.util.Map; - import org.apache.james.protocols.api.ProtocolSession; import org.apache.james.protocols.api.handler.LineHandler; @@ -39,8 +37,6 @@ public interface SMTPSession extends Pro /** HELO or EHLO */ final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; final static String CURRENT_HELO_NAME = "CURRENT_HELO_NAME"; - /** the Session state */ - final static String SESSION_STATE_MAP = "SESSION_STATE_MAP"; /** * Returns the service wide hello name @@ -108,13 +104,6 @@ public interface SMTPSession extends Pro int getRcptCount(); /** - * Returns Map that consists of the state of the SMTPSession per connection - * - * @return map of the current SMTPSession state per connection - */ - Map<String,Object> getConnectionState(); - - /** * Put a new line handler in the chain * @param overrideCommandHandler */ Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java?rev=1175439&r1=1175438&r2=1175439&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java Sun Sep 25 17:36:43 2011 @@ -19,8 +19,6 @@ package org.apache.james.protocols.smtp; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import org.apache.james.protocols.api.ProtocolTransport; import org.apache.james.protocols.api.AbstractSession; @@ -38,37 +36,15 @@ public class SMTPSessionImpl extends Abs private boolean relayingAllowed; - private Map<String, Object> connectionState; private SMTPConfiguration theConfigData; public SMTPSessionImpl(SMTPConfiguration theConfigData, Logger logger, ProtocolTransport transport) { super(logger, transport); this.theConfigData = theConfigData; - connectionState = new HashMap<String, Object>(); - relayingAllowed = theConfigData.isRelayingAllowed(getRemoteIPAddress()); } - /** - * @see org.apache.james.protocols.smtp.SMTPSession#getConnectionState() - */ - public Map<String, Object> getConnectionState() { - return connectionState; - } - - /** - * @see org.apache.james.protocols.smtp.SMTPSession#getState() - */ - @SuppressWarnings("unchecked") - public Map<String, Object> getState() { - Map<String, Object> res = (Map<String, Object>) getConnectionState().get(SMTPSession.SESSION_STATE_MAP); - if (res == null) { - res = new HashMap<String, Object>(); - getConnectionState().put(SMTPSession.SESSION_STATE_MAP, res); - } - return res; - } /** * @see org.apache.james.protocols.smtp.SMTPSession#isRelayingAllowed() --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org