Class DecodingStateProtocolDecoder
- java.lang.Object
-
- org.apache.mina.filter.codec.statemachine.DecodingStateProtocolDecoder
-
- All Implemented Interfaces:
ProtocolDecoder
public class DecodingStateProtocolDecoder extends Object implements ProtocolDecoder
ProtocolDecoder
which uses aDecodingState
to decode data. Use aDecodingStateMachine
asDecodingState
to create a state machine which can decode your protocol.NOTE: This is a stateful decoder. You should create one instance per session.
- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description DecodingStateProtocolDecoder(DecodingState state)
Creates a new instance using the specifiedDecodingState
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
Decodes binary or protocol-specific content into higher-level message objects.void
dispose(IoSession session)
Releases all resources related with this decoder.void
finishDecode(IoSession session, ProtocolDecoderOutput out)
Invoked when the specified session is closed.
-
-
-
Constructor Detail
-
DecodingStateProtocolDecoder
public DecodingStateProtocolDecoder(DecodingState state)
Creates a new instance using the specifiedDecodingState
instance.- Parameters:
state
- theDecodingState
.- Throws:
IllegalArgumentException
- if the specified state isnull
.
-
-
Method Detail
-
decode
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
Decodes binary or protocol-specific content into higher-level message objects. MINA invokesProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput
.- Specified by:
decode
in interfaceProtocolDecoder
- Parameters:
session
- The current Sessionin
- the buffer to decodeout
- TheProtocolDecoderOutput
that will receive the decoded message- Throws:
Exception
- if the read data violated protocol specification
-
finishDecode
public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception
Invoked when the specified session is closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response without content-length header. Implement this method to process the remaining data thatProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method didn't process completely.- Specified by:
finishDecode
in interfaceProtocolDecoder
- Parameters:
session
- The current Sessionout
- TheProtocolDecoderOutput
that contains the decoded message- Throws:
Exception
- if the read data violated protocol specification
-
dispose
public void dispose(IoSession session) throws Exception
Releases all resources related with this decoder.- Specified by:
dispose
in interfaceProtocolDecoder
- Parameters:
session
- The current Session- Throws:
Exception
- if failed to dispose all resources
-
-