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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidderegister(PUProtocol puProtocol) Deregisters thePUProtocol.protected voidfindProtocol(PUContext puContext, FilterChainContext ctx) Get the back channelFilterimplementation, which should connect the custom protocolFilterChainwith the mainFilterChain.Get registered port unification protocols -PUProtocols.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.booleanReturns true if aConnectionwhose protocol is not recognized will be automatically closed, or false if normalFilterChainprocessing will be continued for suchConnection, so aFilternext to PUFilter may implement custom logic to process unrecognized connection.register(ProtocolFinder protocolFinder, FilterChain filterChain) Registers newProtocolFinder-FilterChainpair, which defines the protocol.voidregister(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 aConnectionwhose protocol is not recognized will be automatically closed, or false if normalFilterChainprocessing will be continued for suchConnection, so aFilternext to PUFilter may implement custom logic to process unrecognized connection.
-
-
Method Details
-
register
Registers newProtocolFinder-FilterChainpair, which defines the protocol.- Parameters:
protocolFinder-ProtocolFinderfilterChain-FilterChain- Returns:
PUProtocol, which wraps passedProtocolFinderandFilterChain.
-
register
Registers newPUProtocol.- Parameters:
puProtocol-PUProtocol
-
deregister
Deregisters thePUProtocol.- Parameters:
puProtocol-PUProtocol
-
getProtocols
Get registered port unification protocols -PUProtocols.- Returns:
PUProtocolSet.
-
getBackChannelFilter
Get the back channelFilterimplementation, which should connect the custom protocolFilterChainwith the mainFilterChain. Usually developers shouldn't use this method, if they build custom protocol chains usinggetPUFilterChainBuilder(), otherwise they have to make sure there custom protocolFilterChaincontains 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 returnedFilterChainBuildermay have someFilters pre-added.- Returns:
FilterChainBuilder.
-
isCloseUnrecognizedConnection
public boolean isCloseUnrecognizedConnection()Returns true if aConnectionwhose protocol is not recognized will be automatically closed, or false if normalFilterChainprocessing will be continued for suchConnection, so aFilternext to PUFilter may implement custom logic to process unrecognized connection. -
handleRead
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when channel will become available for reading. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleReadin interfaceFilter- Overrides:
handleReadin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleEvent
Description copied from class:BaseFilterHandle custom event associated with theConnection. ThisFiltermay either complete the required processing and returnStopAction, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returningInvokeAction.- Specified by:
handleEventin interfaceFilter- Overrides:
handleEventin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleClose
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when connection has been closed. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleClosein interfaceFilter- Overrides:
handleClosein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
findProtocol
-