You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2016/08/11 15:28:18 UTC
[08/10] mina git commit: Added a method to let the user set the
fragmentation option
Added a method to let the user set the fragmentation option
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/e5d3a647
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/e5d3a647
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/e5d3a647
Branch: refs/heads/2.0
Commit: e5d3a6477a01bb1b3c8ac18b7eeede8c5921cd03
Parents: d2aeee7
Author: Emmanuel L�charny <el...@symas.com>
Authored: Thu Aug 11 16:49:41 2016 +0200
Committer: Emmanuel L�charny <el...@symas.com>
Committed: Thu Aug 11 16:49:41 2016 +0200
----------------------------------------------------------------------
.../filter/codec/CumulativeProtocolDecoder.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/e5d3a647/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java b/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
index 227fbfd..ebeae0d 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
@@ -99,8 +99,13 @@ import org.apache.mina.core.session.IoSession;
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public abstract class CumulativeProtocolDecoder extends ProtocolDecoderAdapter {
-
+ /** The buffer used to store the data in the session */
private final AttributeKey BUFFER = new AttributeKey(getClass(), "buffer");
+
+ /** A flag set to true if we handle fragmentation accordingly to the TransportMetadata setting.
+ * It can be set to false if needed (UDP with fragments, for instance). the default value is 'true'
+ */
+ private boolean transportMetadataFragmentation = true;
/**
* Creates a new instance.
@@ -121,7 +126,7 @@ public abstract class CumulativeProtocolDecoder extends ProtocolDecoderAdapter {
* consuming the cumulative buffer.
*/
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
- if (!session.getTransportMetadata().hasFragmentation()) {
+ if (transportMetadataFragmentation && !session.getTransportMetadata().hasFragmentation()) {
while (in.hasRemaining()) {
if (!doDecode(session, in, out)) {
break;
@@ -241,4 +246,14 @@ public abstract class CumulativeProtocolDecoder extends ProtocolDecoderAdapter {
session.setAttribute(BUFFER, remainingBuf);
}
+
+ /**
+ * Let the user change the way we handle fragmentation. If set to <tt>false</tt>, the
+ * decode() method will not check the TransportMetadata fragmentation capability
+ *
+ * @param handleFragment The flag to set.
+ */
+ public void setTransportMetadataFragmentation(boolean transportMetadataFragmentation) {
+ this.transportMetadataFragmentation = transportMetadataFragmentation;
+ }
}