org.apache.mina.filter.codec
Class ProtocolCodecSession

java.lang.Object
  extended by org.apache.mina.core.session.AbstractIoSession
      extended by org.apache.mina.core.session.DummySession
          extended by org.apache.mina.filter.codec.ProtocolCodecSession
All Implemented Interfaces:
IoSession

public class ProtocolCodecSession
extends DummySession

A virtual IoSession that provides ProtocolEncoderOutput and ProtocolDecoderOutput. It is useful for unit-testing codec and reusing codec for non-network-use (e.g. serialization).

Encoding

 ProtocolCodecSession session = new ProtocolCodecSession();
 ProtocolEncoder encoder = ...;
 MessageX in = ...;

 encoder.encode(session, in, session.getProtocolEncoderOutput());

 IoBuffer buffer = session.getProtocolDecoderOutputQueue().poll();
 

Decoding

 ProtocolCodecSession session = new ProtocolCodecSession();
 ProtocolDecoder decoder = ...;
 IoBuffer in = ...;

 decoder.decode(session, in, session.getProtocolDecoderOutput());

 Object message = session.getProtocolDecoderOutputQueue().poll();
 

Version:
$Rev: 713125 $, $Date: 2008-11-11 20:32:26 +0100 (Di, 11 Nov 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
ProtocolCodecSession()
          Creates a new instance.
 
Method Summary
 ProtocolDecoderOutput getDecoderOutput()
          Returns the ProtocolEncoderOutput that buffers messages generated by ProtocolDecoder.
 Queue<Object> getDecoderOutputQueue()
          Returns the Queue of the buffered decoder output.
 ProtocolEncoderOutput getEncoderOutput()
          Returns the ProtocolEncoderOutput that buffers IoBuffers generated by ProtocolEncoder.
 Queue<Object> getEncoderOutputQueue()
          Returns the Queue of the buffered encoder output.
 
Methods inherited from class org.apache.mina.core.session.DummySession
getConfig, getFilterChain, getHandler, getLocalAddress, getProcessor, getRemoteAddress, getService, getTransportMetadata, setConfig, setHandler, setLocalAddress, setRemoteAddress, setScheduledWriteBytes, setScheduledWriteMessages, setService, setTransportMetadata, updateThroughput
 
Methods inherited from class org.apache.mina.core.session.AbstractIoSession
close, close, containsAttribute, decreaseReadBufferSize, decreaseScheduledBytesAndMessages, equals, getAttachment, getAttribute, getAttribute, getAttributeKeys, getAttributeMap, getBothIdleCount, getCloseFuture, getCreationTime, getCurrentWriteMessage, getCurrentWriteRequest, getId, getIdleCount, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getServiceAddress, getWriteRequestQueue, getWriterIdleCount, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, hashCode, increaseIdleCount, increaseReadBufferSize, increaseReadBytes, increaseReadMessages, increaseScheduledWriteBytes, increaseScheduledWriteMessages, increaseWrittenBytes, increaseWrittenMessages, isBothIdle, isClosing, isConnected, isIdle, isReaderIdle, isReadSuspended, isScheduledForFlush, isWriterIdle, isWriteSuspended, notifyIdleness, notifyIdleSession, offerClosedReadFuture, offerFailedReadFuture, offerReadFuture, read, removeAttribute, removeAttribute, replaceAttribute, resumeRead, resumeWrite, setAttachment, setAttribute, setAttribute, setAttributeIfAbsent, setAttributeIfAbsent, setAttributeMap, setCurrentWriteRequest, setScheduledForFlush, setWriteRequestQueue, suspendRead, suspendWrite, toString, updateThroughput, write, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProtocolCodecSession

public ProtocolCodecSession()
Creates a new instance.

Method Detail

getEncoderOutput

public ProtocolEncoderOutput getEncoderOutput()
Returns the ProtocolEncoderOutput that buffers IoBuffers generated by ProtocolEncoder.


getEncoderOutputQueue

public Queue<Object> getEncoderOutputQueue()
Returns the Queue of the buffered encoder output.


getDecoderOutput

public ProtocolDecoderOutput getDecoderOutput()
Returns the ProtocolEncoderOutput that buffers messages generated by ProtocolDecoder.


getDecoderOutputQueue

public Queue<Object> getDecoderOutputQueue()
Returns the Queue of the buffered decoder output.



Copyright © 2004-2009 Apache MINA Project. All Rights Reserved.