Author: jvermillard
Date: Tue Aug 30 06:43:26 2011
New Revision: 1163103
URL: http://svn.apache.org/viewvc?rev=1163103&view=rev
Log:
fixing issues with the filter chain
Modified:
mina/trunk/ (props changed)
mina/trunk/core/ (props changed)
mina/trunk/core/src/main/java/org/apache/mina/api/IoSession.java
mina/trunk/core/src/main/java/org/apache/mina/filterchain/DefaultIoFilterController.java
mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
mina/trunk/http/ (props changed)
mina/trunk/http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java
mina/trunk/pom.xml
Propchange: mina/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Aug 30 06:43:26 2011
@@ -1,5 +1,2 @@
-*.iws
-*.ipr
-*.iml
+.*
target
-.settings
Propchange: mina/trunk/core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Aug 30 06:43:26 2011
@@ -1,4 +1,2 @@
+.*
target
-.project
-.settings
-.classpath
Modified: mina/trunk/core/src/main/java/org/apache/mina/api/IoSession.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/api/IoSession.java?rev=1163103&r1=1163102&r2=1163103&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/api/IoSession.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/api/IoSession.java Tue Aug 30
06:43:26 2011
@@ -28,13 +28,11 @@ import org.apache.mina.service.SelectorP
import org.apache.mina.session.WriteRequest;
/**
- * A handle which represents a connection between two end-points regardless of
- * transport types.
+ * A handle which represents a connection between two end-points regardless of
transport types.
* <p/>
- * {@link IoSession} provides user-defined attributes. User-defined attributes
- * are application-specific data which are associated with a session. It often
- * contains objects that represents the state of a higher-level protocol and
- * becomes a way to exchange data between filters and handlers.
+ * {@link IoSession} provides user-defined attributes. User-defined attributes
are application-specific data which are
+ * associated with a session. It often contains objects that represents the
state of a higher-level protocol and becomes
+ * a way to exchange data between filters and handlers.
* <p/>
* <h3>Adjusting Transport Type Specific Properties</h3>
* <p/>
@@ -43,20 +41,19 @@ import org.apache.mina.session.WriteRequ
* <p/>
* <h3>Thread Safety</h3>
* <p/>
- * {@link IoSession} is thread-safe. But please note that performing more than
- * one {@link #write(Object)} calls at the same time will cause the
- * {@link IoFilter#filterWrite(IoFilter.NextFilter,IoSession,WriteRequest)} to
- * be executed simultaneously, and therefore you have to make sure the
- * {@link IoFilter} implementations you're using are thread-safe, too.
+ * {@link IoSession} is thread-safe. But please note that performing more than
one {@link #write(Object)} calls at the
+ * same time will cause the {@link
IoFilter#filterWrite(IoFilter.NextFilter,IoSession,WriteRequest)} to be executed
+ * simultaneously, and therefore you have to make sure the {@link IoFilter}
implementations you're using are
+ * thread-safe, too.
* </p>
- *
+ *
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public interface IoSession {
/**
* The unique identifier of this session.
- *
+ *
* @return the session's unique identifier
*/
long getId();
@@ -65,54 +62,48 @@ public interface IoSession {
/**
* Returns the socket address of remote peer.
- *
+ *
* @return the remote socket address
*/
SocketAddress getRemoteAddress();
/**
* Gets the local address of the local peer.
- *
- * @return the socket address of local machine which is associated with
this
- * session.
+ *
+ * @return the socket address of local machine which is associated with
this session.
*/
SocketAddress getLocalAddress();
/**
* Gets the service this session is attached to.
- *
- * @return the {@link IoService} which provides {@link IoSession} to this
- * session.
+ *
+ * @return the {@link IoService} which provides {@link IoSession} to this
session.
*/
IoService getService();
/* READ / WRITE / CLOSE */
/**
- * Tells if the session is currently connected and able to process incoming
- * requests and to send outgoing responses.
- *
+ * Tells if the session is currently connected and able to process
incoming requests and to send outgoing responses.
+ *
* @return <code>true</code> if this session is connected with remote peer.
*/
boolean isConnected();
/**
* Tells if the session is being closed, but is not yet in Closed state.
- *
+ *
* @return <code>true</tt> if and only if this session is being closed
* (but not disconnected yet) or is closed.
*/
boolean isClosing();
/**
- * Closes this session immediately or after all queued write requests are
- * flushed. This operation is asynchronous. Wait for the returned
- * {@link IoFuture} if you want to wait for the session actually closed.
- * Once this method has been called, no incoming request will be accepted.
- *
- * @param immediately
- * {@code true} to close this session immediately. {@code false}
- * to close this session after all queued write requests are
- * flushed.
+ * Closes this session immediately or after all queued write requests are
flushed. This operation is asynchronous.
+ * Wait for the returned {@link IoFuture} if you want to wait for the
session actually closed. Once this method has
+ * been called, no incoming request will be accepted.
+ *
+ * @param immediately {@code true} to close this session immediately.
{@code false} to close this session after all
+ * queued write requests are flushed.
* @return A {@link IoFuture} that will contains the session's state
*/
IoFuture<Void> close(boolean immediately);
@@ -140,69 +131,65 @@ public interface IoSession {
/**
* Is read operation is suspended for this session.
- *
+ *
* @return <code>true</code> if suspended
*/
boolean isReadSuspended();
/**
* Is write operation is suspended for this session.
- *
+ *
* @return <code>true</code> if suspended
*/
boolean isWriteSuspended();
/* BASIC STATS */
/**
- * Gets the total number of bytes read for this session since it was
- * created.
- *
+ * Gets the total number of bytes read for this session since it was
created.
+ *
* Returns the total number of bytes which were read from this session.
*/
long getReadBytes();
/**
- * Gets the total number of bytes written for this session since it was
- * created.
- *
+ * Gets the total number of bytes written for this session since it was
created.
+ *
* @return the total number of bytes which were written to this session.
*/
long getWrittenBytes();
/* IDLE management */
/**
- * Gets the session configuration, it where the idle timeout are set and
- * other transport specific configuration.
- *
+ * Gets the session configuration, it where the idle timeout are set and
other transport specific configuration.
+ *
* @return the session's configuration
*/
IoSessionConfig getConfig();
/**
* The session's creation time.
- *
+ *
* @return the session's creation time in milliseconds
*/
long getCreationTime();
/**
- * Returns the time in millisecond when I/O occurred lastly (either read or
- * write).
- *
+ * Returns the time in millisecond when I/O occurred lastly (either read
or write).
+ *
* @return the time of the last read or write done for this session
*/
long getLastIoTime();
/**
* Returns the time in millisecond when the last I/O read occurred.
- *
+ *
* Returns the time in millisecond when read operation occurred lastly.
*/
long getLastReadTime();
/**
* Returns the time in millisecond when the last I/O write occurred.
- *
+ *
* Returns the time in millisecond when write operation occurred lastly.
*/
long getLastWriteTime();
@@ -210,46 +197,39 @@ public interface IoSession {
/* Session context management */
/**
* Returns the value of the user-defined attribute for this session.
- *
- * @param name
- * the attribute's name
+ *
+ * @param name the attribute's name
* @return <tt>null</tt> if there is no attribute with the specified name
*/
- Object getAttribute(Object name);
+ <T> T getAttribute(String name);
/**
* Sets a user-defined attribute.
- *
- * @param name
- * the attribute's name
- * @param value
- * the attribute's value
- * @return The old attribute's value. <tt>null</tt> if there is no previous
- * value or if the value is null
+ *
+ * @param name the attribute's name
+ * @param value the attribute's value
+ * @return The old attribute's value. <tt>null</tt> if there is no
previous value or if the value is null
*/
- Object setAttribute(Object name, Object value);
+ <T> T setAttribute(String name, T value);
/**
* Removes a user-defined attribute with the specified name.
- *
- * @param name
- * the attribute's name
- * @return The old attribute's value. <tt>null</tt> if not found or if the
- * attribute had no value
+ *
+ * @param name the attribute's name
+ * @return The old attribute's value. <tt>null</tt> if not found or if the
attribute had no value
*/
Object removeAttribute(Object name);
/**
* Tells if the session has an attached attribute.
- *
- * @return <tt>true</tt> if this session contains the attribute with the
- * specified <tt>name</tt>.
+ *
+ * @return <tt>true</tt> if this session contains the attribute with the
specified <tt>name</tt>.
*/
boolean containsAttribute(Object name);
/**
* Gets the set of attributes stored within the session.
- *
+ *
* @return the set of names of all user-defined attributes.
*/
Set<Object> getAttributeNames();
@@ -258,9 +238,9 @@ public interface IoSession {
/**
* State of a {@link IoSession}
- *
+ *
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
- *
+ *
*/
public enum SessionState {
CREATED, CONNECTED, CLOSING, CLOSED
@@ -268,17 +248,16 @@ public interface IoSession {
/* SESSION WRITING */
/**
- * Enqueue a message for writing. This method wont block ! The message will
- * by asynchronously processed by the filter chain and wrote to socket by
- * the {@link SelectorProcessor}.
- *
+ * Enqueue a message for writing. This method wont block ! The message
will by asynchronously processed by the
+ * filter chain and wrote to socket by the {@link SelectorProcessor}.
+ *
*/
public void write(Object message);
/**
- * Same as {@link IoSession#write(Object)}, but provide a
- * {@link IoFuture} for tracking the completion of this write.
- *
+ * Same as {@link IoSession#write(Object)}, but provide a {@link IoFuture}
for tracking the completion of this
+ * write.
+ *
* @param message the message to be processed and written
* @return the {@link IoFuture} for tracking this asynchronous operation
*/
@@ -286,18 +265,21 @@ public interface IoSession {
/**
* Internal method for enqueue write request after {@link
IoFilterController} processing
+ *
* @param message
*/
public void enqueueWriteRequest(Object message);
/**
* Get the {@link Queue} of this session. The write queue contains the
pending writes.
+ *
* @return the write queue of this session
*/
public Queue<WriteRequest> getWriteQueue();
/**
* Get the filter chain in charge of filtering events generated by this
session.
+ *
* @return the filter chain for this session
*/
public IoFilterController getFilterChain();
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filterchain/DefaultIoFilterController.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filterchain/DefaultIoFilterController.java?rev=1163103&r1=1163102&r2=1163103&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/filterchain/DefaultIoFilterController.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/filterchain/DefaultIoFilterController.java
Tue Aug 30 06:43:26 2011
@@ -103,6 +103,7 @@ public class DefaultIoFilterController i
} else {
chain[writeChainPosition].messageWriting(session, message, this);
}
+ writeChainPosition++;
}
@Override
@@ -113,6 +114,7 @@ public class DefaultIoFilterController i
} else {
chain[readChainPosition].messageReceived(session, message, this);
}
+ readChainPosition--;
}
@Override
Modified:
mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java?rev=1163103&r1=1163102&r2=1163103&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
Tue Aug 30 06:43:26 2011
@@ -36,8 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Base implementation of {@link IoSession} shared with all the different
- * transports.
+ * Base implementation of {@link IoSession} shared with all the different
transports.
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
@@ -179,17 +178,19 @@ public abstract class AbstractIoSession
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
- public Object getAttribute(Object name) {
- return attributes.get(name);
+ public <T> T getAttribute(String name) {
+ return (T) attributes.get(name);
}
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
@Override
- public Object setAttribute(Object name, Object value) {
- return attributes.put(name, value);
+ public <T> T setAttribute(String name, T value) {
+ return (T) attributes.put(name, value);
}
/**
Propchange: mina/trunk/http/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Aug 30 06:43:26 2011
@@ -0,0 +1,2 @@
+.*
+target
Modified:
mina/trunk/http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java
URL:
http://svn.apache.org/viewvc/mina/trunk/http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java?rev=1163103&r1=1163102&r2=1163103&view=diff
==============================================================================
---
mina/trunk/http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java
(original)
+++
mina/trunk/http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java
Tue Aug 30 06:43:26 2011
@@ -21,4 +21,8 @@ package org.apache.mina.http.api;
public class HttpEndOfContent {
+ @Override
+ public String toString() {
+ return "HttpEndOfContent";
+ }
}
Modified: mina/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/mina/trunk/pom.xml?rev=1163103&r1=1163102&r2=1163103&view=diff
==============================================================================
--- mina/trunk/pom.xml (original)
+++ mina/trunk/pom.xml Tue Aug 30 06:43:26 2011
@@ -88,6 +88,7 @@
<modules>
<module>core</module>
+ <module>http</module>
</modules>
<dependencyManagement>