org.apache.qpid.proton.driver
Interface Driver


public interface Driver

A driver for the proton engine. Manages Connector's and Listener's, which act as intermediaries between the proton engine and the network. Provides methods for the application to access the "top half" of the engine API when the state of the engine may have changed due to I/O or timing events - see connector(). Connectors incorporate the SASL engine in order to provide a complete network stack: AMQP over SASL over TCP. Unless otherwise stated, methods on Driver implementations are not necessarily thread-safe.


Method Summary
 Connector connector()
          Get the next active connector in the driver.
 java.lang.Iterable<Connector> connectors()
          Return an iterator over all connectors.
<C> Connector<C>
createConnector(java.nio.channels.SelectableChannel fd, C context)
          Create a connector using the existing file descriptor.
<C> Connector<C>
createConnector(java.lang.String host, int port, C context)
          Construct a connector to the given remote address.
<C> Listener<C>
createListener(java.nio.channels.ServerSocketChannel c, C context)
          Create a listener using the existing channel.
<C> Listener<C>
createListener(java.lang.String host, int port, C context)
          Construct a listener for the given address.
 void destroy()
          Destruct the driver and all associated listeners, connectors and other resources.
 boolean doWait(long timeout)
          Wait for an active connector or listener, or for wakeup() to be called.
 Listener listener()
          Get the next listener with pending data in the driver.
 java.lang.Iterable<Listener> listeners()
          Return an iterator over all listeners.
 void wakeup()
          Force doWait(long) to return.
 

Method Detail

wakeup

void wakeup()
Force doWait(long) to return. If the driver is not currently waiting then the next invocation of doWait(long) will return immediately unless the connector() method is invoked in the meantime. Thread-safe.


doWait

boolean doWait(long timeout)
Wait for an active connector or listener, or for wakeup() to be called. Thread-safe.

Parameters:
timeout - maximum time in milliseconds to wait. 0 means wait indefinitely.
returns - true if woken up

listener

Listener listener()
Get the next listener with pending data in the driver.

Returns:
null if no active listener available

connector

Connector connector()
Get the next active connector in the driver. Returns the next connector with pending inbound data, available capacity for outbound data, or pending tick. Clears the wake-up status that is set by wakeup().

Returns:
null if no active connector available

destroy

void destroy()
Destruct the driver and all associated listeners, connectors and other resources.


createListener

<C> Listener<C> createListener(java.lang.String host,
                               int port,
                               C context)
Construct a listener for the given address.

Parameters:
host - local host address to listen on
port - local port to listen on
context - application-supplied, can be accessed via getContext() method on a listener.
Returns:
a new listener on the given host:port, null if error

createListener

<C> Listener<C> createListener(java.nio.channels.ServerSocketChannel c,
                               C context)
Create a listener using the existing channel.

Parameters:
c - existing SocketChannel for listener to listen on
context - application-supplied, can be accessed via getContext() method on a listener.
Returns:
a new listener on the given channel, null if error

createConnector

<C> Connector<C> createConnector(java.lang.String host,
                                 int port,
                                 C context)
Construct a connector to the given remote address.

Parameters:
host - remote host to connect to.
port - remote port to connect to.
context - application-supplied, can be accessed via getContext() method on a listener.
Returns:
a new connector to the given remote, or null on error.

createConnector

<C> Connector<C> createConnector(java.nio.channels.SelectableChannel fd,
                                 C context)
Create a connector using the existing file descriptor.

Parameters:
fd - existing SocketChannel for listener to listen on
context - application-supplied, can be accessed via getContext() method on a listener.
Returns:
a new connector to the given host:port, null if error.

listeners

java.lang.Iterable<Listener> listeners()
Return an iterator over all listeners.


connectors

java.lang.Iterable<Connector> connectors()
Return an iterator over all connectors.