public class DemuxingProtocolCodecFactory extends java.lang.Object implements ProtocolCodecFactory
ProtocolCodecFactory
that consists of multiple
MessageEncoder
s and MessageDecoder
s.
ProtocolEncoder
and ProtocolDecoder
this factory
returns demultiplex incoming messages and buffers to
appropriate MessageEncoder
s and MessageDecoder
s.
MessageEncoder
and MessageDecoder
Make your MessageEncoder
and MessageDecoder
to put all
resources that need to be released as a session attribute. disposeCodecResources(IoSession)
method will be invoked when a session is closed. Override disposeCodecResources(IoSession)
to release the resources you've put as an attribute.
We didn't provide any dispose method for MessageEncoder
and MessageDecoder
because they can give you a big performance penalty in case you have a lot of
message types to handle.
MessageEncoder
,
MessageDecoder
Constructor and Description |
---|
DemuxingProtocolCodecFactory() |
Modifier and Type | Method and Description |
---|---|
protected void |
disposeCodecResources(IoSession session)
Implement this method to release all resources acquired to perform
encoding and decoding messages for the specified session.
|
ProtocolDecoder |
getDecoder()
Returns a new (or reusable) instance of
ProtocolDecoder which
decodes binary or protocol-specific data into message objects. |
ProtocolEncoder |
getEncoder()
Returns a new (or reusable) instance of
ProtocolEncoder which
encodes message objects into binary or protocol-specific data. |
void |
register(java.lang.Class<?> encoderOrDecoderClass) |
void |
register(MessageDecoder decoder) |
void |
register(MessageDecoderFactory factory) |
void |
register(MessageEncoder encoder) |
void |
register(MessageEncoderFactory factory) |
public void register(java.lang.Class<?> encoderOrDecoderClass)
public void register(MessageEncoder encoder)
public void register(MessageEncoderFactory factory)
public void register(MessageDecoder decoder)
public void register(MessageDecoderFactory factory)
public ProtocolEncoder getEncoder() throws java.lang.Exception
ProtocolCodecFactory
ProtocolEncoder
which
encodes message objects into binary or protocol-specific data.getEncoder
in interface ProtocolCodecFactory
java.lang.Exception
public ProtocolDecoder getDecoder() throws java.lang.Exception
ProtocolCodecFactory
ProtocolDecoder
which
decodes binary or protocol-specific data into message objects.getDecoder
in interface ProtocolCodecFactory
java.lang.Exception
protected void disposeCodecResources(IoSession session)
session
- the session that requires resource deallocation nowCopyright © 2004-2019 Apache MINA Project. All Rights Reserved.