org.glassfish.grizzly.filterchain
Class TransportFilter

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

public class TransportFilter
extends BaseFilter

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: stream or message. In stream mode, TransportFilter produces/consumes the socket channel directly. In message mode, TransportFilter represents Connection data as Buffer, using FilterChainContext.getMessage()}, FilterChainContext.setMessage(Object). For specific Transport, one mode could be more preferable than another. For example TCPNIOTransport works just in stream mode. UDPNIOTransport prefers message mode, but could also work in stream mode.

Author:
Alexey Stashok

Nested Class Summary
static class TransportFilter.FlushEvent
           
 
Field Summary
static java.lang.String WORKER_THREAD_BUFFER_NAME
           
 
Constructor Summary
TransportFilter()
          Create TransportFilter.
 
Method Summary
static FilterChainEvent createFlushEvent()
           
static FilterChainEvent createFlushEvent(FutureImpl future, CompletionHandler completionHandler)
           
protected  Filter getTransportFilter0(Transport transport)
          Get default Transport specific transport filter.
 NextAction handleAccept(FilterChainContext ctx)
          Delegates accept operation to Transport's specific transport filter.
 NextAction handleClose(FilterChainContext ctx)
          Delegates close operation to Transport's specific transport filter.
 NextAction handleConnect(FilterChainContext ctx)
          Delegates connect operation to Transport's specific transport filter.
 NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event)
          Delegates event operation to Transport's specific transport filter.
 NextAction handleRead(FilterChainContext ctx)
          Delegates reading operation to Transport's specific transport filter.
 NextAction handleWrite(FilterChainContext ctx)
          Delegates writing operation to Transport's specific transport filter.
 
Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, getFilterChain, getIndex, onAdded, onFilterChainChanged, onRemoved
 
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 java.lang.String WORKER_THREAD_BUFFER_NAME
See Also:
Constant Field Values
Constructor Detail

TransportFilter

public TransportFilter()
Create TransportFilter.

Method Detail

createFlushEvent

public static FilterChainEvent createFlushEvent()

createFlushEvent

public static FilterChainEvent createFlushEvent(FutureImpl future,
                                                CompletionHandler completionHandler)

handleAccept

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

Specified by:
handleAccept in interface Filter
Overrides:
handleAccept in class BaseFilter
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
Delegates connect operation to Transport's specific transport filter.

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

handleRead

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

Specified by:
handleRead in interface Filter
Overrides:
handleRead in class BaseFilter
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
Delegates writing operation to Transport's specific transport filter.

Specified by:
handleWrite in interface Filter
Overrides:
handleWrite in class BaseFilter
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
Delegates event operation to Transport's specific transport filter.

Specified by:
handleEvent in interface Filter
Overrides:
handleEvent in class BaseFilter
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
Delegates close operation to Transport's specific transport filter.

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

getTransportFilter0

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

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


Copyright © 2011 Oracle Corpration. All Rights Reserved.