SelectorHandler
* @author Jeanfrancois Arcand
*/
public interface ConnectorHandlerController.Protocol
*/
public Controller.Protocol protocol();
/**
* Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ
* or OP_WRITE), the Controller
will invoke the
* CallBackHandler.
*
* @param remoteAddress remote address to connect
* @param callbackHandler the handler invoked by the Controller when an non
* blocking operation is ready to be handled.
* @param e SelectorHandler
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress, CallbackHandler callbackHandler, E e) throws IOException;
/**
* Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ
* or OP_WRITE), the Controller
will invoke the
* CallBackHandler.
*
* @param remoteAddress remote address to connect
* @param callbackHandler the handler invoked by the Controller when
* an non blocking operation is ready to be handled.
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress,
CallbackHandler callbackHandler) throws IOException;
/**
* Connect to hostname:port. Internally an instance of Controller and its
* default SelectorHandler will be created everytime this method is called.
* This method should be used only and only if no external Controller has
* been initialized.
*
* @param remoteAddress remote address to connect
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress) throws IOException;
/**
* Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ
* or OP_WRITE), the Controller
will invoke the
* CallBackHandler.
*
* @param remoteAddress remote address to connect
* @param localAddress local address to bind
* @param callbackHandler the handler invoked by the Controller when
* an non blocking operation is ready to be handled.
* @param e SelectorHandler
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress, SocketAddress localAddress, CallbackHandler callbackHandler, E e) throws IOException;
/**
* Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ
* or OP_WRITE), the Controller
will invoke the
* CallBackHandler.
*
* @param remoteAddress remote address to connect
* @param localAddress local address to bind
* @param callbackHandler the handler invoked by the Controller when
* an non blocking operation is ready to be handled.
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress, SocketAddress localAddress,
CallbackHandler callbackHandler) throws IOException;
/**
* Connect to hostname:port. Internally an instance of Controller and its
* default SelectorHandler will be created everytime this method is called.
* This method should be used only and only if no external Controller has
* been initialized.
*
* @param remoteAddress remote address to connect
* @param localAddress local address to bind
* @throws java.io.IOException
*/
public void connect(SocketAddress remoteAddress, SocketAddress localAddress) throws IOException;
/**
* Read bytes. If blocking is set to true, a pool of temporary
* Selector
will be used to read bytes.
*
* @param byteBuffer The byteBuffer to store bytes.
* @param blocking true if a a pool of temporary Selector is
* required to handle a blocking read.
* @return number of bytes read
* @throws java.io.IOException
*/
public long read(ByteBuffer byteBuffer, boolean blocking) throws IOException;
/**
* Writes bytes. If blocking is set to true, a pool of temporary
* Selector
will be used to writes bytes.
*
* @param byteBuffer The byteBuffer to write.
* @param blocking true if a a pool of temporary Selector
* is required to handle a blocking write.
* @return number of bytes written
* @throws java.io.IOException
*/
public long write(ByteBuffer byteBuffer, boolean blocking) throws IOException;
/**
* Close the underlying connection.
*
* @throws java.io.IOException
*/
public void close() throws IOException;
/**
* Decide how the OP_CONNECT final steps are handled.
* @param key SelectionKey
*/
public void finishConnect(SelectionKey key);
/**
* Set the Controller
associated with this instance.
* @param controller Controller
*/
public void setController(Controller controller);
/**
* Return the Controller
*
* @return
*/
public Controller getController();
/**
* Method returns SelectorHandler
, which manages this
* ConnectorHandler
*
* @return SelectorHandler
*/
public E getSelectorHandler();
/**
* Method returns ConnectorHandler
's underlying channel
*
* @return channel
*/
public C getUnderlyingChannel();
/**
* Returns ConnectorHandler
's callback handler instance,
* which is used to process occuring events
*
* @return callback handler
*/
public CallbackHandler getCallbackHandler();
/**
* Sets an existing channel for this ConnectorHandler. This can be used to
* (re)use this ConnectorHandler for an already existing connection.
*
* The controller which controls the channel must also be set.
* @param channel The channel to use.
* @see #setController(Controller).
*/
public void setUnderlyingChannel(C channel);
/**
* Sets ConnectorHandler
's callback handler instance, which
* is used to process occuring events
*
* @param callbackHandler handler
*/
public void setCallbackHandler(CallbackHandler callbackHandler);
}