|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectau.com.terabit.jproactor.Acceptor
public class Acceptor
The Acceptor class allows to start user defined server-side
protocol servers.
Acceptor opens java.net.ServerSocketChannel and requests
Demultiplexor to execute accept operation, once accept is completed
registered AsynchChannelHandlerFactory instantiates a new Protocol
object and starts execution using the same multiplexor instance.
The following code fragment shows how to start test EchoServer using acceptor:
// Create and run Demultiplexor instance for EchoServer on port 9999 Demultiplexor m = new Demultiplexor(); m.start(); // Create acceptor instance for EchoServer on port 9999 Acceptor a = new Acceptor( m, new EchoServerProtocolFactory(), 9999 ); // start listening for incoming connections a.start();
$Revision$ $Date$| Field Summary | |
|---|---|
static int |
NUM_INITIAL_ACCEPTS
How may accepts to perform, default value |
| Constructor Summary | |
|---|---|
Acceptor(Demultiplexor m,
int port,
AsynchChannelHandlerFactory factory)
Creates acceptor for the specified AsynchHandlerFactory
and on the specified tcp/ip port. |
|
Acceptor(Demultiplexor m,
int port,
java.lang.String host,
AsynchChannelHandlerFactory factory)
Creates acceptor for the specified AsynchHandlerFactory
and on the specified tcp/ip port and host. |
|
Acceptor(Demultiplexor m,
java.net.SocketAddress address,
AsynchChannelHandlerFactory factory)
Creates acceptor for the specified AsynchHandlerFactory
and on the specified Socket Address. |
|
| Method Summary | |
|---|---|
void |
acceptCompleted(OpAccept op)
Implementation of AsynchChannelHandler#acceptCompleted(OpAccept op). |
void |
channelAttached(AsynchChannel channel)
Notifies that this handler is associated with the TCPAsynchChannel
instance. |
void |
channelClosed(AsynchChannel channel)
Notifies that cnannel is closed. |
void |
start()
Starts acceptor, using NUM_INITIAL_ACCEPTS default number of
accept operations. |
void |
start(int numInitialAccepts)
Starts accept operation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NUM_INITIAL_ACCEPTS
| Constructor Detail |
|---|
public Acceptor(Demultiplexor m,
int port,
AsynchChannelHandlerFactory factory)
throws java.net.UnknownHostException
AsynchHandlerFactory
and on the specified tcp/ip port.
m - - multiplexor instancefactory - - protocol factoryport - - tcp/ip port to listen on
java.net.UnknownHostException
public Acceptor(Demultiplexor m,
int port,
java.lang.String host,
AsynchChannelHandlerFactory factory)
AsynchHandlerFactory
and on the specified tcp/ip port and host.
m - - multiplexor instancefactory - - protocol factoryport - - tcp/ip port to listen onhost - - host name
public Acceptor(Demultiplexor m,
java.net.SocketAddress address,
AsynchChannelHandlerFactory factory)
AsynchHandlerFactory
and on the specified Socket Address.
m - - multiplexor instancefactory - - protocol factoryaddress - - socket address to listen on| Method Detail |
|---|
public void acceptCompleted(OpAccept op)
throws java.lang.Exception
AsynchChannelHandler#acceptCompleted(OpAccept op).
Executes accept operation, non-blocking, instantiates protocol on the
accepted channel, starts protocol using acceptor's multiplexor instance.
acceptCompleted in interface AsynchAcceptHandlerjava.lang.Exception - if this method is called
public void channelAttached(AsynchChannel channel)
throws java.lang.Exception
AsynchChannelHandlerTCPAsynchChannel
instance.
One AsynchHandler can be shared with multiple socket
channels, e.g. chat server.
This mehtod is called by TCPAsynchChannel.
channelAttached in interface AsynchChannelHandlerchannel - a new channel that is associated with this protocol.
java.lang.Exception
public void channelClosed(AsynchChannel channel)
throws java.lang.Exception
AsynchChannelHandler
channelClosed in interface AsynchChannelHandlerchannel - asynchronous channel that was closed
java.lang.Exception
public void start()
throws java.lang.Exception
NUM_INITIAL_ACCEPTS default number of
accept operations.
java.lang.Exceptionau.com.terabit.multiplexor.AsynchChannelHandler#start(),
start(int numInitialAccepts)
public void start(int numInitialAccepts)
throws java.lang.Exception
java.io.IOException - if error occurs, the operation won't be started
in this case.
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||