Package org.apache.qpid.protonj2.client
Class TransportOptions
- java.lang.Object
-
- org.apache.qpid.protonj2.client.TransportOptions
-
- All Implemented Interfaces:
java.lang.Cloneable
public class TransportOptions extends java.lang.Object implements java.lang.Cloneable
Encapsulates all the Transport options in one configuration object.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_ALLOW_NATIVE_IO
static int
DEFAULT_CONNECT_TIMEOUT
static int
DEFAULT_LOCAL_PORT
static java.util.List<java.lang.String>
DEFAULT_NATIVEIO_PREFERENCES
static int
DEFAULT_RECEIVE_BUFFER_SIZE
static int
DEFAULT_SEND_BUFFER_SIZE
static int
DEFAULT_SO_LINGER
static int
DEFAULT_SO_TIMEOUT
static boolean
DEFAULT_TCP_KEEP_ALIVE
static boolean
DEFAULT_TCP_NO_DELAY
static int
DEFAULT_TCP_PORT
static boolean
DEFAULT_TRACE_BYTES
static int
DEFAULT_TRAFFIC_CLASS
static boolean
DEFAULT_USE_WEBSOCKETS
static int
DEFAULT_WEBSOCKET_MAX_FRAME_SIZE
-
Constructor Summary
Constructors Constructor Description TransportOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransportOptions
addWebSocketHeader(java.lang.String key, java.lang.String value)
Additional headers to be passed along to the remote when performing a WebSocket based connect.boolean
allowNativeIO()
TransportOptions
allowNativeIO(boolean allowNativeIO)
Determines if the a native IO implementation is preferred to the JDK based IO.TransportOptions
clone()
int
connectTimeout()
TransportOptions
connectTimeout(int connectTimeout)
A transport layer connection timeout value that controls how long a connection attempt can block before giving up and throwing a connection error.TransportOptions
copyInto(TransportOptions other)
Copy all configuration into the givenTransportOptions
from this instance.int
defaultTcpPort()
TransportOptions
defaultTcpPort(int defaultTcpPort)
The default unsecured connection port to use when none has been specified by the user.java.lang.String
localAddress()
TransportOptions
localAddress(java.lang.String localAddress)
The local address to bind to when attempting a remote connection.int
localPort()
TransportOptions
localPort(int localPort)
Configures the local port value to bind to when connecting to the remote, if that port is already in use this can lead to a connection error.java.lang.String[]
nativeIOPreference()
void
nativeIOPreference(java.lang.String... nativeIOPreference)
int
receiveBufferSize()
TransportOptions
receiveBufferSize(int receiveBufferSize)
Sets the receive buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.int
sendBufferSize()
TransportOptions
sendBufferSize(int sendBufferSize)
Sets the send buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.int
soLinger()
TransportOptions
soLinger(int soLinger)
Configures the soLinger value that should be configured on the connection socket.int
soTimeout()
TransportOptions
soTimeout(int soTimeout)
Sets the value to use when configuring the socket level soTimeout option.boolean
tcpKeepAlive()
TransportOptions
tcpKeepAlive(boolean keepAlive)
Configures the TCP socket keep-alive value that should be used for a connection.boolean
tcpNoDelay()
TransportOptions
tcpNoDelay(boolean tcpNoDelay)
Configure the underlying connection to use the tcpNoDelay option.boolean
traceBytes()
TransportOptions
traceBytes(boolean traceBytes)
Determines if the transport should add a logger for bytes in / outint
trafficClass()
TransportOptions
trafficClass(int trafficClass)
Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.boolean
useWebSockets()
TransportOptions
useWebSockets(boolean webSockets)
Set to true to configure the transport layer as a WebSocket based connection.java.util.Map<java.lang.String,java.lang.String>
webSocketHeaders()
int
webSocketMaxFrameSize()
TransportOptions
webSocketMaxFrameSize(int maxFrameSize)
Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are split into multiple frames during transmission.java.lang.String
webSocketPath()
TransportOptions
webSocketPath(java.lang.String webSocketPath)
The optional path element to provide when connecting via a WebSocket.
-
-
-
Field Detail
-
DEFAULT_SEND_BUFFER_SIZE
public static final int DEFAULT_SEND_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_RECEIVE_BUFFER_SIZE
public static final int DEFAULT_RECEIVE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_TRAFFIC_CLASS
public static final int DEFAULT_TRAFFIC_CLASS
- See Also:
- Constant Field Values
-
DEFAULT_TCP_NO_DELAY
public static final boolean DEFAULT_TCP_NO_DELAY
- See Also:
- Constant Field Values
-
DEFAULT_TCP_KEEP_ALIVE
public static final boolean DEFAULT_TCP_KEEP_ALIVE
- See Also:
- Constant Field Values
-
DEFAULT_SO_LINGER
public static final int DEFAULT_SO_LINGER
- See Also:
- Constant Field Values
-
DEFAULT_SO_TIMEOUT
public static final int DEFAULT_SO_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_TCP_PORT
public static final int DEFAULT_TCP_PORT
- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_NATIVE_IO
public static final boolean DEFAULT_ALLOW_NATIVE_IO
- See Also:
- Constant Field Values
-
DEFAULT_TRACE_BYTES
public static final boolean DEFAULT_TRACE_BYTES
- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_PORT
public static final int DEFAULT_LOCAL_PORT
- See Also:
- Constant Field Values
-
DEFAULT_USE_WEBSOCKETS
public static final boolean DEFAULT_USE_WEBSOCKETS
- See Also:
- Constant Field Values
-
DEFAULT_WEBSOCKET_MAX_FRAME_SIZE
public static final int DEFAULT_WEBSOCKET_MAX_FRAME_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_NATIVEIO_PREFERENCES
public static final java.util.List<java.lang.String> DEFAULT_NATIVEIO_PREFERENCES
-
-
Method Detail
-
clone
public TransportOptions clone()
- Overrides:
clone
in classjava.lang.Object
-
sendBufferSize
public int sendBufferSize()
- Returns:
- the currently set send buffer size in bytes.
-
sendBufferSize
public TransportOptions sendBufferSize(int sendBufferSize)
Sets the send buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.- Parameters:
sendBufferSize
- the new send buffer size for the TCP Transport.- Returns:
- this options instance.
- Throws:
java.lang.IllegalArgumentException
- if the value given is not in the valid range.
-
receiveBufferSize
public int receiveBufferSize()
- Returns:
- the currently configured receive buffer size in bytes.
-
receiveBufferSize
public TransportOptions receiveBufferSize(int receiveBufferSize)
Sets the receive buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.- Parameters:
receiveBufferSize
- the new receive buffer size for the TCP Transport.- Returns:
- this options instance.
- Throws:
java.lang.IllegalArgumentException
- if the value given is not in the valid range.
-
trafficClass
public int trafficClass()
- Returns:
- the currently configured traffic class value.
-
trafficClass
public TransportOptions trafficClass(int trafficClass)
Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.- Parameters:
trafficClass
- the new traffic class value.- Returns:
- this options instance.
- Throws:
java.lang.IllegalArgumentException
- if the value given is not in the valid range.
-
soTimeout
public int soTimeout()
- Returns:
- the configured value for the socket level soTimeout option.
-
soTimeout
public TransportOptions soTimeout(int soTimeout)
Sets the value to use when configuring the socket level soTimeout option.- Parameters:
soTimeout
- the soTimeout value to configure on the newly create socket.- Returns:
- this
TransportOptions
instance.
-
tcpNoDelay
public boolean tcpNoDelay()
- Returns:
- the configured value for the socket level tcpNoDelay option.
-
tcpNoDelay
public TransportOptions tcpNoDelay(boolean tcpNoDelay)
Configure the underlying connection to use the tcpNoDelay option.- Parameters:
tcpNoDelay
- controls if the underlying connection configures tcpNoDelay.- Returns:
- this
TransportOptions
instance.
-
soLinger
public int soLinger()
- Returns:
- the configured value for the socket level soLinger option.
-
soLinger
public TransportOptions soLinger(int soLinger)
Configures the soLinger value that should be configured on the connection socket.- Parameters:
soLinger
- The soLinger value to use for the underlying socket.- Returns:
- this
TransportOptions
instance.
-
tcpKeepAlive
public boolean tcpKeepAlive()
- Returns:
- the configured value for the socket level tcpKeepAlive option.
-
tcpKeepAlive
public TransportOptions tcpKeepAlive(boolean keepAlive)
Configures the TCP socket keep-alive value that should be used for a connection.- Parameters:
keepAlive
- The TCP/IP keep-alive value to use for the connection.- Returns:
- this
TransportOptions
instance.
-
connectTimeout
public int connectTimeout()
- Returns:
- the configured value for the socket level connection timeout option.
-
connectTimeout
public TransportOptions connectTimeout(int connectTimeout)
A transport layer connection timeout value that controls how long a connection attempt can block before giving up and throwing a connection error.- Parameters:
connectTimeout
- connection timeout in milliseconds.- Returns:
- this
TransportOptions
instance.
-
defaultTcpPort
public int defaultTcpPort()
- Returns:
- the configured value for the socket level default port to use for connection if none is provided.
-
defaultTcpPort
public TransportOptions defaultTcpPort(int defaultTcpPort)
The default unsecured connection port to use when none has been specified by the user.- Parameters:
defaultTcpPort
- the default port to use for non-SSL connection if none provided.- Returns:
- this
TransportOptions
instance.
-
localAddress
public java.lang.String localAddress()
- Returns:
- the configured value for the socket level localAddress option.
-
localAddress
public TransportOptions localAddress(java.lang.String localAddress)
The local address to bind to when attempting a remote connection.- Parameters:
localAddress
- the local address to bind to.- Returns:
- this
TransportOptions
instance.
-
localPort
public int localPort()
- Returns:
- the configured value for the socket level localPort option.
-
localPort
public TransportOptions localPort(int localPort)
Configures the local port value to bind to when connecting to the remote, if that port is already in use this can lead to a connection error.- Parameters:
localPort
- local port value to use when making a remote connection.- Returns:
- this
TransportOptions
instance.
-
allowNativeIO
public boolean allowNativeIO()
- Returns:
- true if an native IO library can be used if available on this platform instead of the JDK IO.
-
allowNativeIO
public TransportOptions allowNativeIO(boolean allowNativeIO)
Determines if the a native IO implementation is preferred to the JDK based IO.- Parameters:
allowNativeIO
- should use of available native transport be allowed if one is available.- Returns:
- this
TransportOptions
instance.
-
nativeIOPreference
public java.lang.String[] nativeIOPreference()
- Returns:
- the nativeIOPreference
-
nativeIOPreference
public void nativeIOPreference(java.lang.String... nativeIOPreference)
- Parameters:
nativeIOPreference
- the nativeIOPreference to set
-
traceBytes
public boolean traceBytes()
- Returns:
- true if the transport should enable byte tracing
-
traceBytes
public TransportOptions traceBytes(boolean traceBytes)
Determines if the transport should add a logger for bytes in / out- Parameters:
traceBytes
- should the transport log the bytes in and out.- Returns:
- this
TransportOptions
instance.
-
useWebSockets
public boolean useWebSockets()
- Returns:
- the configured state of WebSockets for client connections.
-
useWebSockets
public TransportOptions useWebSockets(boolean webSockets)
Set to true to configure the transport layer as a WebSocket based connection.- Parameters:
webSockets
- should the transport attempt connection using a WebSocket.- Returns:
- this
TransportOptions
instance.
-
webSocketPath
public java.lang.String webSocketPath()
- Returns:
- the configured value for the socket level WebSocket path option.
-
webSocketPath
public TransportOptions webSocketPath(java.lang.String webSocketPath)
The optional path element to provide when connecting via a WebSocket.- Parameters:
webSocketPath
- path value to use for WebSocket connections.- Returns:
- this
TransportOptions
instance.
-
webSocketHeaders
public java.util.Map<java.lang.String,java.lang.String> webSocketHeaders()
- Returns:
- the configured value for the socket level WebSocket Headers option.
-
addWebSocketHeader
public TransportOptions addWebSocketHeader(java.lang.String key, java.lang.String value)
Additional headers to be passed along to the remote when performing a WebSocket based connect.- Parameters:
key
- the header key to use with the provided value.value
- the value to store under the provided key.- Returns:
- this
TransportOptions
instance.
-
webSocketMaxFrameSize
public int webSocketMaxFrameSize()
- Returns:
- the configured value for the socket level WebSocket max frame size option.
-
webSocketMaxFrameSize
public TransportOptions webSocketMaxFrameSize(int maxFrameSize)
Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are split into multiple frames during transmission.- Parameters:
maxFrameSize
- the maximum WebSocket frame size before payloads are split.- Returns:
- this
TransportOptions
instance.
-
copyInto
public TransportOptions copyInto(TransportOptions other)
Copy all configuration into the givenTransportOptions
from this instance.- Parameters:
other
- anotherTransportOptions
instance that will receive the configuration from this instance.- Returns:
- the options instance that was copied into.
-
-