org.norther.tammi.spray.connector.chain
Interface Connection

All Superinterfaces:
Closeable, Runnable
All Known Implementing Classes:
AbstractConnection, ChannelConnection, InterConnection, OverflowConnection, ServletConnection, SocketConnection

public interface Connection
extends Runnable, Closeable

An interface to connections maintaining communication channels to clients.

Note that the close and setReadySet methods may be called from other threads during connection execution and must thus be thread safe.

Version:
$Id: Connection.java,v 1.16 2010-03-10 06:46:29 cvsimp Exp $
Author:
Ilkka Priha

Nested Class Summary
static class Connection.Status
          The connection status.
 
Method Summary
 void busy()
          Resets the status of this connection to busy during time-consuming requests.
 void close()
          Closes this connection and stops execution.
 void connected()
          Sets the status of this connection to busy after idle.
 int filter()
          Filters the request of this connection.
 int getByteCount()
          Gets the number of bytes written to this connection.
 Connection.Status getConnectionStatus()
          Gets the connection status of this connection.
 long getConnectionTime()
          Gets the connection time of this connection.
 int getConnectionTimeout()
          Gets the connection timeout of this connection.
 Connector getConnector()
          Gets the connector of this connection.
 Filter getFilter()
          Gets the filter of this connection.
 Logger getLogger()
          Gets the logger of this connection.
 MBeanServer getMBeanServer()
          Gets the MBean server of this connection.
 Certificate[] getPeerCertificates()
          Gets the client certificate chain, if available.
 int getReadyOps()
          Gets the ready operations set of this connection.
 String getRemoteAddr()
          Gets the remote address of this connection.
 int getRemotePort()
          Gets the remote port of this connection.
 ServletRequest getRequest()
          Gets of the request of this connection.
 int getRequestTimeout()
          Gets the request timeout of this connection.
 ServletResponse getResponse()
          Gets of the response of this connection.
 Timeout getTimeout()
          Gets the timer of this connection.
 boolean isConnected()
          Checks whether this connection is still connected.
 boolean isContextThread()
          Checks whether this connection executes in a connector context thread.
 boolean isKeepConnection()
          Checks whether to keep this connection alive in idle after request processing.
 boolean keepConnection()
          Keeps this connection alive in idle after processing request processing if applicable.
 void log()
          Logs the request of this connection, if applicable
 void setReadyOps(int ops)
          Sets the ready operations set of this connection.
 boolean waitUntilDone(int msecs)
          Waits until this the execution of connection is done.
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

getConnector

Connector getConnector()
Gets the connector of this connection.

Returns:
the connector.

getFilter

Filter getFilter()
Gets the filter of this connection.

Returns:
the filter.

getLogger

Logger getLogger()
Gets the logger of this connection.

Returns:
the logger.

getTimeout

Timeout getTimeout()
Gets the timer of this connection.

Returns:
the timer.

getMBeanServer

MBeanServer getMBeanServer()
Gets the MBean server of this connection.

Returns:
the server.

isContextThread

boolean isContextThread()
Checks whether this connection executes in a connector context thread.

Returns:
true if a context thread, false otherwise.

isConnected

boolean isConnected()
Checks whether this connection is still connected.

Returns:
true if connected, false otherwise.

getConnectionStatus

Connection.Status getConnectionStatus()
Gets the connection status of this connection.

Returns:
the status.

getConnectionTime

long getConnectionTime()
Gets the connection time of this connection.

Returns:
the connection time in msecs.

connected

void connected()
Sets the status of this connection to busy after idle.


busy

void busy()
Resets the status of this connection to busy during time-consuming requests.


getRequestTimeout

int getRequestTimeout()
Gets the request timeout of this connection.

Returns:
the request timeout in msecs.

getConnectionTimeout

int getConnectionTimeout()
Gets the connection timeout of this connection.

Returns:
the connection timeout in msecs.

getReadyOps

int getReadyOps()
Gets the ready operations set of this connection.

Returns:
the operations set as a bit mask.

setReadyOps

void setReadyOps(int ops)
Sets the ready operations set of this connection.

Note that this method must be thread safe and not causing deadlocks as it may be called by several threads during channel selections.

Parameters:
ops - the operations set as a bit mask.

isKeepConnection

boolean isKeepConnection()
Checks whether to keep this connection alive in idle after request processing.

Returns:
true to keep, false otherwise.

keepConnection

boolean keepConnection()
Keeps this connection alive in idle after processing request processing if applicable.

Returns:
true if kept, false otherwise.

getByteCount

int getByteCount()
Gets the number of bytes written to this connection.

Returns:
the number of bytes written.

getRemotePort

int getRemotePort()
Gets the remote port of this connection.

Returns:
the remote port.

getRemoteAddr

String getRemoteAddr()
Gets the remote address of this connection.

Returns:
the remote address.

getRequest

ServletRequest getRequest()
Gets of the request of this connection.

Returns:
the request.

getResponse

ServletResponse getResponse()
Gets of the response of this connection.

Returns:
the response.

getPeerCertificates

Certificate[] getPeerCertificates()
Gets the client certificate chain, if available.

Returns:
an array of certificates or null.

filter

int filter()
           throws ServletException,
                  IOException
Filters the request of this connection. It should return the number of available bytes in the connection for reprocessing or -1 to close the connection.

Returns:
the number of bytes to reprocess.
Throws:
ServletException - for servlet errors.
IOException - for general errors.

waitUntilDone

boolean waitUntilDone(int msecs)
Waits until this the execution of connection is done.

Parameters:
msecs - a timeout to wait in msecs.
Returns:
true if done, otherwise false.

close

void close()
Closes this connection and stops execution.

Note that this method must be thread safe and not causing deadlocks as it may be called by several threads during timeouts.

Specified by:
close in interface Closeable

log

void log()
Logs the request of this connection, if applicable



Copyright © 2004 The Norther Organization. All rights reserved.