org.glassfish.grizzly.filterchain
Class TransportFilter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.FilterAdapter
      extended by org.glassfish.grizzly.filterchain.TransportFilter
All Implemented Interfaces:
Filter

public class TransportFilter
extends FilterAdapter

Transport Filter implementation, which should work with any Transport. This Filter tries to delegate I/O event processing to the Transport's specific transport Filter. If Transport doesn't have own implementation - uses common I/O event processing logic. TransportFilter could be set to work in 2 modes: TransportFilter.Mode.Stream or TransportFilter.Mode.Message. In the TransportFilter.Mode.Stream mode, TransportFilter produces/consumes Connection data using FilterChainContext.getStreamReader(), FilterChainContext.getStreamWriter(). In the TransportFilter.Mode.Message mode, TransportFilter represents Connection data as Buffer, using FilterChainContext#getMessage(}, FilterChainContext#setMessage(). For specific Transport, one mode could be more preferable than another. For example TCPNIOTransport works just in TransportFilter.Mode.Stream mode, UDPNIOTransport prefers TransportFilter.Mode.Message mode, but could also work in TransportFilter.Mode.Stream mode.

Author:
Alexey Stashok

Nested Class Summary
static class TransportFilter.Mode
           
 
Field Summary
static String WORKER_THREAD_BUFFER_NAME
           
 
Constructor Summary
TransportFilter()
          Create TransportFilter, which will operate in TransportFilter.Mode.Stream mode.
TransportFilter(TransportFilter.Mode mode)
          Create TransportFilter, which will operate in defined mode.
 
Method Summary
 TransportFilter.Mode getMode()
          Get the TransportFilter mode.
protected  Filter getTransportFilter0(Transport transport)
          Get default Transport specific transport filter.
 NextAction handleAccept(FilterChainContext ctx, NextAction nextAction)
          Delegates accept operation to Transport's specific transport filter.
 NextAction handleClose(FilterChainContext ctx, NextAction nextAction)
          Delegates close operation to Transport's specific transport filter.
 NextAction handleConnect(FilterChainContext ctx, NextAction nextAction)
          Delegates connect operation to Transport's specific transport filter.
 NextAction handleRead(FilterChainContext ctx, NextAction nextAction)
          Delegates reading operation to Transport's specific transport filter.
 NextAction handleWrite(FilterChainContext ctx, NextAction nextAction)
          Delegates writing operation to Transport's specific transport filter.
 NextAction postAccept(FilterChainContext ctx, NextAction nextAction)
          Delegates post accepting processing to Transport's specific transport filter.
 NextAction postClose(FilterChainContext ctx, NextAction nextAction)
          Delegates post closing processing to Transport's specific transport filter.
 NextAction postConnect(FilterChainContext ctx, NextAction nextAction)
          Delegates post connecting processing to Transport's specific transport filter.
 NextAction postRead(FilterChainContext ctx, NextAction nextAction)
          Delegates post reading processing to Transport's specific transport filter.
 NextAction postWrite(FilterChainContext ctx, NextAction nextAction)
          Delegates post writing processing to Transport's specific transport filter.
 
Methods inherited from class org.glassfish.grizzly.filterchain.FilterAdapter
exceptionOccurred, getFilterChain, getIndex, isIndexable, setIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKER_THREAD_BUFFER_NAME

public static final String WORKER_THREAD_BUFFER_NAME
See Also:
Constant Field Values
Constructor Detail

TransportFilter

public TransportFilter()
Create TransportFilter, which will operate in TransportFilter.Mode.Stream mode.


TransportFilter

public TransportFilter(TransportFilter.Mode mode)
Create TransportFilter, which will operate in defined mode.

Parameters:
mode -
Method Detail

getMode

public TransportFilter.Mode getMode()
Get the TransportFilter mode. TransportFilter could work in 2 modes: TransportFilter.Mode.Stream or TransportFilter.Mode.Message. In the TransportFilter.Mode.Stream mode, TransportFilter produces/consumes Connection data using FilterChainContext.getStreamReader(), FilterChainContext.getStreamWriter(). In the TransportFilter.Mode.Message mode, TransportFilter represents Connection data as Buffer, using FilterChainContext#getMessage(}, FilterChainContext#setMessage().

Returns:
the TransportFilter mode.

handleAccept

public NextAction handleAccept(FilterChainContext ctx,
                               NextAction nextAction)
                        throws IOException
Delegates accept operation to Transport's specific transport filter.

Specified by:
handleAccept in interface Filter
Overrides:
handleAccept in class FilterAdapter
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:
IOException

handleConnect

public NextAction handleConnect(FilterChainContext ctx,
                                NextAction nextAction)
                         throws IOException
Delegates connect operation to Transport's specific transport filter.

Specified by:
handleConnect in interface Filter
Overrides:
handleConnect in class FilterAdapter
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:
IOException

handleRead

public NextAction handleRead(FilterChainContext ctx,
                             NextAction nextAction)
                      throws IOException
Delegates reading operation to Transport's specific transport filter.

Specified by:
handleRead in interface Filter
Overrides:
handleRead in class FilterAdapter
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:
IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Delegates writing operation to Transport's specific transport filter.

Specified by:
handleWrite in interface Filter
Overrides:
handleWrite in class FilterAdapter
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:
IOException

handleClose

public NextAction handleClose(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Delegates close operation to Transport's specific transport filter.

Specified by:
handleClose in interface Filter
Overrides:
handleClose in class FilterAdapter
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:
IOException

postAccept

public NextAction postAccept(FilterChainContext ctx,
                             NextAction nextAction)
                      throws IOException
Delegates post accepting processing to Transport's specific transport filter.

Specified by:
postAccept in interface Filter
Overrides:
postAccept in class FilterAdapter
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:
IOException

postConnect

public NextAction postConnect(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Delegates post connecting processing to Transport's specific transport filter.

Specified by:
postConnect in interface Filter
Overrides:
postConnect in class FilterAdapter
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:
IOException

postRead

public NextAction postRead(FilterChainContext ctx,
                           NextAction nextAction)
                    throws IOException
Delegates post reading processing to Transport's specific transport filter.

Specified by:
postRead in interface Filter
Overrides:
postRead in class FilterAdapter
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:
IOException

postWrite

public NextAction postWrite(FilterChainContext ctx,
                            NextAction nextAction)
                     throws IOException
Delegates post writing processing to Transport's specific transport filter.

Specified by:
postWrite in interface Filter
Overrides:
postWrite in class FilterAdapter
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:
IOException

postClose

public NextAction postClose(FilterChainContext ctx,
                            NextAction nextAction)
                     throws IOException
Delegates post closing processing to Transport's specific transport filter.

Specified by:
postClose in interface Filter
Overrides:
postClose in class FilterAdapter
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:
IOException

getTransportFilter0

protected Filter getTransportFilter0(Transport transport)
Get default Transport specific transport filter.

Parameters:
transport - Transport.
Returns:
default Transport specific transport filter.


Copyright © 2009 SUN Microsystems. All Rights Reserved.