Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.net
Interface Connection

All Known Implementing Classes:
SocketChannelConnection

public interface Connection

Generic representation of a network connection.

This interface intentionally tries to abstract the underlying socket to enable generic use with traditional and nio style sockets.


Field Summary
static int STATUS_READ_ACTIVE
          Status indicating the connection is actively being handled by worker thread.
static int STATUS_READ_CLOSED
          Status indicating the connection is closed and can't be read.
static int STATUS_READ_LOADED
          Status indicating the connection is loaded with read data.
static int STATUS_READ_READY
          Status indicating the connection is ready to read.
static int STATUS_READ_SCHEDULED
          Status indicating the connection has been scheduled for handling by worker thread.
 
Method Summary
 void close()
          Close the connection removing any registrations with session managers.
 java.util.Date getConnectDate()
          Obtain the date/time the connection was initially made.
 BandwidthMonitor getConsumerBandwidthMonitor()
          Obtain the bandwidth monitor watching the raw network traffic for this connection's DataConsumer.
 int getID()
          Obtain a unique key to identify this connection in the connection manager.
 java.net.InetAddress getLocalAddress()
          Obtain the InetAddress describing the local side of the connection.
 int getLocalPort()
          Obtain the local port for this connection.
 BandwidthMonitor getProducerBandwidthMonitor()
          Obtain the bandwidth monitor watching the raw network traffic for this connection's DataProducer.
 java.io.Reader getReader()
           
 int getReadStatus()
          Obtain the current read status of the connection.
 java.net.InetAddress getRemoteAddress()
          Obtain the InetAddress describing the connection.
 int getRemotePort()
          Obtain the remote port for this connection.
 java.net.Socket getSocket()
           
 long getUptime()
          Obtain the number of milliseconds the connection has been open.
 java.io.Writer getWriter()
           
 boolean isAcceptCreated()
          Retrieve the mechanism used to open this connection
 boolean isClosed()
          Retrieve the closed state of the Session.
 boolean isSecure()
          Determines if this connection is secure.
 void setConnectionManager(ConnectionManager manager)
          Sets the connection manager this connection belongs to.
 void setReadStatus(int status)
          Sets the current read status of the connection.
 void setSecure(boolean secure)
          Sets the security status of this connection.
 

Field Detail

STATUS_READ_CLOSED

static final int STATUS_READ_CLOSED
Status indicating the connection is closed and can't be read.

See Also:
Constant Field Values

STATUS_READ_READY

static final int STATUS_READ_READY
Status indicating the connection is ready to read.

See Also:
Constant Field Values

STATUS_READ_LOADED

static final int STATUS_READ_LOADED
Status indicating the connection is loaded with read data.

See Also:
Constant Field Values

STATUS_READ_SCHEDULED

static final int STATUS_READ_SCHEDULED
Status indicating the connection has been scheduled for handling by worker thread.

See Also:
Constant Field Values

STATUS_READ_ACTIVE

static final int STATUS_READ_ACTIVE
Status indicating the connection is actively being handled by worker thread.

See Also:
Constant Field Values
Method Detail

getID

int getID()

Obtain a unique key to identify this connection in the connection manager. The ID is primarily used by stateless admin interfaces (e.g. HTTP) to allow a connection to be easily identified across accesses to the connection manager. The ID is only unique within the server at the time the connection is alive. IDs will be recycled on particularly long lived servers and should not be assumed to identify the same connection across server restarts, server instances, cluster members, etc.

Returns:
the ID used to retrieve the connection from the connection manager.

getConnectDate

java.util.Date getConnectDate()

Obtain the date/time the connection was initially made.

Returns:
the date the connection was initially made.

getUptime

long getUptime()

Obtain the number of milliseconds the connection has been open.

If the connection is still open, this is the time difference between the result of getConnectDate() and the current time (e.g. System.currentTimeMillis() otherwise it returns the number of milliseconds between the opening and closing of the connection.

Returns:
the number of milliseconds the connection has been open.

getConsumerBandwidthMonitor

BandwidthMonitor getConsumerBandwidthMonitor()

Obtain the bandwidth monitor watching the raw network traffic for this connection's DataConsumer.

Returns:
the bandwidth monitor watching the raw bandwidth usage of this connection.

getProducerBandwidthMonitor

BandwidthMonitor getProducerBandwidthMonitor()

Obtain the bandwidth monitor watching the raw network traffic for this connection's DataProducer.

Returns:
the bandwidth monitor watching the raw bandwidth usage of this connection.

getRemoteAddress

java.net.InetAddress getRemoteAddress()

Obtain the InetAddress describing the connection.

Returns:
the InetAddress describing the underlying connection properties access this resource.

getRemotePort

int getRemotePort()

Obtain the remote port for this connection.

Returns:
the remote port for the connection.

getLocalAddress

java.net.InetAddress getLocalAddress()

Obtain the InetAddress describing the local side of the connection.

Returns:
the InetAddress describing the underlying connection properties.

getLocalPort

int getLocalPort()

Obtain the local port for this connection.

Returns:
the local port for the connection.

getSocket

java.net.Socket getSocket()

getWriter

java.io.Writer getWriter()

getReader

java.io.Reader getReader()

close

void close()
           throws java.io.IOException
Close the connection removing any registrations with session managers.

Throws:
java.io.IOException - if there was problem closing the connection.

isClosed

boolean isClosed()
Retrieve the closed state of the Session.

Returns:
true if the session is closed.

isAcceptCreated

boolean isAcceptCreated()
Retrieve the mechanism used to open this connection

Returns:
true if the connection was created as a server accept call, false otherwise.

isSecure

boolean isSecure()

Determines if this connection is secure.

Returns:
true if the connection is secure (e.g. SSL/TLS).

setSecure

void setSecure(boolean secure)

Sets the security status of this connection.

Ordinarily a connection is either insecure (standard Socket or SocketChannel) or secure (SSLSocket). However, many protocols including XMPP and NNTP allow the use of SASL where transport layer security can be established after the connection is created. So application level objects must be able to change the security status of a connection during such negotiations.

Parameters:
secure - true if the connection is secure (e.g. SSL/TLS).

setConnectionManager

void setConnectionManager(ConnectionManager manager)

Sets the connection manager this connection belongs to.

Connections may only have on connection manager at a time.

Parameters:
manager - the connection manager for the connection.

getReadStatus

int getReadStatus()
Obtain the current read status of the connection. Must be one of the predefined constants.

Returns:
the current read status of the connection

setReadStatus

void setReadStatus(int status)
Sets the current read status of the connection. Only worker threads and the connection object itself should call this method. Any other usages may leave the connection in an indeterminate state and cause server failure.

Parameters:
status - the new status of the connection

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.