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 no...@apache.org on 2011/12/22 21:00:03 UTC
svn commit: r1222414 - in /james/protocols/trunk:
api/src/main/java/org/apache/james/protocols/api/
smtp/src/test/java/org/apache/james/protocols/smtp/
Author: norman
Date: Thu Dec 22 20:00:03 2011
New Revision: 1222414
URL: http://svn.apache.org/viewvc?rev=1222414&view=rev
Log:
@deprecate ProtocolSession.getState() and ProtocolSession.getConnectionState(). See PROTOCOLS-63
Modified:
james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSession.java
james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java
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=1222414&r1=1222413&r2=1222414&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 Thu Dec 22 20:00:03 2011
@@ -31,6 +31,10 @@ import org.slf4j.Logger;
*/
public interface ProtocolSession {
+ public static enum State {
+ Connection,
+ Transaction
+ }
/**
* Gets the context sensitive log for this session.
* @return log, not null
@@ -39,10 +43,32 @@ public interface ProtocolSession {
/**
+ * Store the given value with the given key in the specified {@link State}. If you want to remove a value you need to use <code>null</code> as value
+ *
+ * @param key the key under which the value should get stored
+ * @param value the value which will get stored under the given key or <code>null</code> if you want to remove any value which is stored under the key
+ * @param state the {@link State} to which the mapping belongs
+ * @return oldValue the value which was stored before for this key or <code>null</code> if non was stored before.
+ */
+ Object setAttachment(String key, Object value, State state);
+
+ /**
+ * Return the value which is stored for the given key in the specified {@link State} or <code>null</code> if non was stored before.
+ *
+ * @param key the key under which the value should be searched
+ * @param state the {@link State} in which the value was stored for the key
+ * @return value the stored value for the key
+ */
+ Object getAttachment(String key, State state);
+
+
+ /**
* Return Map which can be used to store objects within a session
*
* @return state
+ * @deprecated use {@link #setAttachment(String, Object, State)}
*/
+ @Deprecated
Map<String, Object> getState();
@@ -50,7 +76,9 @@ public interface ProtocolSession {
* Returns Map that consists of the state of the {@link ProtocolSession} per connection
*
* @return map of the current {@link ProtocolSession} state per connection
+ * @deprecated use {@link #getAttachment(String, State)}
*/
+ @Deprecated
Map<String,Object> getConnectionState();
Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java?rev=1222414&r1=1222413&r2=1222414&view=diff
==============================================================================
--- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java (original)
+++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/ProtocolSessionImpl.java Thu Dec 22 20:00:03 2011
@@ -165,4 +165,36 @@ public class ProtocolSessionImpl impleme
return config;
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.protocols.api.ProtocolSession#setAttachment(java.lang.String, java.lang.Object, org.apache.james.protocols.api.ProtocolSession.State)
+ */
+ public Object setAttachment(String key, Object value, State state) {
+ if (state == State.Connection) {
+ if (value == null) {
+ return connectionState.remove(key);
+ } else {
+ return connectionState.put(key, value);
+ }
+ } else {
+ if (value == null) {
+ return sessionState.remove(key);
+ } else {
+ return sessionState.put(key, value);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.protocols.api.ProtocolSession#getAttachment(java.lang.String, org.apache.james.protocols.api.ProtocolSession.State)
+ */
+ public Object getAttachment(String key, State state) {
+ if (state == State.Connection) {
+ return connectionState.get(key);
+ } else {
+ return sessionState.get(key);
+ }
+ }
+
}
Modified: james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java?rev=1222414&r1=1222413&r2=1222414&view=diff
==============================================================================
--- james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java (original)
+++ james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java Thu Dec 22 20:00:03 2011
@@ -200,4 +200,12 @@ public class BaseFakeSMTPSession impleme
throw new UnsupportedOperationException("Unimplemented Stub Method");
}
+ public Object setAttachment(String key, Object value, State state) {
+ throw new UnsupportedOperationException("Unimplemented Stub Method");
+ }
+
+ public Object getAttachment(String key, State state) {
+ throw new UnsupportedOperationException("Unimplemented Stub Method");
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org