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.CloneableEncapsulates all the Transport options in one configuration object.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_ALLOW_NATIVE_IOstatic intDEFAULT_CONNECT_TIMEOUTstatic intDEFAULT_LOCAL_PORTstatic java.util.List<java.lang.String>DEFAULT_NATIVEIO_PREFERENCESstatic intDEFAULT_RECEIVE_BUFFER_SIZEstatic intDEFAULT_SEND_BUFFER_SIZEstatic intDEFAULT_SO_LINGERstatic intDEFAULT_SO_TIMEOUTstatic booleanDEFAULT_TCP_KEEP_ALIVEstatic booleanDEFAULT_TCP_NO_DELAYstatic intDEFAULT_TCP_PORTstatic booleanDEFAULT_TRACE_BYTESstatic intDEFAULT_TRAFFIC_CLASSstatic booleanDEFAULT_USE_WEBSOCKETSstatic intDEFAULT_WEBSOCKET_MAX_FRAME_SIZE
-
Constructor Summary
Constructors Constructor Description TransportOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransportOptionsaddWebSocketHeader(java.lang.String key, java.lang.String value)Additional headers to be passed along to the remote when performing a WebSocket based connect.booleanallowNativeIO()TransportOptionsallowNativeIO(boolean allowNativeIO)Determines if the a native IO implementation is preferred to the JDK based IO.TransportOptionsclone()intconnectTimeout()TransportOptionsconnectTimeout(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.TransportOptionscopyInto(TransportOptions other)Copy all configuration into the givenTransportOptionsfrom this instance.intdefaultTcpPort()TransportOptionsdefaultTcpPort(int defaultTcpPort)The default unsecured connection port to use when none has been specified by the user.java.lang.StringlocalAddress()TransportOptionslocalAddress(java.lang.String localAddress)The local address to bind to when attempting a remote connection.intlocalPort()TransportOptionslocalPort(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()voidnativeIOPreference(java.lang.String... nativeIOPreference)intreceiveBufferSize()TransportOptionsreceiveBufferSize(int receiveBufferSize)Sets the receive buffer size in bytes, the value must be greater than zero or anIllegalArgumentExceptionwill be thrown.intsendBufferSize()TransportOptionssendBufferSize(int sendBufferSize)Sets the send buffer size in bytes, the value must be greater than zero or anIllegalArgumentExceptionwill be thrown.intsoLinger()TransportOptionssoLinger(int soLinger)Configures the soLinger value that should be configured on the connection socket.intsoTimeout()TransportOptionssoTimeout(int soTimeout)Sets the value to use when configuring the socket level soTimeout option.booleantcpKeepAlive()TransportOptionstcpKeepAlive(boolean keepAlive)Configures the TCP socket keep-alive value that should be used for a connection.booleantcpNoDelay()TransportOptionstcpNoDelay(boolean tcpNoDelay)Configure the underlying connection to use the tcpNoDelay option.booleantraceBytes()TransportOptionstraceBytes(boolean traceBytes)Determines if the transport should add a logger for bytes in / outinttrafficClass()TransportOptionstrafficClass(int trafficClass)Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.booleanuseWebSockets()TransportOptionsuseWebSockets(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()intwebSocketMaxFrameSize()TransportOptionswebSocketMaxFrameSize(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.StringwebSocketPath()TransportOptionswebSocketPath(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:
clonein 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 anIllegalArgumentExceptionwill 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 anIllegalArgumentExceptionwill 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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
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
TransportOptionsinstance.
-
copyInto
public TransportOptions copyInto(TransportOptions other)
Copy all configuration into the givenTransportOptionsfrom this instance.- Parameters:
other- anotherTransportOptionsinstance that will receive the configuration from this instance.- Returns:
- the options instance that was copied into.
-
-