org.indi.reactor
Class Connector

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

public class Connector
extends SimpleEventHandler

EventHandler for active connection estabishment. The Connector regesters with the reactor asking to estabish a connection to a particular server during construction. It called by the reactor and establishes the connection. It creates a new EventHandler using the given EventHandlerFactory and associates it with the newly created connection. After completing this work is unregisters with the reactor.

Author:
Dirk Hünniger

Field Summary
protected  EventHandlerFactory factory
          The EventHandlerFactory used to create new EventHandlers to be associated with the newly created connection
 
Fields inherited from class org.indi.reactor.SimpleEventHandler
channel, reactor, registeredOperations
 
Constructor Summary
Connector(Reactor r, EventHandlerFactory f, java.lang.String host, int port)
          Class Constructor
 
Method Summary
 void onConnect()
          Callback method called by the reactor when the new connection is ready to be established.
 void onConnected(EventHandler h)
          Callback method called when the new connection has been established and a new EvendHandler has be created and associated with it
 
Methods inherited from class org.indi.reactor.SimpleEventHandler
channel, onAccept, onClose, 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 create new EventHandlers to be associated with the newly created connection

Constructor Detail

Connector

public Connector(Reactor r,
                 EventHandlerFactory f,
                 java.lang.String host,
                 int port)
          throws java.io.IOException
Class Constructor

Parameters:
r - The reactor to register with
f - The factory used to create a new EventHandler for the newly created connection
host - The host to connect to
port - The port to connect to
Throws:
java.io.IOException
Method Detail

onConnect

public final void onConnect()
                     throws java.io.IOException
Callback method called by the reactor when the new connection is ready to be established.

Specified by:
onConnect in interface EventHandler
Overrides:
onConnect in class SimpleEventHandler
Throws:
java.io.IOException
See Also:
EventHandler.onConnect()

onConnected

public void onConnected(EventHandler h)
                 throws java.nio.channels.ClosedChannelException,
                        java.io.IOException
Callback method called when the new connection has been established and a new EvendHandler has be created and associated with it

Parameters:
h - The new EventHandler associated with the new connection
Throws:
java.nio.channels.ClosedChannelException
java.io.IOException


Copyright © 2008. All Rights Reserved.