Interface IoFilter

    • Method Detail

      • init

        void init()
           throws java.lang.Exception
        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.
        Throws:
        java.lang.Exception - If an error occurred while processing the event
      • destroy

        void destroy()
              throws java.lang.Exception
        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.
        Throws:
        java.lang.Exception - If an error occurred while processing the event
      • onPreAdd

        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 before init() is invoked.
        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:
        java.lang.Exception - If an error occurred while processing the event
      • onPostAdd

        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 before init() is invoked.
        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:
        java.lang.Exception - If an error occurred while processing the event
      • onPreRemove

        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 before destroy() is invoked.
        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:
        java.lang.Exception - If an error occurred while processing the event
      • onPostRemove

        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 before destroy() is invoked.
        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:
        java.lang.Exception - If an error occurred while processing the event
      • exceptionCaught

        void exceptionCaught​(IoFilter.NextFilter nextFilter,
                             IoSession session,
                             java.lang.Throwable cause)
                      throws java.lang.Exception
        Parameters:
        nextFilter - 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 event
        cause - The exception that cause this event to be received
        Throws:
        java.lang.Exception - If an error occurred while processing the event
      • messageReceived

        void messageReceived​(IoFilter.NextFilter nextFilter,
                             IoSession session,
                             java.lang.Object message)
                      throws java.lang.Exception
        Parameters:
        nextFilter - 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 event
        message - The received message
        Throws:
        java.lang.Exception - If an error occurred while processing the event