org.firebirdsql.gds.ng.wire

## Class AbstractFbWireService

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractFbAttachment<T>
  - - org.firebirdsql.gds.ng.AbstractFbService<WireServiceConnection>
    - - org.firebirdsql.gds.ng.wire.AbstractFbWireService

- All Implemented Interfaces:
    java.lang.AutoCloseable, FbAttachment, FbService, ExceptionListenable, FbWireAttachment, FbWireService
  Direct Known Subclasses:
    V10Service

      public abstract class AbstractFbWireService
      extends AbstractFbService<WireServiceConnection>
      implements FbWireService

  Abstract service implementation for the wire protocol.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment

      `FbWireAttachment.AcceptPacket`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ProtocolDescriptor` | `protocolDescriptor`
    `protected FbWireOperations` | `wireOperations`

    - ### Fields inherited from class org.firebirdsql.gds.ng.AbstractFbService

      `serviceListenerDispatcher`

    - ### Fields inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment

      `connection, exceptionListenerDispatcher`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractFbWireService(WireServiceConnection connection, ProtocolDescriptor descriptor)` Creates an AbstractFbWireDatabase instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkAttached()` Checks if a physical connection to the server is established and if the connection is attached to a database.
    `protected void` | `checkConnected()` Checks if a physical connection to the server is established.
    `protected void` | `closeConnection()` Closes the WireConnection associated with this connection.
    `ServiceParameterBuffer` | `createServiceParameterBuffer()` Creates an empty `ServiceParameterBuffer`.
    `ServiceRequestBuffer` | `createServiceRequestBuffer()`
    `protected void` | `finalize()`
    `void` | `forceClose()` Forces the connection to close without proper detach or cleanup.
    `int` | `getHandle()`
    `FbWireOperations` | `getWireOperations()`
    `protected XdrInputStream` | `getXdrIn()` Gets the XdrInputStream.
    `protected XdrOutputStream` | `getXdrOut()` Gets the XdrOutputStream.
    `XdrStreamAccess` | `getXdrStreamAccess()`
    `boolean` | `isAttached()` Current attachment status.
    `GenericResponse` | `readGenericResponse(WarningMessageCallback warningCallback)` Convenience method to read a Response to a GenericResponse
    `void` | `setNetworkTimeout(int milliseconds)` Sets the network timeout for this attachment.

    - ### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbService

      `addServiceListener, close, getDescribeServiceRequestBuffer, getServiceInfo, getServiceInformationProcessor, getServiceWarningCallback, internalDetach, removeServiceListener`

    - ### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment

      `addExceptionListener, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, getServerVersionInformation, isLockedByCurrentThread, removeExceptionListener, safelyDetach, setAttached, setDetached, setServerVersion, withLock`

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

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

    - ### Methods inherited from interface org.firebirdsql.gds.ng.FbService

      `addServiceListener, getServiceInfo, getServiceInfo, removeServiceListener, startServiceAction`

    - ### Methods inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment

      `authReceiveResponse`

    - ### Methods inherited from interface org.firebirdsql.gds.ng.FbAttachment

      `attach, close, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isLockedByCurrentThread, withLock`

    - ### Methods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable

      `addExceptionListener, removeExceptionListener`

- - ### Field Detail

    - #### protocolDescriptor

          protected final ProtocolDescriptor protocolDescriptor

    - #### wireOperations

          protected final FbWireOperations wireOperations

  - ### Constructor Detail

    - #### AbstractFbWireService

          protected AbstractFbWireService(WireServiceConnection connection,
                                          ProtocolDescriptor descriptor)

      Creates an AbstractFbWireDatabase instance.
      Parameters:
        `connection` - A WireConnection with an established connection to the server.
        `descriptor` - The ProtocolDescriptor that created this connection (this is used for creating further dependent objects).

  - ### Method Detail

    - #### getHandle

          public final int getHandle()

      Specified by:
        `getHandle` in interface `FbAttachment`
      Specified by:
        `getHandle` in interface `FbService`
      Returns:
        The service handle value

    - #### forceClose

          public void forceClose()
                          throws java.sql.SQLException

      Description copied from class: `AbstractFbAttachment`
      Forces the connection to close without proper detach or cleanup.

      If a given implementation does not support this, then this method should call `FbAttachment.close()`.

      Default implementation, calls `FbAttachment.close()`

      Specified by:
        `forceClose` in interface `FbAttachment`
      Overrides:
        `forceClose` in class `AbstractFbAttachment<WireServiceConnection>`
      Throws:
        `java.sql.SQLException` - For problems closing the connection.

    - #### createServiceParameterBuffer

          public final ServiceParameterBuffer createServiceParameterBuffer()

      Description copied from interface: `FbService`
      Creates an empty `ServiceParameterBuffer`.

      Attach expects a service parameter buffer to have the version as the first item. This needs to be added explicitly.

      Specified by:
        `createServiceParameterBuffer` in interface `FbService`
      Returns:
        Service

    - #### createServiceRequestBuffer

          public final ServiceRequestBuffer createServiceRequestBuffer()

      Specified by:
        `createServiceRequestBuffer` in interface `FbService`
      Returns:
        An empty service request buffer

    - #### isAttached

          public final boolean isAttached()

      Description copied from interface: `FbAttachment`
      Current attachment status.
      Specified by:
        `isAttached` in interface `FbAttachment`
      Overrides:
        `isAttached` in class `AbstractFbAttachment<WireServiceConnection>`
      Returns:
        `true` if connected to the server and attached to a database or service, `false` otherwise.

    - #### checkConnected

          protected final void checkConnected()
                                       throws java.sql.SQLException

      Checks if a physical connection to the server is established.
      Specified by:
        `checkConnected` in class `AbstractFbAttachment<WireServiceConnection>`
      Throws:
        `java.sql.SQLException` - If not connected.

    - #### checkAttached

          protected final void checkAttached()
                                      throws java.sql.SQLException

      Checks if a physical connection to the server is established and if the connection is attached to a database.

      This method calls `checkConnected()`, so it is not necessary to call both.

      Throws:
        `java.sql.SQLException` - If the database not connected or attached.

    - #### setNetworkTimeout

          public void setNetworkTimeout(int milliseconds)
                                 throws java.sql.SQLException

      Description copied from interface: `FbAttachment`
      Sets the network timeout for this attachment.
      Specified by:
        `setNetworkTimeout` in interface `FbAttachment`
      Parameters:
        `milliseconds` - Timeout in milliseconds; 0 means no timeout. If the attachment doesn't support milliseconds, it should round up to the nearest second.
      Throws:
        `java.sql.SQLException` - If this attachment is closed, the value of `milliseconds` is smaller than 0, or if setting the timeout fails.
        `java.sql.SQLFeatureNotSupportedException` - If this attachment doesn't support (changing) the network timeout.

    - #### getXdrIn

          protected final XdrInputStream getXdrIn()
                                           throws java.sql.SQLException

      Gets the XdrInputStream.
      Returns:
        Instance of XdrInputStream
      Throws:
        `java.sql.SQLException` - If no connection is opened or when exceptions occur retrieving the InputStream

    - #### getXdrOut

          protected final XdrOutputStream getXdrOut()
                                             throws java.sql.SQLException

      Gets the XdrOutputStream.
      Returns:
        Instance of XdrOutputStream
      Throws:
        `java.sql.SQLException` - If no connection is opened or when exceptions occur retrieving the OutputStream

    - #### readGenericResponse

          public final GenericResponse readGenericResponse(WarningMessageCallback warningCallback)
                                                    throws java.sql.SQLException,
                                                           java.io.IOException

      Description copied from interface: `FbWireAttachment`
      Convenience method to read a Response to a GenericResponse
      Specified by:
        `readGenericResponse` in interface `FbWireAttachment`
      Parameters:
        `warningCallback` - Callback object for warnings, `null` for default callback
      Returns:
        GenericResponse
      Throws:
        `java.sql.SQLException` - For errors returned from the server, or when attempting to read.
        `java.io.IOException` - For errors reading the response from the connection.

    - #### getXdrStreamAccess

          public final XdrStreamAccess getXdrStreamAccess()

      Specified by:
        `getXdrStreamAccess` in interface `FbWireAttachment`
      Returns:
        Instance of `XdrStreamAccess` for this attachment.

    - #### getWireOperations

          public final FbWireOperations getWireOperations()

      Specified by:
        `getWireOperations` in interface `FbWireAttachment`
      Returns:
        Instance of `FbWireOperations` for this attachment.

    - #### closeConnection

          protected final void closeConnection()
                                        throws java.io.IOException

      Closes the WireConnection associated with this connection.
      Throws:
        `java.io.IOException` - For errors closing the connection.

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`

Copyright © 2001-2025 Jaybird (Firebird JDBC) team. All rights reserved.