org.norther.tammi.spray.connector.chain
Class ChannelConnection

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.core.pool.PoolableSupport
          extended by org.norther.tammi.spray.connector.chain.AbstractConnection
              extended by org.norther.tammi.spray.connector.chain.ChannelConnection
All Implemented Interfaces:
Closeable, Serializable, Runnable, Poolable, Recyclable, Connection

public class ChannelConnection
extends AbstractConnection

A connection through a non-blocking socket channel registered with the specified key.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.spray.connector.chain.Connection
BUSY, DONE, IDLE, IN_QUEUE, INITIAL
 
Constructor Summary
ChannelConnection(MBeanReference connector, MBeanReference filter, MBeanReference logger, MBeanReference timeout, Thread thread, SelectionKey key, Channel channel)
          Constructs a new connection.
 
Method Summary
 void close()
          Closes this connection and stops execution.
 void dispose()
          Disposes the object by setting its disposed flag.
 int filter()
          Filters the request of this connection.
 int getByteCount()
          Gets the number of bytes written to this connection.
 Channel getChannel()
          Gets the channel of this connection.
 Certificate[] getPeerCertificates()
          Gets the client certificate chain, if available.
 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.
 ServletResponse getResponse()
          Gets of the response of this connection.
 SelectionKey getSelectionKey()
          Gets the selection key of this connection.
 boolean keepConnection()
          Keeps this connection alive in idle after processing request processing if applicable.
 void recycle(MBeanReference connector, MBeanReference filter, MBeanReference logger, MBeanReference timeout, Thread thread, SelectionKey key, Channel channel)
          Recycles an existing connection.
 void setReadyOps(int ops)
          Sets the ready operations set of this connection.
 String toString()
           
 
Methods inherited from class org.norther.tammi.spray.connector.chain.AbstractConnection
connected, disposed, getConnectionStatus, getConnectionTime, getConnectionTimeout, getConnector, getFilter, getLogger, getMBeanServer, getReadyOps, getRequestTimeout, getTimeout, isContextThread, isKeepConnection, log, recycle, run, waitUntilDone
 
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport
recycled
 
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.pool.Recyclable
isDisposed, recycle
 

Constructor Detail

ChannelConnection

public ChannelConnection(MBeanReference connector,
                         MBeanReference filter,
                         MBeanReference logger,
                         MBeanReference timeout,
                         Thread thread,
                         SelectionKey key,
                         Channel channel)
Constructs a new connection.

Parameters:
connector - the socket connector.
filter - the active filter.
logger - the active logger.
timeout - the active timeout.
thread - the connector thread.
key - the selection key.
channel - the channel.
Method Detail

recycle

public void recycle(MBeanReference connector,
                    MBeanReference filter,
                    MBeanReference logger,
                    MBeanReference timeout,
                    Thread thread,
                    SelectionKey key,
                    Channel channel)
Recycles an existing connection.

Parameters:
connector - the socket connector.
filter - the active filter.
logger - the active logger.
timeout - the active timeout.
thread - the connector thread.
key - the selection key.
channel - the channel.

dispose

public void dispose()
Description copied from class: RecyclableSupport
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class AbstractConnection

setReadyOps

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

Specified by:
setReadyOps in interface Connection
Overrides:
setReadyOps in class AbstractConnection
Parameters:
ops - the operations set as a bit mask.

keepConnection

public boolean keepConnection()
Description copied from interface: Connection
Keeps this connection alive in idle after processing request processing if applicable.

Specified by:
keepConnection in interface Connection
Overrides:
keepConnection in class AbstractConnection
Returns:
true if kept, false otherwise.

getByteCount

public int getByteCount()
Description copied from interface: Connection
Gets the number of bytes written to this connection.

Returns:
the number of bytes written.

getRemotePort

public int getRemotePort()
Description copied from interface: Connection
Gets the remote port of this connection.

Returns:
the remote port.

getRemoteAddr

public String getRemoteAddr()
Description copied from interface: Connection
Gets the remote address of this connection.

Returns:
the remote address.

getRequest

public ServletRequest getRequest()
Description copied from interface: Connection
Gets of the request of this connection.

Returns:
the request.

getResponse

public ServletResponse getResponse()
Description copied from interface: Connection
Gets of the response of this connection.

Returns:
the response.

getPeerCertificates

public Certificate[] getPeerCertificates()
Description copied from interface: Connection
Gets the client certificate chain, if available.

Returns:
an array of certificates or null.

filter

public int filter()
           throws ServletException,
                  IOException
Description copied from interface: Connection
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.

close

public void close()
Description copied from interface: Connection
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
Specified by:
close in interface Connection
Overrides:
close in class AbstractConnection

toString

public String toString()
Overrides:
toString in class Object

getSelectionKey

public SelectionKey getSelectionKey()
Gets the selection key of this connection.

Returns:
the selection key.

getChannel

public Channel getChannel()
Gets the channel of this connection.

Returns:
the channel.


Copyright © 2004 The Norther Organization. All rights reserved.