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
AnIoFilter
s 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Throwable cause)
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.void
filterClose(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoSession.closeNow()
or aIoSession.closeOnFlush()
method invocations.void
filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoSession.write(Object)
method invocation.void
messageReceived(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message)
FiltersIoHandler.messageReceived(IoSession,Object)
event.void
messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoHandler.messageSent(IoSession,Object)
event.void
onPostAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter)
Invoked after this filter is added to the specified parent.void
onPostRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specified parent.void
onPreAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified parent.void
onPreRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter)
Invoked before this filter is removed from the specified parent.void
sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionClosed(IoSession)
event.void
sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionCreated(IoSession)
event.void
sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.void
sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionOpened(IoSession)
event.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, 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, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
Invoked before this filter is added to the specified 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 beforeIoFilter.init()
is invoked.- Specified by:
onPreAdd
in interfaceIoFilter
- Overrides:
onPreAdd
in classIoFilterAdapter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
onPostRemove
public void onPostRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
Invoked after this filter is removed from the specified 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 beforeIoFilter.destroy()
is invoked.- Specified by:
onPostRemove
in interfaceIoFilter
- Overrides:
onPostRemove
in classIoFilterAdapter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
exceptionCaught
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Throwable cause) throws java.lang.Exception
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.- Specified by:
exceptionCaught
in interfaceIoFilter
- Overrides:
exceptionCaught
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventcause
- The exception that cause this event to be received- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
filterClose
public void filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
FiltersIoSession.closeNow()
or aIoSession.closeOnFlush()
method invocations.- Specified by:
filterClose
in interfaceIoFilter
- Overrides:
filterClose
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this method invocation- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
filterWrite
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws java.lang.Exception
FiltersIoSession.write(Object)
method invocation.- Specified by:
filterWrite
in interfaceIoFilter
- Overrides:
filterWrite
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this invocationwriteRequest
- TheWriteRequest
to process- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message) throws java.lang.Exception
FiltersIoHandler.messageReceived(IoSession,Object)
event.- Specified by:
messageReceived
in interfaceIoFilter
- Overrides:
messageReceived
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventmessage
- The received message- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws java.lang.Exception
FiltersIoHandler.messageSent(IoSession,Object)
event.- Specified by:
messageSent
in interfaceIoFilter
- Overrides:
messageSent
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventwriteRequest
- TheWriteRequest
that contains the sent message- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
onPostAdd
public void onPostAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
Invoked after this filter is added to the specified 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 beforeIoFilter.init()
is invoked.- Specified by:
onPostAdd
in interfaceIoFilter
- Overrides:
onPostAdd
in classIoFilterAdapter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
onPreRemove
public void onPreRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
Invoked before this filter is removed from the specified 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 beforeIoFilter.destroy()
is invoked.- Specified by:
onPreRemove
in interfaceIoFilter
- Overrides:
onPreRemove
in classIoFilterAdapter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
FiltersIoHandler.sessionClosed(IoSession)
event.- Specified by:
sessionClosed
in interfaceIoFilter
- Overrides:
sessionClosed
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
FiltersIoHandler.sessionCreated(IoSession)
event.- Specified by:
sessionCreated
in interfaceIoFilter
- Overrides:
sessionCreated
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws java.lang.Exception
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.- Specified by:
sessionIdle
in interfaceIoFilter
- Overrides:
sessionIdle
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventstatus
- TheIdleStatus
type- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
FiltersIoHandler.sessionOpened(IoSession)
event.- Specified by:
sessionOpened
in interfaceIoFilter
- Overrides:
sessionOpened
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
java.lang.Exception
- If an error occurred while processing the event
-
-