Top Description Inners Methods
org.glassfish.tyrus.spi

public Interface ClientEngine


Facade for handling client operations from containers.
Authors
Pavel Bucek, Ondrej Kosatka

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ClientEngine.ClientUpgradeInfo

Upgrade process result.

public static enum
ClientEngine.ClientUpgradeStatus

Status of upgrade process.

public static interface
ClientEngine.TimeoutHandler

Indicates to container that handshake timeout was reached.

Method Summary

Modifier and TypeMethod and Description
public UpgradeRequest

Returns:

request to be send on the wire or null, when the request cannot be created. When null is returned, client should free all resources tied to current connection.
createUpgradeRequest
(ClientEngine.TimeoutHandler
handshake timeout handler. TimeoutHandler#handleTimeout() is invoked if processResponse(UpgradeResponse, Writer, Connection.CloseListener) is not called within handshake timeout.
timeoutHandler
)

Create upgrade request and register TimeoutHandler.

public void
processError(Throwable
encountered error.
t
)

Process error.

public ClientEngine.ClientUpgradeInfo

Returns:

info with upgrade status.
processResponse
(UpgradeResponse
response to be processed.
upgradeResponse
,
final Writer
used for sending dataframes from client endpoint.
writer
,
final Connection.CloseListener
will be called when connection is closed, will be set as listener of returned Connection.
closeListener
)

Process handshake and return ClientUpgradeInfo with handshake status (ClientUpgradeStatus).

Method Detail

createUpgradeRequestback to summary
public UpgradeRequest createUpgradeRequest(ClientEngine.TimeoutHandler timeoutHandler)

Create upgrade request and register TimeoutHandler.

Parameters
timeoutHandler:ClientEngine.TimeoutHandler

handshake timeout handler. TimeoutHandler#handleTimeout() is invoked if processResponse(UpgradeResponse, Writer, Connection.CloseListener) is not called within handshake timeout.

Returns:UpgradeRequest

request to be send on the wire or null, when the request cannot be created. When null is returned, client should free all resources tied to current connection.

processErrorback to summary
public void processError(Throwable t)

Process error.

This method can be called any time when client encounters an error which cannot be handled in the container before ClientUpgradeStatus#SUCCESS is returned from processResponse(UpgradeResponse, Writer, Connection.CloseListener).

Parameters
t:Throwable

encountered error.

See Also
processResponse(UpgradeResponse, Writer, Connection.CloseListener)
processResponseback to summary
public ClientEngine.ClientUpgradeInfo processResponse(UpgradeResponse upgradeResponse, final Writer writer, final Connection.CloseListener closeListener)

Process handshake and return ClientUpgradeInfo with handshake status (ClientUpgradeStatus).

Parameters
upgradeResponse:UpgradeResponse

response to be processed.

writer:Writer

used for sending dataframes from client endpoint.

closeListener:Connection.CloseListener

will be called when connection is closed, will be set as listener of returned Connection.

Returns:ClientEngine.ClientUpgradeInfo

info with upgrade status.

See Also
processError(Throwable)
org.glassfish.tyrus.spi back to summary

public Interface ClientEngine.ClientUpgradeInfo


Upgrade process result.

Provides information about upgrade process. There are three possible states which can be reported:

When getUpgradeStatus() returns ClientUpgradeStatus#SUCCESS, client container can create Connection and start processing read events from the underlying connection and report them to Tyrus runtime.

When getUpgradeStatus() returns ClientUpgradeStatus#UPGRADE_REQUEST_FAILED, client container HAS TO close all resources related to currently processed UpgradeResponse.

When getUpgradeStatus() returns ClientUpgradeStatus#ANOTHER_UPGRADE_REQUEST_REQUIRED, client container HAS TO close all resources related to currently processed UpgradeResponse, open new TCP connection and send UpgradeRequest obtained from method createUpgradeRequest(TimeoutHandler).

Method Summary

Modifier and TypeMethod and Description
public Connection

Returns:

new Connection instance or null, when getUpgradeStatus() does not return ClientUpgradeStatus.
createConnection
()

Create new Connection when getUpgradeStatus() returns ClientUpgradeStatus#SUCCESS.

public ClientEngine.ClientUpgradeStatus

Method Detail

createConnectionback to summary
public Connection createConnection()

Create new Connection when getUpgradeStatus() returns ClientUpgradeStatus#SUCCESS.

Returns:Connection

new Connection instance or null, when getUpgradeStatus() does not return ClientUpgradeStatus.

getUpgradeStatusback to summary
public ClientEngine.ClientUpgradeStatus getUpgradeStatus()

Get ClientUpgradeStatus.

Returns:ClientEngine.ClientUpgradeStatus

ClientUpgradeStatus.

org.glassfish.tyrus.spi back to summary

public final Enum ClientEngine.ClientUpgradeStatus

extends Enum<ClientEngine.ClientUpgradeStatus>
Class Inheritance

Status of upgrade process.

Returned by processResponse(UpgradeResponse, Writer, Connection.CloseListener).

Field Summary

Modifier and TypeField and Description
public static final ClientEngine.ClientUpgradeStatus
ANOTHER_UPGRADE_REQUEST_REQUIRED

Client engine needs to send another request.

public static final ClientEngine.ClientUpgradeStatus
SUCCESS

Upgrade process was successful.

public static final ClientEngine.ClientUpgradeStatus
UPGRADE_REQUEST_FAILED

Upgrade process failed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ClientEngine.ClientUpgradeStatus
public static ClientEngine.ClientUpgradeStatus[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ANOTHER_UPGRADE_REQUEST_REQUIREDback to summary
public static final ClientEngine.ClientUpgradeStatus ANOTHER_UPGRADE_REQUEST_REQUIRED

Client engine needs to send another request.

See Also
createUpgradeRequest(TimeoutHandler)
SUCCESSback to summary
public static final ClientEngine.ClientUpgradeStatus SUCCESS

Upgrade process was successful.

See Also
ClientUpgradeInfo#createConnection()
UPGRADE_REQUEST_FAILEDback to summary
public static final ClientEngine.ClientUpgradeStatus UPGRADE_REQUEST_FAILED

Upgrade process failed.

Constructor Detail

ClientUpgradeStatusback to summary
private ClientUpgradeStatus()

Method Detail

valueOfback to summary
public static ClientEngine.ClientUpgradeStatus valueOf(String name)
valuesback to summary
public static ClientEngine.ClientUpgradeStatus[] values()
org.glassfish.tyrus.spi back to summary

public Interface ClientEngine.TimeoutHandler


Indicates to container that handshake timeout was reached.

Method Summary

Modifier and TypeMethod and Description
public void
handleTimeout()

Invoked when timeout is reached.

Method Detail

handleTimeoutback to summary
public void handleTimeout()

Invoked when timeout is reached. Container is supposed to clean all resources related to ClientEngine instance.