Package org.apache.mina.filter.util
Class ReferenceCountingFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.util.ReferenceCountingFilter
-
- All Implemented Interfaces:
IoFilter
public class ReferenceCountingFilter extends IoFilterAdapter
AnIoFilters wrapper that keeps track of the number of usages of this filter and will call init/destroy when the filter is not in use.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Constructor Summary
Constructors Constructor Description ReferenceCountingFilter(IoFilter filter)Creates a new ReferenceCountingFilter instance
-
Method Summary
-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, event, init, inputClosed, toString
-
-
-
-
Constructor Detail
-
ReferenceCountingFilter
public ReferenceCountingFilter(IoFilter filter)
Creates a new ReferenceCountingFilter instance- Parameters:
filter- the filter we are counting references on
-
-
Method Detail
-
onPreAdd
public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked before this filter is added to the specifiedparent. 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 beforeIoFilter.init()is invoked.- Specified by:
onPreAddin interfaceIoFilter- Overrides:
onPreAddin classIoFilterAdapter- Parameters:
parent- the parent who called this methodname- the name assigned to this filternextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception- If an error occurred while processing the event
-
onPostRemove
public void onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked after this filter is removed from the specifiedparent. 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 beforeIoFilter.destroy()is invoked.- Specified by:
onPostRemovein interfaceIoFilter- Overrides:
onPostRemovein classIoFilterAdapter- Parameters:
parent- the parent who called this methodname- the name assigned to this filternextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception- If an error occurred while processing the event
-
exceptionCaught
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
FiltersIoHandler.exceptionCaught(IoSession,Throwable)event.- Specified by:
exceptionCaughtin interfaceIoFilter- Overrides:
exceptionCaughtin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventcause- The exception that cause this event to be received- Throws:
Exception- If an error occurred while processing the event
-
filterClose
public void filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoSession.closeNow()or aIoSession.closeOnFlush()method invocations.- Specified by:
filterClosein interfaceIoFilter- Overrides:
filterClosein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has to process this method invocation- Throws:
Exception- If an error occurred while processing the event
-
filterWrite
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoSession.write(Object)method invocation.- Specified by:
filterWritein interfaceIoFilter- Overrides:
filterWritein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has to process this invocationwriteRequest- TheWriteRequestto process- Throws:
Exception- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws Exception
FiltersIoHandler.messageReceived(IoSession,Object)event.- Specified by:
messageReceivedin interfaceIoFilter- Overrides:
messageReceivedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventmessage- The received message- Throws:
Exception- If an error occurred while processing the event
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoHandler.messageSent(IoSession,Object)event.- Specified by:
messageSentin interfaceIoFilter- Overrides:
messageSentin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventwriteRequest- TheWriteRequestthat contains the sent message- Throws:
Exception- If an error occurred while processing the event
-
onPostAdd
public void onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked after this filter is added to the specifiedparent. 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 beforeIoFilter.init()is invoked.- Specified by:
onPostAddin interfaceIoFilter- Overrides:
onPostAddin classIoFilterAdapter- Parameters:
parent- the parent who called this methodname- the name assigned to this filternextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception- If an error occurred while processing the event
-
onPreRemove
public void onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked before this filter is removed from the specifiedparent. 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 beforeIoFilter.destroy()is invoked.- Specified by:
onPreRemovein interfaceIoFilter- Overrides:
onPreRemovein classIoFilterAdapter- Parameters:
parent- the parent who called this methodname- the name assigned to this filternextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionClosed(IoSession)event.- Specified by:
sessionClosedin interfaceIoFilter- Overrides:
sessionClosedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionCreated(IoSession)event.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)event.- Specified by:
sessionIdlein interfaceIoFilter- Overrides:
sessionIdlein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventstatus- TheIdleStatustype- Throws:
Exception- If an error occurred while processing the event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionOpened(IoSession)event.- Specified by:
sessionOpenedin interfaceIoFilter- Overrides:
sessionOpenedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
-