Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.net.spi
Class SocketChannelConnection

java.lang.Object
  extended by com.jivesoftware.forum.net.spi.SocketChannelConnection
All Implemented Interfaces:
Connection

public class SocketChannelConnection
extends java.lang.Object
implements Connection

A connection based on the nio socket channel.

This implementation will only work on JDK 1.4 or later JVMs.


Field Summary
 
Fields inherited from interface com.jivesoftware.forum.net.Connection
STATUS_READ_ACTIVE, STATUS_READ_CLOSED, STATUS_READ_LOADED, STATUS_READ_READY, STATUS_READ_SCHEDULED
 
Constructor Summary
SocketChannelConnection(java.net.Socket socket, int connectionID, boolean isAcceptCreated, boolean isSecure)
          Creates a new connection using the given socket channel and basic settings.
 
Method Summary
 void close()
          Close this connection and remove registration with connection manager (if any).
 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 readStatus)
          Sets the current read status of the connection.
 void setSecure(boolean isSecure)
          Sets the security status of this connection.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocketChannelConnection

public SocketChannelConnection(java.net.Socket socket,
                               int connectionID,
                               boolean isAcceptCreated,
                               boolean isSecure)
                        throws java.io.IOException

Creates a new connection using the given socket channel and basic settings.

Parameters:
socket - the socket this connection represents.
connectionID - the identifier for this connection.
isAcceptCreated - true if the connection was created by a server accept() call.
isSecure - True if the connection is currently secure.
Throws:
java.io.IOException
Method Detail

getID

public int getID()
Description copied from interface: Connection

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.

Specified by:
getID in interface Connection
Returns:
the ID used to retrieve the connection from the connection manager.

getConnectDate

public java.util.Date getConnectDate()
Description copied from interface: Connection

Obtain the date/time the connection was initially made.

Specified by:
getConnectDate in interface Connection
Returns:
the date the connection was initially made.

getUptime

public long getUptime()
Description copied from interface: Connection

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.

Specified by:
getUptime in interface Connection
Returns:
the number of milliseconds the connection has been open.

getConsumerBandwidthMonitor

public BandwidthMonitor getConsumerBandwidthMonitor()
Description copied from interface: Connection

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

Specified by:
getConsumerBandwidthMonitor in interface Connection
Returns:
the bandwidth monitor watching the raw bandwidth usage of this connection.

getProducerBandwidthMonitor

public BandwidthMonitor getProducerBandwidthMonitor()
Description copied from interface: Connection

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

Specified by:
getProducerBandwidthMonitor in interface Connection
Returns:
the bandwidth monitor watching the raw bandwidth usage of this connection.

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
Description copied from interface: Connection

Obtain the InetAddress describing the connection.

Specified by:
getRemoteAddress in interface Connection
Returns:
the InetAddress describing the underlying connection properties access this resource.

getRemotePort

public int getRemotePort()
Description copied from interface: Connection

Obtain the remote port for this connection.

Specified by:
getRemotePort in interface Connection
Returns:
the remote port for the connection.

getLocalAddress

public java.net.InetAddress getLocalAddress()
Description copied from interface: Connection

Obtain the InetAddress describing the local side of the connection.

Specified by:
getLocalAddress in interface Connection
Returns:
the InetAddress describing the underlying connection properties.

getLocalPort

public int getLocalPort()
Description copied from interface: Connection

Obtain the local port for this connection.

Specified by:
getLocalPort in interface Connection
Returns:
the local port for the connection.

close

public void close()
           throws java.io.IOException
Close this connection and remove registration with connection manager (if any).

Specified by:
close in interface Connection
Throws:
java.io.IOException - if there was problem closing the connection.

isClosed

public boolean isClosed()
Description copied from interface: Connection
Retrieve the closed state of the Session.

Specified by:
isClosed in interface Connection
Returns:
true if the session is closed.

isAcceptCreated

public boolean isAcceptCreated()
Description copied from interface: Connection
Retrieve the mechanism used to open this connection

Specified by:
isAcceptCreated in interface Connection
Returns:
true if the connection was created as a server accept call, false otherwise.

isSecure

public boolean isSecure()
Description copied from interface: Connection

Determines if this connection is secure.

Specified by:
isSecure in interface Connection
Returns:
true if the connection is secure (e.g. SSL/TLS).

setSecure

public void setSecure(boolean isSecure)
Description copied from interface: Connection

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.

Specified by:
setSecure in interface Connection
Parameters:
isSecure - true if the connection is secure (e.g. SSL/TLS).

setConnectionManager

public void setConnectionManager(ConnectionManager manager)
Description copied from interface: Connection

Sets the connection manager this connection belongs to.

Connections may only have on connection manager at a time.

Specified by:
setConnectionManager in interface Connection
Parameters:
manager - the connection manager for the connection.

getReadStatus

public int getReadStatus()
Description copied from interface: Connection
Obtain the current read status of the connection. Must be one of the predefined constants.

Specified by:
getReadStatus in interface Connection
Returns:
the current read status of the connection

setReadStatus

public void setReadStatus(int readStatus)
Description copied from interface: Connection
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.

Specified by:
setReadStatus in interface Connection
Parameters:
readStatus - the new status of the connection

getSocket

public java.net.Socket getSocket()
Specified by:
getSocket in interface Connection

getWriter

public java.io.Writer getWriter()
Specified by:
getWriter in interface Connection

getReader

public java.io.Reader getReader()
Specified by:
getReader in interface Connection

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.