org.indi.reactor
Class Acceptor

java.lang.Object
  extended by org.indi.reactor.SimpleEventHandler
      extended by org.indi.reactor.Acceptor
All Implemented Interfaces:
EventHandler

public class Acceptor
extends SimpleEventHandler

EventHandler for passive connection establishment. The Acceptor is registered with the reactor during construction. Whenever a new client connects, on the specified port a new EventHandler is created using the given EventHandlerFactory and associated with the newly created connection, as well as registered with the reactor.

Author:
Dirk Hünniger

Field Summary
protected  EventHandlerFactory factory
          The EventHandlerFactory used to produce new EventHandlers for new connections
 
Fields inherited from class org.indi.reactor.SimpleEventHandler
channel, reactor, registeredOperations
 
Constructor Summary
protected Acceptor(Reactor r, EventHandlerFactory f, int port)
          Class Constructor
 
Method Summary
 void onAccept()
          Callback method called by the reactor when a new client is ready to be accepted.
 void onAccepted(EventHandler h)
          Callbackmethod called after the connection has been established and a new EventHandler has been created and set up to interact with this new conenction
 
Methods inherited from class org.indi.reactor.SimpleEventHandler
channel, onClose, onConnect, onRead, onWrite, register
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected EventHandlerFactory factory
The EventHandlerFactory used to produce new EventHandlers for new connections

Constructor Detail

Acceptor

protected Acceptor(Reactor r,
                   EventHandlerFactory f,
                   int port)
            throws java.io.IOException
Class Constructor

Parameters:
r - the reactor the Acceptor is to be registered with
f - the EventHandlerFactory to be used for the creation of new EventHandlers for new connections
port - The port to listen for new connections
Throws:
java.io.IOException
Method Detail

onAccept

public final void onAccept()
                    throws java.io.IOException
Callback method called by the reactor when a new client is ready to be accepted. Implemented here.

Specified by:
onAccept in interface EventHandler
Overrides:
onAccept in class SimpleEventHandler
Throws:
java.io.IOException
java.nio.channels.ClosedChannelException
See Also:
EventHandler.onAccept()

onAccepted

public void onAccepted(EventHandler h)
                throws java.nio.channels.ClosedChannelException,
                       java.io.IOException
Callbackmethod called after the connection has been established and a new EventHandler has been created and set up to interact with this new conenction

Parameters:
h - The newly created EventHandler
Throws:
java.nio.channels.ClosedChannelException
java.io.IOException


Copyright © 2008. All Rights Reserved.