Package org.glassfish.grizzly.portunif
Class PUFilter
java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.portunif.PUFilter
- All Implemented Interfaces:
Filter
Port unification filter.
- Author:
- Alexey Stashok
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deregister
(PUProtocol puProtocol) Deregisters thePUProtocol
.protected void
findProtocol
(PUContext puContext, FilterChainContext ctx) Get the back channelFilter
implementation, which should connect the custom protocolFilterChain
with the mainFilterChain
.Get registered port unification protocols -PUProtocol
s.Returns theFilterChainBuilder
, developers may use to build there custom protocol filter chain.Execute a unit of processing work to be performed, when connection has been closed.handleEvent
(FilterChainContext ctx, FilterChainEvent event) Handle custom event associated with theConnection
.Execute a unit of processing work to be performed, when channel will become available for reading.boolean
Returns true if aConnection
whose protocol is not recognized will be automatically closed, or false if normalFilterChain
processing will be continued for suchConnection
, so aFilter
next to PUFilter may implement custom logic to process unrecognized connection.register
(ProtocolFinder protocolFinder, FilterChain filterChain) Registers newProtocolFinder
-FilterChain
pair, which defines the protocol.void
register
(PUProtocol puProtocol) Registers newPUProtocol
.Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleConnect, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString
-
Constructor Details
-
PUFilter
public PUFilter() -
PUFilter
public PUFilter(boolean isCloseUnrecognizedConnection) Constructs PUFilter.- Parameters:
isCloseUnrecognizedConnection
- true if aConnection
whose protocol is not recognized will be automatically closed, or false if normalFilterChain
processing will be continued for suchConnection
, so aFilter
next to PUFilter may implement custom logic to process unrecognized connection.
-
-
Method Details
-
register
Registers newProtocolFinder
-FilterChain
pair, which defines the protocol.- Parameters:
protocolFinder
-ProtocolFinder
filterChain
-FilterChain
- Returns:
PUProtocol
, which wraps passedProtocolFinder
andFilterChain
.
-
register
Registers newPUProtocol
.- Parameters:
puProtocol
-PUProtocol
-
deregister
Deregisters thePUProtocol
.- Parameters:
puProtocol
-PUProtocol
-
getProtocols
Get registered port unification protocols -PUProtocol
s.- Returns:
PUProtocol
Set
.
-
getBackChannelFilter
Get the back channelFilter
implementation, which should connect the custom protocolFilterChain
with the mainFilterChain
. Usually developers shouldn't use this method, if they build custom protocol chains usinggetPUFilterChainBuilder()
, otherwise they have to make sure there custom protocolFilterChain
contains back channelFilter
(usually first Filter in the custom protocol filter chain).- Returns:
- back channel
Filter
.
-
getPUFilterChainBuilder
Returns theFilterChainBuilder
, developers may use to build there custom protocol filter chain. The returnedFilterChainBuilder
may have someFilter
s pre-added.- Returns:
FilterChainBuilder
.
-
isCloseUnrecognizedConnection
public boolean isCloseUnrecognizedConnection()Returns true if aConnection
whose protocol is not recognized will be automatically closed, or false if normalFilterChain
processing will be continued for suchConnection
, so aFilter
next to PUFilter may implement custom logic to process unrecognized connection. -
handleRead
Description copied from class:BaseFilter
Execute a unit of processing work to be performed, when channel will become available for reading. ThisFilter
may either complete the required processing and return false, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returning true.- Specified by:
handleRead
in interfaceFilter
- Overrides:
handleRead
in classBaseFilter
- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleEvent
Description copied from class:BaseFilter
Handle custom event associated with theConnection
. ThisFilter
may either complete the required processing and returnStopAction
, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returningInvokeAction
.- Specified by:
handleEvent
in interfaceFilter
- Overrides:
handleEvent
in classBaseFilter
- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleClose
Description copied from class:BaseFilter
Execute a unit of processing work to be performed, when connection has been closed. ThisFilter
may either complete the required processing and return false, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returning true.- Specified by:
handleClose
in interfaceFilter
- Overrides:
handleClose
in classBaseFilter
- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
findProtocol
-