- All Known Subinterfaces:
CodecFilter<K,
L>
- All Known Implementing Classes:
AbstractCodecFilter
,ActivityCheckFilter
,BaseFilter
,ChunkingFilter
,DelayFilter
,EchoFilter
,GZipFilter
,IdleTimeoutFilter
,LogFilter
,LZMAFilter
,SilentConnectionFilter
,SSLBaseFilter
,SSLBaseFilter.SSLTransportFilterWrapper
,SSLFilter
,StringFilter
,TCPNIOTransportFilter
,TransportFilter
,UDPNIOTransportFilter
public interface Filter
A Filter encapsulates a unit of processing work to be performed, whose purpose is to examine and/or modify the state
of a transaction that is represented by a
FilterChainContext
. Individual Filter can be assembled into a
FilterChain
, which allows them to either complete the required processing or delegate further processing to
the next Filter in the FilterChain
.
Filter implementations should be designed in a thread-safe manner, suitable for inclusion in multiple
FilterChain
that might be processed by different threads simultaneously. In general, this implies that Filter
classes should not maintain state information in instance variables. Instead, state information should be maintained
via suitable modifications to the attributes of the FilterChainContext
that is passed to the appropriate
Filter
processing methods.
Filter implementations typically retrieve and store state information in the FilterChainContext
instance that
is passed as a parameter to the appropriate Filter
processing methods, using particular Attribute
s
that can be acquired via Attribute.get(org.glassfish.grizzly.attributes.AttributeStorage)
method.- Author:
- Jeanfrancois Arcand, Alexey Stashok
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
exceptionOccurred
(FilterChainContext ctx, Throwable error) Notification about exception, occurred on theFilterChain
Execute a unit of processing work to be performed, when server channel has accepted the client connection.Execute a unit of processing work to be performed, when connection has been closed.Execute a unit of processing work to be performed, when channel gets connected.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.Execute a unit of processing work to be performed, when some data should be written on channel.void
onAdded
(FilterChain filterChain) Method is called, when the Filter has been added to the passedFilterChain
.void
onFilterChainChanged
(FilterChain filterChain) Method is called, when theFilterChain
this Filter is part of, has been changed.void
onRemoved
(FilterChain filterChain) Method is called, when the Filter has been removed from the passedFilterChain
.
-
Method Details
-
onAdded
Method is called, when the Filter has been added to the passedFilterChain
.- Parameters:
filterChain
- theFilterChain
this Filter was added to.
-
onRemoved
Method is called, when the Filter has been removed from the passedFilterChain
.- Parameters:
filterChain
- theFilterChain
this Filter was removed from.
-
onFilterChainChanged
Method is called, when theFilterChain
this Filter is part of, has been changed.- Parameters:
filterChain
- theFilterChain
.
-
handleRead
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.- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleWrite
Execute a unit of processing work to be performed, when some data should be written on channel. ThisFilter
may either complete the required processing and return false, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returning true.- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleConnect
Execute a unit of processing work to be performed, when channel gets connected. ThisFilter
may either complete the required processing and return false, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returning true.- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleAccept
Execute a unit of processing work to be performed, when server channel has accepted the client connection. ThisFilter
may either complete the required processing and return false, or delegate remaining processing to the nextFilter
in aFilterChain
containing thisFilter
by returning true.- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleEvent
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
.- Parameters:
ctx
-FilterChainContext
event
-- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
handleClose
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.- Parameters:
ctx
-FilterChainContext
- Returns:
NextAction
instruction forFilterChain
, how it should continue the execution- Throws:
IOException
-
exceptionOccurred
Notification about exception, occurred on theFilterChain
- Parameters:
ctx
- event processingFilterChainContext
error
- error, which occurred during FilterChain execution
-