Interface Filter
-
- 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 FilterA 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 aFilterChainContext. Individual Filter can be assembled into aFilterChain, which allows them to either complete the required processing or delegate further processing to the next Filter in theFilterChain. Filter implementations should be designed in a thread-safe manner, suitable for inclusion in multipleFilterChainthat 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 theFilterChainContextthat is passed to the appropriateFilterprocessing methods. Filter implementations typically retrieve and store state information in theFilterChainContextinstance that is passed as a parameter to the appropriateFilterprocessing methods, using particularAttributes that can be acquired viaAttribute.get(org.glassfish.grizzly.attributes.AttributeStorage)method.- Author:
- Jeanfrancois Arcand, Alexey Stashok
- See Also:
FilterChain,Attribute
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidexceptionOccurred(FilterChainContext ctx, Throwable error)Notification about exception, occurred on theFilterChainNextActionhandleAccept(FilterChainContext ctx)Execute a unit of processing work to be performed, when server channel has accepted the client connection.NextActionhandleClose(FilterChainContext ctx)Execute a unit of processing work to be performed, when connection has been closed.NextActionhandleConnect(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel gets connected.NextActionhandleEvent(FilterChainContext ctx, FilterChainEvent event)Handle custom event associated with theConnection.NextActionhandleRead(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel will become available for reading.NextActionhandleWrite(FilterChainContext ctx)Execute a unit of processing work to be performed, when some data should be written on channel.voidonAdded(FilterChain filterChain)Method is called, when the Filter has been added to the passedFilterChain.voidonFilterChainChanged(FilterChain filterChain)Method is called, when theFilterChainthis Filter is part of, has been changed.voidonRemoved(FilterChain filterChain)Method is called, when the Filter has been removed from the passedFilterChain.
-
-
-
Method Detail
-
onAdded
void onAdded(FilterChain filterChain)
Method is called, when the Filter has been added to the passedFilterChain.- Parameters:
filterChain- theFilterChainthis Filter was added to.
-
onRemoved
void onRemoved(FilterChain filterChain)
Method is called, when the Filter has been removed from the passedFilterChain.- Parameters:
filterChain- theFilterChainthis Filter was removed from.
-
onFilterChainChanged
void onFilterChainChanged(FilterChain filterChain)
Method is called, when theFilterChainthis Filter is part of, has been changed.- Parameters:
filterChain- theFilterChain.
-
handleRead
NextAction handleRead(FilterChainContext ctx) throws IOException
Execute 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.- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleWrite
NextAction handleWrite(FilterChainContext ctx) throws IOException
Execute a unit of processing work to be performed, when some data should be written on channel. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleConnect
NextAction handleConnect(FilterChainContext ctx) throws IOException
Execute a unit of processing work to be performed, when channel gets connected. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleAccept
NextAction handleAccept(FilterChainContext ctx) throws IOException
Execute a unit of processing work to be performed, when server channel has accepted the client connection. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleEvent
NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) throws IOException
Handle custom event associated with theConnection. ThisFiltermay either complete the required processing and returnStopAction, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returningInvokeAction.- Parameters:
ctx-FilterChainContextevent-- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleClose
NextAction handleClose(FilterChainContext ctx) throws IOException
Execute 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.- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
exceptionOccurred
void exceptionOccurred(FilterChainContext ctx, Throwable error)
Notification about exception, occurred on theFilterChain- Parameters:
ctx- event processingFilterChainContexterror- error, which occurred during FilterChain execution
-
-