org.apache.mina.filter.util
Class ReferenceCountingFilter

java.lang.Object
  extended by org.apache.mina.core.filterchain.IoFilterAdapter
      extended by org.apache.mina.filter.util.ReferenceCountingFilter
All Implemented Interfaces:
IoFilter

public class ReferenceCountingFilter
extends IoFilterAdapter

An IoFilters 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
ReferenceCountingFilter(IoFilter filter)
           
 
Method Summary
 void destroy()
          Invoked by ReferenceCountingFilter when this filter is not used by any IoFilterChain anymore, so you can destroy shared resources.
 void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)
          Filters IoHandler.exceptionCaught(IoSession,Throwable) event.
 void filterClose(IoFilter.NextFilter nextFilter, IoSession session)
          Filters IoSession.close() method invocation.
 void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
          Filters IoSession.write(Object) method invocation.
 void init()
          Invoked by ReferenceCountingFilter when this filter is added to a IoFilterChain at the first time, so you can initialize shared resources.
 void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
          Filters IoHandler.messageReceived(IoSession,Object) event.
 void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
          Filters IoHandler.messageSent(IoSession,Object) event.
 void onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
          Invoked after this filter is added to the specified parent.
 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 onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
          Invoked before this filter is removed from the specified parent.
 void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
          Filters IoHandler.sessionClosed(IoSession) event.
 void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
          Filters IoHandler.sessionCreated(IoSession) event.
 void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
          Filters IoHandler.sessionIdle(IoSession,IdleStatus) event.
 void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
          Filters IoHandler.sessionOpened(IoSession) event.
 
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceCountingFilter

public ReferenceCountingFilter(IoFilter filter)
Method Detail

init

public void init()
          throws Exception
Description copied from class: IoFilterAdapter
Invoked by ReferenceCountingFilter when this filter is added to a IoFilterChain at the first time, so you can initialize shared resources. Please note that this method is never called if you don't wrap a filter with ReferenceCountingFilter.

Specified by:
init in interface IoFilter
Overrides:
init in class IoFilterAdapter
Throws:
Exception

destroy

public void destroy()
             throws Exception
Description copied from class: IoFilterAdapter
Invoked by ReferenceCountingFilter when this filter is not used by any IoFilterChain anymore, so you can destroy shared resources. Please note that this method is never called if you don't wrap a filter with ReferenceCountingFilter.

Specified by:
destroy in interface IoFilter
Overrides:
destroy in class IoFilterAdapter
Throws:
Exception

onPreAdd

public void onPreAdd(IoFilterChain parent,
                     String name,
                     IoFilter.NextFilter nextFilter)
              throws Exception
Description copied from class: IoFilterAdapter
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 before IoFilter.init() is invoked.

Specified by:
onPreAdd in interface IoFilter
Overrides:
onPreAdd in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

onPostRemove

public void onPostRemove(IoFilterChain parent,
                         String name,
                         IoFilter.NextFilter nextFilter)
                  throws Exception
Description copied from class: IoFilterAdapter
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 before IoFilter.destroy() is invoked.

Specified by:
onPostRemove in interface IoFilter
Overrides:
onPostRemove in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

exceptionCaught

public void exceptionCaught(IoFilter.NextFilter nextFilter,
                            IoSession session,
                            Throwable cause)
                     throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.exceptionCaught(IoSession,Throwable) event.

Specified by:
exceptionCaught in interface IoFilter
Overrides:
exceptionCaught in class IoFilterAdapter
Throws:
Exception

filterClose

public void filterClose(IoFilter.NextFilter nextFilter,
                        IoSession session)
                 throws Exception
Description copied from class: IoFilterAdapter
Filters IoSession.close() method invocation.

Specified by:
filterClose in interface IoFilter
Overrides:
filterClose in class IoFilterAdapter
Throws:
Exception

filterWrite

public void filterWrite(IoFilter.NextFilter nextFilter,
                        IoSession session,
                        WriteRequest writeRequest)
                 throws Exception
Description copied from class: IoFilterAdapter
Filters IoSession.write(Object) method invocation.

Specified by:
filterWrite in interface IoFilter
Overrides:
filterWrite in class IoFilterAdapter
Throws:
Exception

messageReceived

public void messageReceived(IoFilter.NextFilter nextFilter,
                            IoSession session,
                            Object message)
                     throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.messageReceived(IoSession,Object) event.

Specified by:
messageReceived in interface IoFilter
Overrides:
messageReceived in class IoFilterAdapter
Throws:
Exception

messageSent

public void messageSent(IoFilter.NextFilter nextFilter,
                        IoSession session,
                        WriteRequest writeRequest)
                 throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.messageSent(IoSession,Object) event.

Specified by:
messageSent in interface IoFilter
Overrides:
messageSent in class IoFilterAdapter
Throws:
Exception

onPostAdd

public void onPostAdd(IoFilterChain parent,
                      String name,
                      IoFilter.NextFilter nextFilter)
               throws Exception
Description copied from class: IoFilterAdapter
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 before IoFilter.init() is invoked.

Specified by:
onPostAdd in interface IoFilter
Overrides:
onPostAdd in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

onPreRemove

public void onPreRemove(IoFilterChain parent,
                        String name,
                        IoFilter.NextFilter nextFilter)
                 throws Exception
Description copied from class: IoFilterAdapter
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 before IoFilter.destroy() is invoked.

Specified by:
onPreRemove in interface IoFilter
Overrides:
onPreRemove in class IoFilterAdapter
Parameters:
parent - the parent who called this method
name - the name assigned to this filter
nextFilter - the IoFilter.NextFilter for this filter. You can reuse this object until this filter is removed from the chain.
Throws:
Exception

sessionClosed

public void sessionClosed(IoFilter.NextFilter nextFilter,
                          IoSession session)
                   throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.sessionClosed(IoSession) event.

Specified by:
sessionClosed in interface IoFilter
Overrides:
sessionClosed in class IoFilterAdapter
Throws:
Exception

sessionCreated

public void sessionCreated(IoFilter.NextFilter nextFilter,
                           IoSession session)
                    throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.sessionCreated(IoSession) event.

Specified by:
sessionCreated in interface IoFilter
Overrides:
sessionCreated in class IoFilterAdapter
Throws:
Exception

sessionIdle

public void sessionIdle(IoFilter.NextFilter nextFilter,
                        IoSession session,
                        IdleStatus status)
                 throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.sessionIdle(IoSession,IdleStatus) event.

Specified by:
sessionIdle in interface IoFilter
Overrides:
sessionIdle in class IoFilterAdapter
Throws:
Exception

sessionOpened

public void sessionOpened(IoFilter.NextFilter nextFilter,
                          IoSession session)
                   throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.sessionOpened(IoSession) event.

Specified by:
sessionOpened in interface IoFilter
Overrides:
sessionOpened in class IoFilterAdapter
Throws:
Exception


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.