Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.ng.wire.version10

# Class V10AsynchronousChannel

java.lang.Object
org.firebirdsql.gds.ng.wire.version10.V10AsynchronousChannel

All Implemented Interfaces:
  `FbWireAsynchronousChannel`

public class V10AsynchronousChannel extends Object implements FbWireAsynchronousChannel
Asynchronous channel implementation for the V10 wire protocol.

Since:
  3.0
Author:
  Mark Rotteveel

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `V10AsynchronousChannel(FbWireDatabase database)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addChannelListener(AsynchronousChannelListener listener)`
  Register a listener for this channel.
  `void`
  `cancelEvent(EventHandle eventHandle)`
  Cancels a registered event.
  `void`
  `close()`
  Disconnect the asynchronous channel.
  `void`
  `connect(String hostName, int portNumber, int auxHandle)`
  Connects the asynchronous channel to the specified port.
  `ByteBuffer`
  `getEventBuffer()`
  `SocketChannel`
  `getSocketChannel()`
  `boolean`
  `isConnected()`
  `void`
  `processEventData()`
  Process the current event data in the buffer.
  `void`
  `queueEvent(EventHandle eventHandle)`
  Queues a wait for an event.
  `void`
  `removeChannelListener(AsynchronousChannelListener listener)`
  Remove a listener from this channel
  `protected final LockCloseable`
  `withLock()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### V10AsynchronousChannel

    public V10AsynchronousChannel(FbWireDatabase database)

- ## Method Details

  - ### withLock

    protected final LockCloseable withLock()
    See Also:
      - `FbAttachment.withLock()`

  - ### connect

    public void connect(String hostName, int portNumber, int auxHandle) throws SQLException
    Description copied from interface: `FbWireAsynchronousChannel`
    Connects the asynchronous channel to the specified port.
    Specified by:
      `connect` in interface `FbWireAsynchronousChannel`
    Parameters:
      `hostName` - Hostname
      `portNumber` - The port number
      `auxHandle` - Handle identifier for this asynchronous channel
    Throws:
      `SQLException` - For errors connecting, or if the connection is already established

  - ### close

    public void close() throws SQLException
    Description copied from interface: `FbWireAsynchronousChannel`
    Disconnect the asynchronous channel.

    Once closed, the connection can be reestablished using `FbWireAsynchronousChannel.connect(String, int, int)`.

    Calling `close` on a closed channel is a no-op; no exception should be thrown.

    Specified by:
      `close` in interface `FbWireAsynchronousChannel`
    Throws:
      `SQLException` - For errors closing the channel

  - ### isConnected

    public boolean isConnected()
    Specified by:
      `isConnected` in interface `FbWireAsynchronousChannel`
    Returns:
      `true` if connected, otherwise `false`

  - ### addChannelListener

    public void addChannelListener(AsynchronousChannelListener listener)
    Description copied from interface: `FbWireAsynchronousChannel`
    Register a listener for this channel.
    Specified by:
      `addChannelListener` in interface `FbWireAsynchronousChannel`
    Parameters:
      `listener` - Listener

  - ### removeChannelListener

    public void removeChannelListener(AsynchronousChannelListener listener)
    Description copied from interface: `FbWireAsynchronousChannel`
    Remove a listener from this channel
    Specified by:
      `removeChannelListener` in interface `FbWireAsynchronousChannel`
    Parameters:
      `listener` - Listener

  - ### getSocketChannel

    public SocketChannel getSocketChannel() throws SQLException
    Specified by:
      `getSocketChannel` in interface `FbWireAsynchronousChannel`
    Returns:
      The socket channel associated with this asynchronous channel
    Throws:
      `SQLException` - If not currently connected

  - ### getEventBuffer

    public ByteBuffer getEventBuffer()
    Specified by:
      `getEventBuffer` in interface `FbWireAsynchronousChannel`
    Returns:
      The byte buffer for event data

  - ### processEventData

    public void processEventData()
    Description copied from interface: `FbWireAsynchronousChannel`
    Process the current event data in the buffer.

    This is only to be called by the `AsynchronousProcessor`. Implementations should be ready to deal with incomplete data in the event buffer (eg by not processing).

    Specified by:
      `processEventData` in interface `FbWireAsynchronousChannel`

  - ### queueEvent

    public void queueEvent(EventHandle eventHandle) throws SQLException
    Description copied from interface: `FbWireAsynchronousChannel`
    Queues a wait for an event.
    Specified by:
      `queueEvent` in interface `FbWireAsynchronousChannel`
    Parameters:
      `eventHandle` - Event handle
    Throws:
      `SQLException`

  - ### cancelEvent

    public void cancelEvent(EventHandle eventHandle) throws SQLException
    Description copied from interface: `FbWireAsynchronousChannel`
    Cancels a registered event.
    Specified by:
      `cancelEvent` in interface `FbWireAsynchronousChannel`
    Parameters:
      `eventHandle` - The event handle to cancel
    Throws:
      `SQLException` - For errors cancelling the event