public class ProtocolCodecFilter extends IoFilterAdapter
IoFilter which translates binary or protocol specific data into
message objects and vice versa using ProtocolCodecFactory,
ProtocolEncoder, or ProtocolDecoder.IoFilter.NextFilter| Constructor and Description |
|---|
ProtocolCodecFilter(Class<? extends ProtocolEncoder> encoderClass,
Class<? extends ProtocolDecoder> decoderClass)
Creates a new instance of ProtocolCodecFilter, without any factory.
|
ProtocolCodecFilter(ProtocolCodecFactory factory)
Creates a new instance of ProtocolCodecFilter, associating a factory
for the creation of the encoder and decoder.
|
ProtocolCodecFilter(ProtocolEncoder encoder,
ProtocolDecoder decoder)
Creates a new instance of ProtocolCodecFilter, without any factory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoSession.write(Object) method invocation. |
ProtocolEncoder |
getEncoder(IoSession session)
Get the encoder instance from a given session.
|
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
Object message)
Process the incoming message, calling the session decoder.
|
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoHandler.messageSent(IoSession,Object) event. |
void |
onPostRemove(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specified parent.
|
void |
onPreAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified parent.
|
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionClosed(IoSession) event. |
destroy, exceptionCaught, filterClose, init, inputClosed, onPostAdd, onPreRemove, sessionCreated, sessionIdle, sessionOpened, toStringpublic ProtocolCodecFilter(ProtocolCodecFactory factory)
factory - The associated factorypublic ProtocolCodecFilter(ProtocolEncoder encoder, ProtocolDecoder decoder)
encoder - The class responsible for encoding the messagedecoder - The class responsible for decoding the messagepublic ProtocolCodecFilter(Class<? extends ProtocolEncoder> encoderClass, Class<? extends ProtocolDecoder> decoderClass)
encoderClass - The class responsible for encoding the messagedecoderClass - The class responsible for decoding the messagepublic ProtocolEncoder getEncoder(IoSession session)
session - The associated session we will get the encoder frompublic void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
IoFilterAdapterIoFilter.init() is invoked.onPreAdd in interface IoFilteronPreAdd in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventpublic void onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
IoFilterAdapterIoFilter.destroy() is invoked.onPostRemove in interface IoFilteronPostRemove in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventpublic void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws Exception
messageReceived in interface IoFiltermessageReceived in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventmessage - The received messageException - If an error occurred while processing the eventpublic void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
IoFilterAdapterIoHandler.messageSent(IoSession,Object) event.messageSent in interface IoFiltermessageSent in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventwriteRequest - The WriteRequest that contains the sent messageException - If an error occurred while processing the eventpublic void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
IoFilterAdapterIoSession.write(Object) method invocation.filterWrite in interface IoFilterfilterWrite in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this invocationwriteRequest - The WriteRequest to processException - If an error occurred while processing the eventpublic void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoFilterAdapterIoHandler.sessionClosed(IoSession) event.sessionClosed in interface IoFiltersessionClosed in class IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventCopyright © 2004–2017 Apache MINA Project. All rights reserved.