org.glassfish.grizzly.filterchain
Class BaseFilter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.BaseFilter
All Implemented Interfaces:
Filter
Direct Known Subclasses:
AbstractCodecFilter, ActivityCheckFilter, DelayFilter, EchoFilter, GZipFilter, IdleTimeoutFilter, LogFilter, LZMAFilter, SilentConnectionFilter, TCPNIOTransportFilter, TransportFilter, UDPNIOTransportFilter

public class BaseFilter
extends java.lang.Object
implements Filter

Provides empty implementation for Filter processing methods.

Author:
Alexey Stashok
See Also:
Filter

Constructor Summary
BaseFilter()
           
 
Method Summary
 FilterChainContext createContext(Connection connection, FilterChainContext.Operation operation)
           
 void exceptionOccurred(FilterChainContext ctx, java.lang.Throwable error)
          Notification about exception, occurred on the FilterChain
 FilterChain getFilterChain()
          Returns the FilterChain, which is executing this Filter on the current thread.
 int getIndex()
           
 NextAction handleAccept(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when server channel has accepted the client connection.
 NextAction handleClose(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when connection has been closed.
 NextAction handleConnect(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when channel gets connected.
 NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event)
          Handle custom event associated with the Connection.
 NextAction handleRead(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when channel will become available for reading.
 NextAction handleWrite(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when some data should be written on channel.
 void onAdded(FilterChain filterChain)
          Method is called, when the Filter has been added to the passed FilterChain.
 void onFilterChainChanged(FilterChain filterChain)
          Method is called, when the FilterChain this Filter is part of, has been changed.
 void onRemoved(FilterChain filterChain)
          Method is called, when the Filter has been removed from the passed FilterChain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseFilter

public BaseFilter()
Method Detail

onAdded

public void onAdded(FilterChain filterChain)
Description copied from interface: Filter
Method is called, when the Filter has been added to the passed FilterChain.

Specified by:
onAdded in interface Filter
Parameters:
filterChain - the FilterChain this Filter was added to.

onFilterChainChanged

public void onFilterChainChanged(FilterChain filterChain)
Description copied from interface: Filter
Method is called, when the FilterChain this Filter is part of, has been changed.

Specified by:
onFilterChainChanged in interface Filter
Parameters:
filterChain - the FilterChain.

onRemoved

public void onRemoved(FilterChain filterChain)
Description copied from interface: Filter
Method is called, when the Filter has been removed from the passed FilterChain.

Specified by:
onRemoved in interface Filter
Parameters:
filterChain - the FilterChain this Filter was removed from.

handleRead

public NextAction handleRead(FilterChainContext ctx)
                      throws java.io.IOException
Execute a unit of processing work to be performed, when channel will become available for reading. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleRead in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx)
                       throws java.io.IOException
Execute a unit of processing work to be performed, when some data should be written on channel. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleWrite in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleConnect

public NextAction handleConnect(FilterChainContext ctx)
                         throws java.io.IOException
Execute a unit of processing work to be performed, when channel gets connected. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleConnect in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleAccept

public NextAction handleAccept(FilterChainContext ctx)
                        throws java.io.IOException
Execute a unit of processing work to be performed, when server channel has accepted the client connection. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleAccept in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleEvent

public NextAction handleEvent(FilterChainContext ctx,
                              FilterChainEvent event)
                       throws java.io.IOException
Handle custom event associated with the Connection. This Filter may either complete the required processing and return StopAction, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning InvokeAction.

Specified by:
handleEvent in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleClose

public NextAction handleClose(FilterChainContext ctx)
                       throws java.io.IOException
Execute a unit of processing work to be performed, when connection has been closed. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleClose in interface Filter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

exceptionOccurred

public void exceptionOccurred(FilterChainContext ctx,
                              java.lang.Throwable error)
Notification about exception, occurred on the FilterChain

Specified by:
exceptionOccurred in interface Filter
Parameters:
ctx - event processing FilterChainContext
error - error, which occurred during FilterChain execution

getFilterChain

public FilterChain getFilterChain()
Returns the FilterChain, which is executing this Filter on the current thread.

Returns:
the FilterChain, which is currently executing this Filter

getIndex

public int getIndex()
Returns:
the index of this filter within the FilterChain.

createContext

public FilterChainContext createContext(Connection connection,
                                        FilterChainContext.Operation operation)


Copyright © 2011 Oracle Corpration. All Rights Reserved.