it.list.jft
Interface Connection

All Superinterfaces:
CommunicationLifeCycle, LifeCycle

public interface Connection
extends CommunicationLifeCycle

Logical bidirectional channel with a server.

Within the same JFT application several Connections can be created and then opened with the same Server or with several Servers.

Connection Usage

Every new connection is described by:
In brief:
Connections are created by Context.makeConnection() in which the connection parameters are described by ConnectionParam and the event listeners are described by ConnectionListener.

Once created a connection must be opened (attached to the server), used, and then closed (detached from the server).

Connection Lifecycle

See Also:
Context.makeConnection(), ConnectionParam, ConnectionListener

Field Summary
static int STATUS_CONNECTED
          Lifecycle status: Connection connected to the server and ready to be used.
static int STATUS_CONNECTING
          Lifecycle status: Connection waiting the open() server-answer.
static int STATUS_DISCONNECTED
          Lifecycle status: Connection no more connected to the server and ready to be released.
static int STATUS_DISCONNECTING
          Lifecycle status: Connection waiting the close() server-answer.
 
Fields inherited from interface LifeCycle
RESULT_GENERIC_ERROR, RESULT_INVALID_STATUS, RESULT_OK, STATUS_INIT, STATUS_RELEASED
 
Method Summary
 int close()
          Try to close this connection with a given server.
 int open()
          Try to open this connection with a given server.
 
Methods inherited from interface CommunicationLifeCycle
getContext, getListener, getParam
 
Methods inherited from interface LifeCycle
enumChilds, getStatus, release
 

Field Detail

STATUS_CONNECTING

static final int STATUS_CONNECTING
Lifecycle status: Connection waiting the open() server-answer.
This value may be returned by LifeCycle.getStatus().

Status Entry:
STATUS_INITopen() ok → STATUS_CONNECTING.
Status Activities:
none: waiting an automatic onConnectionOpen() call.
Status Exit:
STATUS_CONNECTINGonConnectionOpen() ok → STATUS_CONNECTED.
STATUS_CONNECTINGonConnectionOpen() bad → STATUS_DISCONNECTED.
STATUS_CONNECTINGonConnectionLost()STATUS_DISCONNECTED.

See Also:
Connection lifecycle, Constant Field Values

STATUS_CONNECTED

static final int STATUS_CONNECTED
Lifecycle status: Connection connected to the server and ready to be used.
This value may be returned by LifeCycle.getStatus().

Status Entry:
STATUS_CONNECTINGonConnectionOpen() ok → STATUS_CONNECTED.
Status Activities:
Status Exit:
STATUS_CONNECTEDclose() ok → STATUS_DISCONNECTING.
STATUS_CONNECTEDonConnectionLost()STATUS_DISCONNECTED.

See Also:
Connection lifecycle, Constant Field Values

STATUS_DISCONNECTING

static final int STATUS_DISCONNECTING
Lifecycle status: Connection waiting the close() server-answer.
This value may be returned by LifeCycle.getStatus().

Status Entry:
STATUS_CONNECTEDclose() ok → STATUS_DISCONNECTING.
Status Activities:
none: waiting an automatic onConnectionClose() call.
Status Exit:
STATUS_DISCONNECTINGonConnectionClose()STATUS_DISCONNECTED.
STATUS_DISCONNECTINGonConnectionLost()STATUS_DISCONNECTED.

See Also:
Connection lifecycle, Constant Field Values

STATUS_DISCONNECTED

static final int STATUS_DISCONNECTED
Lifecycle status: Connection no more connected to the server and ready to be released.
This value may be returned by LifeCycle.getStatus().

It's always a good practice to release a Connection in this status.

Status Entry:
STATUS_DISCONNECTINGonConnectionClose()STATUS_DISCONNECTED.
any status → onConnectionLost()STATUS_DISCONNECTED.
Status Activities:
LifeCycle.release().
Status Exit:
STATUS_DISCONNECTEDLifeCycle.release()STATUS_RELEASED.

See Also:
Connection lifecycle, Constant Field Values
Method Detail

open

int open()
Try to open this connection with a given server.

This method must be called only when current status is STATUS_INIT.

If this method invocation completed successfully,
then

otherwise

In the latter case it is a good practice to release this Connection.

Returns:

close

int close()
Try to close this connection with a given server.

This method must be called only when current status is STATUS_CONNECTED.

If this method invocation completed successfully,
then

otherwise

It's not a bad practice to unconditionally release this Connection immediately after this method invocation without handling the returned value.

Returns:


Submit a bug or feature to FT\API Programming Support<\font>