Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.container.jdk.client

pack-priv Class ClientFilter

extends Filter
Class Inheritance
Imports
java.io.IOException, java.net.SocketAddress, .URI, java.nio.ByteBuffer, java.nio.charset.Charset, java.util.Base64, .Collections, .HashMap, .List, .Map, java.util.concurrent.Callable, java.util.concurrent.atomic.AtomicBoolean, java.util.logging.Level, .Logger, jakarta.websocket.CloseReason, .DeploymentException, org.glassfish.tyrus.client.ClientManager, .ClientProperties, org.glassfish.tyrus.core.CloseReasons, .TyrusUpgradeResponse, .Utils, org.glassfish.tyrus.spi.ClientEngine, .CompletionHandler, .Connection, .Connection.CloseListener, .UpgradeRequest, .Writer

A filter that interacts with Tyrus SPI and handles proxy.
Author
Petr Janouch

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ClientEngine
private volatile CompletionHandler<Void>
private volatile boolean
private final AtomicBoolean
private final Callable<Void>
private static final Logger
private volatile boolean
private final Map<String, String>
private final HttpResponseParser
private final UpgradeRequest
private volatile Connection
Inherited from org.glassfish.tyrus.container.jdk.client.Filter:
downstreamFilterupstreamFilter

Constructor Summary

AccessConstructor and Description
pack-priv
ClientFilter(Filter
a filer that is positioned directly under this filter.
downstreamFilter
,
ClientEngine
client engine instance.
clientEngine
,
Map<String, Object>
client properties.
properties
,
Callable<Void>
callback to connecting with modified UpgradeRequest if necessary.
jdkConnector
,
UpgradeRequest
upgrade request to be used for this client session.
upgradeRequest
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.close.

Close the filter, invokes close operation on the next filter in the filter chain.

private void
pack-priv void
connect(SocketAddress
an address where to connect (server or proxy).
address
,
boolean
true if the connection will be established via proxy, false otherwise.
proxy
,
CompletionHandler<Void>
completion handler.
connectCompletionHandler
)

private JdkUpgradeRequest
private JdkUpgradeRequest
private JdkUpgradeRequest
getJdkUpgradeRequest(final UpgradeRequest upgradeRequest, final Filter downstreamFilter)

private static Map<String, String>
public void
public void
pack-priv void
public boolean
pack-priv void
private void
sendRequest(final Filter downstreamFilter, JdkUpgradeRequest handshakeUpgradeRequest)

Inherited from org.glassfish.tyrus.container.jdk.client.Filter:
connecthandleConnectonConnectonConnectionClosedonErroronReadonSslHandshakeCompletedstartSslwrite

Field Detail

clientEngineback to summary
private final ClientEngine clientEngine
connectCompletionHandlerback to summary
private volatile CompletionHandler<Void> connectCompletionHandler
connectedToProxyback to summary
private volatile boolean connectedToProxy
connectionClosedback to summary
private final AtomicBoolean connectionClosed
jdkConnectorback to summary
private final Callable<Void> jdkConnector
LOGGERback to summary
private static final Logger LOGGER
proxyback to summary
private volatile boolean proxy
proxyHeadersback to summary
private final Map<String, String> proxyHeaders
responseParserback to summary
private final HttpResponseParser responseParser
upgradeRequestback to summary
private final UpgradeRequest upgradeRequest
wsConnectionback to summary
private volatile Connection wsConnection

Constructor Detail

ClientFilterback to summary
pack-priv ClientFilter(Filter downstreamFilter, ClientEngine clientEngine, Map<String, Object> properties, Callable<Void> jdkConnector, UpgradeRequest upgradeRequest) throws DeploymentException

Constructor.

Parameters
downstreamFilter:Filter

a filer that is positioned directly under this filter.

clientEngine:ClientEngine

client engine instance.

properties:Map<String, Object>

client properties.

jdkConnector:Callable<Void>

callback to connecting with modified UpgradeRequest if necessary.

upgradeRequest:UpgradeRequest

upgrade request to be used for this client session.

Method Detail

closeback to summary
pack-priv void close()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.close.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.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.

Annotations
@Override
closeConnectionback to summary
private void closeConnection()
connectback to summary
pack-priv void connect(SocketAddress address, boolean proxy, CompletionHandler<Void> connectCompletionHandler)
Parameters
address:SocketAddress

an address where to connect (server or proxy).

proxy:boolean

true if the connection will be established via proxy, false otherwise.

connectCompletionHandler:CompletionHandler<Void>

completion handler.

createHandshakeUpgradeRequestback to summary
private JdkUpgradeRequest createHandshakeUpgradeRequest(final UpgradeRequest upgradeRequest)
createProxyUpgradeRequestback to summary
private JdkUpgradeRequest createProxyUpgradeRequest(final URI uri)
getJdkUpgradeRequestback to summary
private JdkUpgradeRequest getJdkUpgradeRequest(final UpgradeRequest upgradeRequest, final Filter downstreamFilter)
getProxyHeadersback to summary
private static Map<String, String> getProxyHeaders(Map<String, Object> properties) throws DeploymentException
processConnectback to summary
public void processConnect()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processConnect.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processConnect.

Process onConnect().

Annotations
@Override
processConnectionClosedback to summary
public void processConnectionClosed()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processConnectionClosed.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processConnectionClosed.

Process onConnectionClosed().

Annotations
@Override
processErrorback to summary
pack-priv void processError(Throwable t)

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processError.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processError.

Process onError(Throwable).

Parameters
t:Throwable

an error that has occurred.

Annotations
@Override
processReadback to summary
public boolean processRead(ByteBuffer data)

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processRead.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processRead.

Process onRead(ByteBuffer).

Parameters
data:ByteBuffer

read data.

Returns:boolean

true if the data should be sent to processing to upper filter in the chain, false otherwise.

Annotations
@Override
processSslHandshakeCompletedback to summary
pack-priv void processSslHandshakeCompleted()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processSslHandshakeCompleted.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processSslHandshakeCompleted.

Process onSslHandshakeCompleted().

Annotations
@Override
sendRequestback to summary
private void sendRequest(final Filter downstreamFilter, JdkUpgradeRequest handshakeUpgradeRequest)
org.glassfish.tyrus.container.jdk.client back to summary

private Class ClientFilter.JdkWriter

extends Writer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
private final Filter

Constructor Summary

AccessConstructor and Description
pack-priv
JdkWriter(Filter downstreamFilter, AtomicBoolean connectionClosed)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

public void
write(ByteBuffer
bytes to write.
buffer
,
CompletionHandler<ByteBuffer>
completion handler to know the write status.
completionHandler
)

Implements abstract org.glassfish.tyrus.spi.Writer.write.

A backward compatible method called from write(ByteBuffer, CompletionHandler, WriterInfo) to handover the data for a connection to the transport.

Inherited from org.glassfish.tyrus.spi.Writer:
write

Field Detail

connectionClosedback to summary
private final AtomicBoolean connectionClosed
downstreamFilterback to summary
private final Filter downstreamFilter

Constructor Detail

JdkWriterback to summary
pack-priv JdkWriter(Filter downstreamFilter, AtomicBoolean connectionClosed)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
writeback to summary
public void write(ByteBuffer buffer, CompletionHandler<ByteBuffer> completionHandler)

Implements abstract org.glassfish.tyrus.spi.Writer.write.

Doc from org.glassfish.tyrus.spi.Writer.write.

A backward compatible method called from write(ByteBuffer, CompletionHandler, WriterInfo) to handover the data for a connection to the transport. The transport writes bytes to underlying connection. Tyrus runtime must not use the buffer until the write is completed.

The method will be removed in the next major version.

Parameters
buffer:ByteBuffer

bytes to write.

completionHandler:CompletionHandler<ByteBuffer>

completion handler to know the write status.

Annotations
@Override