net.sf.cindy.session
Class AbstractSessionAcceptor

java.lang.Object
  extended by net.sf.cindy.session.AbstractSessionAcceptor
All Implemented Interfaces:
SessionAcceptor
Direct Known Subclasses:
BlockingSessionAcceptor, NonBlockingSessionAcceptor

public abstract class AbstractSessionAcceptor
extends java.lang.Object
implements SessionAcceptor

Abstract session acceptor.

Version:
$id$
Author:
Roger Chen

Constructor Summary
AbstractSessionAcceptor()
           
 
Method Summary
protected  void exceptionCaught(java.lang.Throwable e)
           
 SessionAcceptorHandler getAcceptorHandler()
          Get the acceptor handler associated with this acceptor.
 int getBacklog()
          Get the maximum queue length for incoming connection.
 java.net.SocketAddress getListenAddress()
          Get the listen address which the accpetor bind with.
 int getListenPort()
          Get the listen port which the acceptor bind with.
 boolean isReuseAddress()
          Tests if SO_REUSEADDR is enabled.
protected  void sessionAccepted(Session session)
           
 void setAcceptorHandler(SessionAcceptorHandler handler)
          Set the acceptor handler associated with this acceptor.
 void setBacklog(int backlog)
          Set the maximum queue length for incoming connection.
 void setListenAddress(java.net.SocketAddress address)
          Set the listen address which the acceptor bind with.
 void setListenPort(int port)
          Set the listen port which the acceptor bind with.
 void setReuseAddress(boolean b)
          Enable/disable the SO_REUSEADDR socket option.
protected  void setServerSocketOptions(java.net.ServerSocket socket)
           
protected  void setSocketOptions(java.net.Socket socket)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.cindy.SessionAcceptor
close, getAcceptedCount, getSessionType, isStarted, start
 

Constructor Detail

AbstractSessionAcceptor

public AbstractSessionAcceptor()
Method Detail

setListenAddress

public void setListenAddress(java.net.SocketAddress address)
Description copied from interface: SessionAcceptor
Set the listen address which the acceptor bind with.

Specified by:
setListenAddress in interface SessionAcceptor
Parameters:
address - the local address

getListenAddress

public java.net.SocketAddress getListenAddress()
Description copied from interface: SessionAcceptor
Get the listen address which the accpetor bind with.

Specified by:
getListenAddress in interface SessionAcceptor
Returns:
the local address

setListenPort

public void setListenPort(int port)
Description copied from interface: SessionAcceptor
Set the listen port which the acceptor bind with.

Specified by:
setListenPort in interface SessionAcceptor
Parameters:
port - the local port

getListenPort

public int getListenPort()
Description copied from interface: SessionAcceptor
Get the listen port which the acceptor bind with.

Specified by:
getListenPort in interface SessionAcceptor
Returns:
the local port

getBacklog

public int getBacklog()
Description copied from interface: SessionAcceptor
Get the maximum queue length for incoming connection. If the returned value equal or less than 0, then the default value will be assumed.

Specified by:
getBacklog in interface SessionAcceptor
Returns:
the maximum length of the queue

setBacklog

public void setBacklog(int backlog)
Description copied from interface: SessionAcceptor
Set the maximum queue length for incoming connection. If the value passed equal or less than 0, then the default value will be assumed.

Specified by:
setBacklog in interface SessionAcceptor
Parameters:
backlog - the maximum length of the queue

isReuseAddress

public boolean isReuseAddress()
Description copied from interface: SessionAcceptor
Tests if SO_REUSEADDR is enabled.

Specified by:
isReuseAddress in interface SessionAcceptor
Returns:
a boolean indicating whether or not SO_REUSEADDR is enabled

setReuseAddress

public void setReuseAddress(boolean b)
Description copied from interface: SessionAcceptor
Enable/disable the SO_REUSEADDR socket option.

Specified by:
setReuseAddress in interface SessionAcceptor
Parameters:
b - whether to enable or disable the socket option

getAcceptorHandler

public SessionAcceptorHandler getAcceptorHandler()
Description copied from interface: SessionAcceptor
Get the acceptor handler associated with this acceptor.

Specified by:
getAcceptorHandler in interface SessionAcceptor
Returns:
session acceptor handler

setAcceptorHandler

public void setAcceptorHandler(SessionAcceptorHandler handler)
Description copied from interface: SessionAcceptor
Set the acceptor handler associated with this acceptor.

Specified by:
setAcceptorHandler in interface SessionAcceptor
Parameters:
handler - session acceptor handler

setSocketOptions

protected void setSocketOptions(java.net.Socket socket)
                         throws java.io.IOException
Throws:
java.io.IOException

setServerSocketOptions

protected void setServerSocketOptions(java.net.ServerSocket socket)
                               throws java.io.IOException
Throws:
java.io.IOException

exceptionCaught

protected final void exceptionCaught(java.lang.Throwable e)

sessionAccepted

protected final void sessionAccepted(Session session)