Class Filter<UP_IN,UP_OUT,DOWN_OUT,DOWN_IN>
- java.lang.Object
-
- org.glassfish.jersey.jdk.connector.internal.Filter<UP_IN,UP_OUT,DOWN_OUT,DOWN_IN>
-
- Direct Known Subclasses:
HttpConnection.ConnectionFilter
,HttpFilter
,ProxyFilter
,SslFilter
,TransportFilter
class Filter<UP_IN,UP_OUT,DOWN_OUT,DOWN_IN> extends java.lang.Object
A filter can add functionality to JDK client transport. Filters are composed together to create JDK client transport.
-
-
Field Summary
Fields Modifier and Type Field Description protected Filter<DOWN_OUT,DOWN_IN,?,?>
downstreamFilter
protected Filter<?,?,UP_IN,UP_OUT>
upstreamFilter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
close()
Close the filter, invokes close operation on the next filter in the filter chain.(package private) void
connect(java.net.SocketAddress address, Filter<?,?,UP_IN,UP_OUT> upstreamFilter)
Initiate connect.(package private) void
handleConnect(java.net.SocketAddress address, Filter upstreamFilter)
Handleconnect(SocketAddress, Filter)
.(package private) void
onConnect()
An event listener that is called when a connection is set up.(package private) void
onConnectionClosed()
An event listener that is called when the connection is closed by the peer.(package private) void
onError(java.lang.Throwable t)
An event listener that is called when an error has occurred.(package private) void
onRead(DOWN_IN data)
An event listener that is called when some data is read.(package private) void
onSslHandshakeCompleted()
An event listener that is called, when SSL completes its handshake.(package private) void
processConnect()
ProcessonConnect()
.(package private) void
processConnectionClosed()
ProcessonConnectionClosed()
.(package private) void
processError(java.lang.Throwable t)
ProcessonError(Throwable)
.(package private) boolean
processRead(DOWN_IN data)
ProcessonRead(Object)
.(package private) void
processSslHandshakeCompleted()
ProcessonSslHandshakeCompleted()
.(package private) void
startSsl()
Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.(package private) void
write(UP_IN data, CompletionHandler<UP_IN> completionHandler)
Perform write operation for this filter and invokes write method on the next filter in the filter chain.
-
-
-
Constructor Detail
-
Filter
Filter(Filter<DOWN_OUT,DOWN_IN,?,?> downstreamFilter)
Constructor.- Parameters:
downstreamFilter
- downstream filter. Accessible directly asdownstreamFilter
protected field.
-
-
Method Detail
-
write
void write(UP_IN data, CompletionHandler<UP_IN> completionHandler)
Perform write operation for this filter and invokes write method on the next filter in the filter chain.- Parameters:
data
- on which write operation is performed.completionHandler
- will be invoked when the write operation is completed or has failed.
-
close
void close()
Close the filter, invokes close operation on the next filter in the filter chain. The filter is expected to clean up any allocated resources and pass the invocation to downstream filter.
-
startSsl
void startSsl()
Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.
-
connect
void connect(java.net.SocketAddress address, Filter<?,?,UP_IN,UP_OUT> upstreamFilter)
Initiate connect. If theFilter
needs to do something during this phase, it must implementhandleConnect(SocketAddress, Filter)
method.- Parameters:
address
- an address where to connect (server or proxy).upstreamFilter
- a filter positioned upstream.
-
onConnect
void onConnect()
An event listener that is called when a connection is set up. This event travels up in the filter chain. If theFilter
needs to process this event, it must implementprocessConnect()
method.
-
onRead
final void onRead(DOWN_IN data)
An event listener that is called when some data is read. If theFilter
needs to process this event, it must implementonRead(Object)
()} method. If the method returnstrue
, the processing will continue with upstream filters; if the method invocation returnsfalse
, the processing won't continue.- Parameters:
data
- that has been read.
-
onConnectionClosed
final void onConnectionClosed()
An event listener that is called when the connection is closed by the peer. If theFilter
needs to process this event, it must implementprocessConnectionClosed()
method.
-
onSslHandshakeCompleted
final void onSslHandshakeCompleted()
An event listener that is called, when SSL completes its handshake. If theFilter
needs to process this event, it must implementprocessSslHandshakeCompleted()
method.
-
onError
final void onError(java.lang.Throwable t)
An event listener that is called when an error has occurred. Errors travel in direction from downstream filter to upstream filter. If theFilter
needs to process this event, it must implementprocessError(Throwable)
method.- Parameters:
t
- an error that has occurred.
-
handleConnect
void handleConnect(java.net.SocketAddress address, Filter upstreamFilter)
Handleconnect(SocketAddress, Filter)
.- Parameters:
address
- an address where to connect (server or proxy).upstreamFilter
- a filter positioned upstream.- See Also:
connect(SocketAddress, Filter)
-
processConnect
void processConnect()
ProcessonConnect()
.- See Also:
onConnect()
-
processRead
boolean processRead(DOWN_IN data)
ProcessonRead(Object)
.- Parameters:
data
- read data.- Returns:
true
if the data should be sent to processing to upper filter in the chain,false
otherwise.
-
processConnectionClosed
void processConnectionClosed()
ProcessonConnectionClosed()
.- See Also:
onConnectionClosed()
-
processSslHandshakeCompleted
void processSslHandshakeCompleted()
ProcessonSslHandshakeCompleted()
.- See Also:
onSslHandshakeCompleted()
-
processError
void processError(java.lang.Throwable t)
ProcessonError(Throwable)
.- Parameters:
t
- an error that has occurred.- See Also:
onError(Throwable)
-
-