com.sun.grizzly.portunif
Class PUReadFilter

java.lang.Object
  extended by com.sun.grizzly.filter.ReadFilter
      extended by com.sun.grizzly.portunif.PUReadFilter
All Implemented Interfaces:
ProtocolFilter, ReinvokeAware

public class PUReadFilter
extends ReadFilter

Port unification ReadFilter. Could be used for usecases, where on one TCP/UDP/... port several higher level protocols should be served (for example HTTP, HTTPS, IIOP). If input ByteBuffer is empty - ReadFilter logic will be executed in order to read request data.

Author:
Jean-Francois Arcand, Alexey Stashok

Field Summary
static long DEFAULT_READ_TIMEOUT
           
static String PROTOCOL_FINDERS
           
static String PROTOCOL_HANDLERS
           
static String PU_PRE_PROCESSORS
           
 
Fields inherited from class com.sun.grizzly.filter.ReadFilter
continousExecution, DELAYED_CLOSE_NOTIFICATION, readAttempts, UDP_SOCKETADDRESS
 
Fields inherited from interface com.sun.grizzly.ProtocolFilter
SUCCESSFUL_READ
 
Constructor Summary
PUReadFilter()
           
 
Method Summary
 void addPreProcessor(PUPreProcessor preProcessor)
          Add PUPreProcessor to preprocess income request
 void addProtocolFinder(ProtocolFinder protocolFinder)
          Add an instance of ProtocolFinder
 void addProtocolHandler(ProtocolHandler protocolHandler)
          Add an instance of ProtocolHandler
 void configure(List<ProtocolFinder> protocolFinders, List<ProtocolHandler> protocolHandlers, List<PUPreProcessor> preProcessors)
          Configures port unification depending on passed Lists
 void configure(Properties props)
          Configures port unification depending on passed Properties
 boolean execute(Context context)
          Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.
protected  ProtocolHandler getProtocolChainHandler(Context context, PUProtocolRequest protocolRequest)
          Returns filter chain ProtocolHandler, depending on current Context and PUProtocolRequest state
 long getReadTimeout()
          Get readTimeout.
 boolean processProtocolHandler(ProtocolHandler protocolHandler, Context context, PUProtocolRequest protocolRequest, boolean mapSelectionKey)
           
 void removePreProcessor(PUPreProcessor preProcessor)
          Remove PUPreProcessor from preprocess queue
 void removeProtocolFinder(ProtocolFinder protocolFinder)
          Remove a ProtocolFinder
 void removeProtocolHandler(ProtocolHandler protocolHandler)
          Remove a ProtocolHandler
 void setReadTimeout(long readTimeout)
          Set readTimeout.
 
Methods inherited from class com.sun.grizzly.filter.ReadFilter
checkEmptyRead, execute, getReadAttempts, isContinuousExecution, log, postExecute, setContinuousExecution, setReadAttempts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_READ_TIMEOUT

public static final long DEFAULT_READ_TIMEOUT
See Also:
Constant Field Values

PROTOCOL_FINDERS

public static final String PROTOCOL_FINDERS
See Also:
Constant Field Values

PROTOCOL_HANDLERS

public static final String PROTOCOL_HANDLERS
See Also:
Constant Field Values

PU_PRE_PROCESSORS

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

PUReadFilter

public PUReadFilter()
Method Detail

execute

public boolean execute(Context context)
                throws IOException
Description copied from class: ReadFilter
Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.

Specified by:
execute in interface ProtocolFilter
Overrides:
execute in class ReadFilter
Parameters:
context - Context
Returns:
true if the next ProtocolFilter on the ProtocolChain need to bve invoked.
Throws:
IOException

getProtocolChainHandler

protected ProtocolHandler getProtocolChainHandler(Context context,
                                                  PUProtocolRequest protocolRequest)
Returns filter chain ProtocolHandler, depending on current Context and PUProtocolRequest state

Parameters:
context -
protocolRequest -
Returns:
ProtocolHandler

processProtocolHandler

public boolean processProtocolHandler(ProtocolHandler protocolHandler,
                                      Context context,
                                      PUProtocolRequest protocolRequest,
                                      boolean mapSelectionKey)
                               throws IOException
Throws:
IOException

configure

public void configure(Properties props)
Configures port unification depending on passed Properties

Parameters:
props - Properties

configure

public void configure(List<ProtocolFinder> protocolFinders,
                      List<ProtocolHandler> protocolHandlers,
                      List<PUPreProcessor> preProcessors)
Configures port unification depending on passed Lists

Parameters:
protocolFinders - ProtocolFinders
protocolHandlers - ProtocolHandlers
preProcessors - PUPreProcessors

addProtocolFinder

public void addProtocolFinder(ProtocolFinder protocolFinder)
Add an instance of ProtocolFinder


removeProtocolFinder

public void removeProtocolFinder(ProtocolFinder protocolFinder)
Remove a ProtocolFinder


addProtocolHandler

public void addProtocolHandler(ProtocolHandler protocolHandler)
Add an instance of ProtocolHandler


removeProtocolHandler

public void removeProtocolHandler(ProtocolHandler protocolHandler)
Remove a ProtocolHandler


addPreProcessor

public void addPreProcessor(PUPreProcessor preProcessor)
Add PUPreProcessor to preprocess income request


removePreProcessor

public void removePreProcessor(PUPreProcessor preProcessor)
Remove PUPreProcessor from preprocess queue


setReadTimeout

public void setReadTimeout(long readTimeout)
Set readTimeout. Time interval PUReadFilter will expect more data on channel. If no ProtocolFinder found - Filter tries to read more data and rerun finders.

Parameters:
readTimeout - new timeout value

getReadTimeout

public long getReadTimeout()
Get readTimeout. Time interval PUReadFilter will expect more data on channel. If no ProtocolFinder found - Filter tries to read more data and rerun finders.

Returns:
read timeout value


Copyright © 2013 Oracle Corporation. All Rights Reserved.