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, event, 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
parent.
Please note that this method can be invoked more than once if
this filter is added to more than one parents. This method is not
invoked before IoFilter.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
parent.
Please note that this method can be invoked more than once if
this filter is removed from more than one parents.
This method is always invoked before IoFilter.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
IoHandler.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
IoSession.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
IoHandler.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–2024 Apache MINA Project. All rights reserved.