Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.connection
Interface Connection

All Known Implementing Classes:
com.genesyslab.platform.commons.connection.impl.AbstractConnection, com.genesyslab.platform.commons.connection.impl.AbstractConnectionImpl, HAConnection, UdpConnectionImpl

public interface Connection

Allows for direct communication with a server using TCP/IP. This low-level connection is encapsulated by the Channel classes, such as ClientChannel. The Channel classes present a message-based interface to your applications.

For Genesys internal use only.


Field Summary
static java.lang.String BACKUP_BIND_PORT_KEY
          Constant for ConnectionConfiguration that specifies port from which connection should be made (bind to) for backup server.
static java.lang.String BIND_HOST_KEY
          Constant for ConnectionConfiguration that specifies host from which connection should be made (bind to).
static java.lang.String BIND_PORT_KEY
          Constant for ConnectionConfiguration that specifies port from which connection should be made (bind to).
static java.lang.String CONNECTION_TIMEOUT_KEY
          Integer value.
static java.lang.String DEFAULT_ENABLE_IPV6
           
static java.lang.String DEFAULT_IP_VERSION
           
static int DEFAULT_OPERATION_TIMEOUT
           
static java.lang.String ENABLE_IPV6_KEY
          Turns IPv6 support on/off.
static java.lang.String IP_VERSION_4_6
           
static java.lang.String IP_VERSION_6_4
           
static java.lang.String IP_VERSION_KEY
          Constant for ConnectionConfiguration to specify order in which connection attempts will be made to IPv6 and IPv4 addresses.
static java.lang.String KEEP_ALIVE_KEY
          Boolean value.
static java.lang.String LAZY_PARSING_ENABLED_KEY
          Optional.
static java.lang.String OPERATION_TIMEOUT_KEY
          Integer value.
static java.lang.String REUSE_ADDRESS_KEY
          Boolean value.
static java.lang.String SSL_KEYSTORE_PASS
          Deprecated. Key store password is supported via callback handler
static java.lang.String SSL_KEYSTORE_PATH_KEY
          Deprecated. Use tls-cert and tls-key options
static java.lang.String STR_ATTR_ENCODING_NAME_KEY
          Constant for ConnectionConfiguration that specifies encoding for string attributes.
static java.lang.String TLS_KEY
          Constant for ConnectionConfiguration that specifies whether connection should be secured with TLS.
static java.lang.String TLS_VERSION_KEY
          Deprecated. 
 
Method Summary
 void close()
          Closes connection to the server.
 void configure(ConnectionConfiguration config)
          Configures or reconfigures this connection's additional parameters.
 void forceClose()
          Closes the connection without waiting for pending messages.
 ConnectionState getConnectionState()
          Returns connection state of this connection.
 java.lang.String getHost()
          Gets host of the connection.
 long getId()
          Gets the connection id.
 com.genesyslab.platform.commons.connection.interceptor.Interceptor getInterceptor()
          Returns interceptor of this connection.
 java.lang.String getLocalBindHost()
          Gets the local bind host assigned by setLocalBindHost(String).
 java.lang.Integer getLocalBindPort()
          Gets the local bind port assigned by setLocalBindPort(Integer).
 java.net.InetSocketAddress getLocalEndPoint()
          Gets current local InetSocketAddress of socket, if it is created.
 MessagePackager getMessagePackager()
           
 MessageTransport getMessageTransport()
           
 int getPort()
          Gets port of the connection.
 java.net.InetSocketAddress getRemoteEndPoint()
          Gets current remote InetSocketAddress of socket, if it is created.
 long getUnsetBytes()
          Gets amount of unsent bytes.
 java.lang.String getUri()
          Gets address of the connection.
 boolean hasUnsetBytes()
          Checks if some unsent bytes have been ramained.
 void open()
          Opens network connection to the server.
 void setConnectionHandler(ConnectionHandler connectionHandler)
          Sets connection handler to receive notifications about connection events.
 void setContext(ConnectionContext ctx)
          Sets the connection context.
 void setInvoker(AsyncInvoker invoker)
          Connection can use invoker (if it's set) to parse messages.
 void setLocalBindHost(java.lang.String host)
          Sets the local bind host which is used when the connection is getting opened.
 void setLocalBindPort(java.lang.Integer port)
          Sets the local bind port which is used when the connection is getting opened.
 void setMessagePackager(MessagePackager packager)
           
 void setMessageTransport(MessageTransport transport)
           
 

Field Detail

BIND_HOST_KEY

static final java.lang.String BIND_HOST_KEY
Constant for ConnectionConfiguration that specifies host from which connection should be made (bind to).

See Also:
Constant Field Values

BIND_PORT_KEY

static final java.lang.String BIND_PORT_KEY
Constant for ConnectionConfiguration that specifies port from which connection should be made (bind to).

See Also:
Constant Field Values

BACKUP_BIND_PORT_KEY

static final java.lang.String BACKUP_BIND_PORT_KEY
Constant for ConnectionConfiguration that specifies port from which connection should be made (bind to) for backup server.

See Also:
Constant Field Values

OPERATION_TIMEOUT_KEY

static final java.lang.String OPERATION_TIMEOUT_KEY
Integer value. Timeout for operations like stopReading and resumeReading. Timeout is specified in milliseconds.

See Also:
Constant Field Values

DEFAULT_OPERATION_TIMEOUT

static final int DEFAULT_OPERATION_TIMEOUT
See Also:
Constant Field Values

CONNECTION_TIMEOUT_KEY

static final java.lang.String CONNECTION_TIMEOUT_KEY
Integer value. Sets connection timeout option for the local socket to be opened by connection. Timeout is specified in milliseconds.

See Also:
Constant Field Values

REUSE_ADDRESS_KEY

static final java.lang.String REUSE_ADDRESS_KEY
Boolean value. Sets SO_REUSEADDR option for the local socket to be opened by connection.

See Also:
Constant Field Values

KEEP_ALIVE_KEY

static final java.lang.String KEEP_ALIVE_KEY
Boolean value. Sets SO_KEEPALIVE option for the local socket to be opened by connection.

See Also:
Constant Field Values

ENABLE_IPV6_KEY

static final java.lang.String ENABLE_IPV6_KEY
Turns IPv6 support on/off. Possible values: 0 (default, implied) and 1. If set to 0, IPv6 support would be disabled, even if supported by OS/platform.

See Also:
Constant Field Values

DEFAULT_ENABLE_IPV6

static final java.lang.String DEFAULT_ENABLE_IPV6
See Also:
Constant Field Values

IP_VERSION_KEY

static final java.lang.String IP_VERSION_KEY
Constant for ConnectionConfiguration to specify order in which connection attempts will be made to IPv6 and IPv4 addresses. Possible values: "4,6" (default) or "6,4" (both values without spaces). Has no effect on connection if "enable-ipv6" is set to 0; warning would be logged. Has no effect on server side; warning would be logged.

See Also:
Constant Field Values

IP_VERSION_4_6

static final java.lang.String IP_VERSION_4_6
See Also:
Constant Field Values

IP_VERSION_6_4

static final java.lang.String IP_VERSION_6_4
See Also:
Constant Field Values

DEFAULT_IP_VERSION

static final java.lang.String DEFAULT_IP_VERSION
See Also:
Constant Field Values

STR_ATTR_ENCODING_NAME_KEY

static final java.lang.String STR_ATTR_ENCODING_NAME_KEY
Constant for ConnectionConfiguration that specifies encoding for string attributes.

See Also:
Constant Field Values

TLS_VERSION_KEY

@Deprecated
static final java.lang.String TLS_VERSION_KEY
Deprecated. 
See Also:
Constant Field Values

TLS_KEY

static final java.lang.String TLS_KEY
Constant for ConnectionConfiguration that specifies whether connection should be secured with TLS. Please note that using this key alone will turn TLS with default and the most simple (so probably the least secure) settings. For example, for client connection that means that server certificate won't be validated at all. If more secure and manageable settings are needed please configure SSContext and pass it via ConnectionContext class.

See Also:
Constant Field Values

SSL_KEYSTORE_PATH_KEY

static final java.lang.String SSL_KEYSTORE_PATH_KEY
Deprecated. Use tls-cert and tls-key options
Key for passing path to keystore with server-side certificate and private key. Used for server-side TLS. Please note that this default way of configuration is intended for development stages and follow "minimum configuration" princple. Most probably you will need more secure and thus more complex TLS infrastructure in production systems. For this simple case PSDK uses first certificate found in the keystore. To create such certificate you can use following command:
keytool -genkey -keysize 512 -validity 3650 -keyalg RSA -dname "CN=somename.com, OU=XXX CA, O=SomeName Inc, L=Kyiv, S=Kyiv, C=UA" -keypass somepass -storepass somepass -keystore storename.cert
See JavaDoc for more info on "keytool" command.

See Also:
SSL_KEYSTORE_PASS, Constant Field Values

SSL_KEYSTORE_PASS

static final java.lang.String SSL_KEYSTORE_PASS
Deprecated. Key store password is supported via callback handler
Key for passing keystore password. Used for server-side TLS. Please note that this default way of configuration is intended for development stages and follow "minimum configuration" principle. Most probably you will need more secure and thus more complex TLS infrastructure in production systems.

See Also:
SSL_KEYSTORE_PATH_KEY, Constant Field Values

LAZY_PARSING_ENABLED_KEY

static final java.lang.String LAZY_PARSING_ENABLED_KEY
Optional. Boolean value. If set to true, turns on lazy parsing of properties, for which lazy parsing possibility is enabled in protocol.

See Also:
Constant Field Values
Method Detail

open

void open()
Opens network connection to the server. Please note, that usually this method will return immediately and won't wait while connection is established. (connection process is asynchronous).


close

void close()
Closes connection to the server. The connection is closed "gracefully". In other words pending messages are delivered to remote party before the connection is actually closed. The second open() after close is not guaranteed to work properly (depends on implementation).


forceClose

void forceClose()
Closes the connection without waiting for pending messages. The checks count during this operation is minimal, so be careful.


getConnectionState

ConnectionState getConnectionState()
Returns connection state of this connection.

Returns:
connection state

getUri

java.lang.String getUri()
Gets address of the connection.

Returns:
connection address

getHost

java.lang.String getHost()
Gets host of the connection.

Returns:
connection's host

getPort

int getPort()
Gets port of the connection.

Returns:
connection's port

setConnectionHandler

void setConnectionHandler(ConnectionHandler connectionHandler)
Sets connection handler to receive notifications about connection events.

Parameters:
connectionHandler - connection handler implementation

configure

void configure(ConnectionConfiguration config)
Configures or reconfigures this connection's additional parameters. (e.g. ADDP).

Parameters:
config - Connection parameters

setContext

void setContext(ConnectionContext ctx)
Sets the connection context.

Parameters:
ctx - connection context

getInterceptor

com.genesyslab.platform.commons.connection.interceptor.Interceptor getInterceptor()
Returns interceptor of this connection.

Returns:
interceptor of the connection

setMessagePackager

void setMessagePackager(MessagePackager packager)

getMessagePackager

MessagePackager getMessagePackager()

setMessageTransport

void setMessageTransport(MessageTransport transport)

getMessageTransport

MessageTransport getMessageTransport()

setInvoker

void setInvoker(AsyncInvoker invoker)
Connection can use invoker (if it's set) to parse messages. It is recommended to use the invoker if you know that it can take long to parse the message. Whether invoker will be used or not is implementation specific. For instance it seems a good idea to set some kind of thread pool as invoker for some busy connection, but you can break the order of message arrival by doing so.

Parameters:
invoker - async invoker

getRemoteEndPoint

java.net.InetSocketAddress getRemoteEndPoint()
Gets current remote InetSocketAddress of socket, if it is created.

Returns:
connection remote endpoint or null

getLocalEndPoint

java.net.InetSocketAddress getLocalEndPoint()
Gets current local InetSocketAddress of socket, if it is created.

Returns:
connection local endpoint or null

hasUnsetBytes

boolean hasUnsetBytes()
Checks if some unsent bytes have been ramained.

Returns:
true if some unsent bytes have been ramained.

getUnsetBytes

long getUnsetBytes()
Gets amount of unsent bytes.

Returns:
amount of unsent bytes.

getId

long getId()
Gets the connection id.

Returns:
connection id.

getLocalBindHost

java.lang.String getLocalBindHost()
Gets the local bind host assigned by setLocalBindHost(String).
If it isn't assigned or null is assigned then local bind host will be reading from connection configuration using BIND_HOST_KEY when the connection is getting opened.

Note: empty string value allow using any network interface for local binding.

Returns:
local bind host assigned by setLocalBindHost(String)

setLocalBindHost

void setLocalBindHost(java.lang.String host)
Sets the local bind host which is used when the connection is getting opened.
If it isn't assigned or null is assigned then local bind host will be reading from connection configuration using BIND_HOST_KEY when the connection is getting opened.

Note: empty string value allow using any network interface for local binding.


getLocalBindPort

java.lang.Integer getLocalBindPort()
Gets the local bind port assigned by setLocalBindPort(Integer).
If it isn't assigned or null is assigned then local bind port will be reading from connection configuration using BIND_PORT_KEY when the connection is getting opened.

Note: zero value means ephemeral port using.

Returns:
local bind port assigned by setLocalBindPort(Integer)

setLocalBindPort

void setLocalBindPort(java.lang.Integer port)
Sets the local bind port which is used when the connection is getting opened.
If it isn't assigned or null is assigned then local bind port will be reading from connection configuration using BIND_PORT_KEY when the connection is getting opened.

Note: zero value means ephemeral port using.


Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.