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

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.SocketConnection
All Implemented Interfaces:
Closeable, Serializable, Runnable, Poolable, Recyclable, Connection
Direct Known Subclasses:
OverflowConnection

public class SocketConnection
extends AbstractConnection

A connection through a socket.

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
SocketConnection(MBeanReference connector, MBeanReference filter, MBeanReference logger, MBeanReference timeout, Thread thread, Socket socket)
          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.
 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.
 Socket getSocket()
          Gets the socket of this connection.
 void recycle(MBeanReference connector, MBeanReference filter, MBeanReference logger, MBeanReference timeout, Thread thread, Socket socket)
          Recycles an existing 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, keepConnection, log, recycle, run, setReadyOps, 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

SocketConnection

public SocketConnection(MBeanReference connector,
                        MBeanReference filter,
                        MBeanReference logger,
                        MBeanReference timeout,
                        Thread thread,
                        Socket socket)
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.
socket - the socket.
Method Detail

recycle

public void recycle(MBeanReference connector,
                    MBeanReference filter,
                    MBeanReference logger,
                    MBeanReference timeout,
                    Thread thread,
                    Socket socket)
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.
socket - the socket.

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

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

getSocket

public Socket getSocket()
Gets the socket of this connection.

Returns:
the socket.


Copyright © 2004 The Norther Organization. All rights reserved.