org.glassfish.grizzly.filterchain
Class FilterAdapter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.FilterAdapter
All Implemented Interfaces:
Filter
Direct Known Subclasses:
EchoFilter, IdleTimeoutFilter, SmartFilter, SSLFilter, TCPNIOTransportFilter, TransportFilter, UDPNIOMessageTransportFilter, UDPNIOStreamTransportFilter

public class FilterAdapter
extends Object
implements Filter

Provides empty implementation for Filter processing methods.

Author:
Alexey Stashok
See Also:
Filter

Constructor Summary
FilterAdapter()
           
 
Method Summary
 void exceptionOccurred(FilterChainContext ctx, Throwable error)
          Notification about exception, occured on the FilterChain
 FilterChain getFilterChain(Context ctx)
          Returns the FilterChain, which is executing this Filter on the current thread.
 int getIndex()
          Gets the Filter index.
 NextAction handleAccept(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when server channel has accepted the client connection.
 NextAction handleClose(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when connection has been closed.
 NextAction handleConnect(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when channel gets connected.
 NextAction handleRead(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when channel will become available for reading.
 NextAction handleWrite(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when channel will become available for writing.
 boolean isIndexable()
          Defines if this Filter could be indexed by a FilterChain in order to find neighbour Filters faster.
 NextAction postAccept(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleAccept(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postClose(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleClose(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postConnect(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleConnect(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postRead(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleRead(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postWrite(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleWrite(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 void setIndex(int index)
          Sets the Filter index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterAdapter

public FilterAdapter()
Method Detail

handleRead

public NextAction handleRead(FilterChainContext ctx,
                             NextAction nextAction)
                      throws 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
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

postRead

public NextAction postRead(FilterChainContext ctx,
                           NextAction nextAction)
                    throws IOException
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleRead(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postRead in interface Filter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Execute a unit of processing work to be performed, when channel will become available for writing. 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
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

postWrite

public NextAction postWrite(FilterChainContext ctx,
                            NextAction nextAction)
                     throws IOException
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleWrite(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postWrite in interface Filter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

handleConnect

public NextAction handleConnect(FilterChainContext ctx,
                                NextAction nextAction)
                         throws 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
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

postConnect

public NextAction postConnect(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleConnect(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postConnect in interface Filter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

handleAccept

public NextAction handleAccept(FilterChainContext ctx,
                               NextAction nextAction)
                        throws 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
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

postAccept

public NextAction postAccept(FilterChainContext ctx,
                             NextAction nextAction)
                      throws IOException
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleAccept(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postAccept in interface Filter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

handleClose

public NextAction handleClose(FilterChainContext ctx,
                              NextAction nextAction)
                       throws 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
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

postClose

public NextAction postClose(FilterChainContext ctx,
                            NextAction nextAction)
                     throws IOException
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleClose(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postClose in interface Filter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
{@link - java.io.IOException}
IOException

exceptionOccurred

public void exceptionOccurred(FilterChainContext ctx,
                              Throwable error)
Notification about exception, occured 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(Context ctx)
Returns the FilterChain, which is executing this Filter on the current thread. Because Filter could be shared among several FilterChain - we need IOEventContext to get the FilterChain, which is running this Filter

Parameters:
ctx - the execution IOEventContext
Returns:
the FilterChain, which is currently executing this Filter

isIndexable

public boolean isIndexable()
Defines if this Filter could be indexed by a FilterChain in order to find neighbour Filters faster. Most of the time it's very desired for a Filters to be indexable, but there are cases, when it's not appropriate, for example if single Filter instance should be shared among several FilterChains.

Specified by:
isIndexable in interface Filter
Returns:
true, if this Filter is indexable, or false otherwise.

getIndex

public int getIndex()
Gets the Filter index.

Specified by:
getIndex in interface Filter
Returns:
the Filter index.

setIndex

public void setIndex(int index)
Sets the Filter index.

Specified by:
setIndex in interface Filter
Parameters:
index - the Filter index.


Copyright © 2009 SUN Microsystems. All Rights Reserved.