Package org.firebirdsql.gds.ng

## Class AbstractConnection<T extends IAttachProperties<T>,​C extends FbAttachment>

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractConnection<T,​C>

- Type Parameters:
    `T` - Type of attach properties
    `C` - Type of connection handle
  Direct Known Subclasses:
    `JnaConnection`, `WireConnection`

      public abstract class AbstractConnection<T extends IAttachProperties<T>,​C extends FbAttachment>
      extends java.lang.Object

  Abstract class with common logic for connections.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected T` | `attachProperties` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `AbstractConnection​(T attachProperties, IEncodingFactory encodingFactory)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `DbCryptCallback` | `createDbCryptCallback()` | Creates an instance of `DbCryptCallback` for this connection.
    `T` | `getAttachProperties()` |
    `Encoding` | `getEncoding()` |
    `EncodingDefinition` | `getEncodingDefinition()` |
    `IEncodingFactory` | `getEncodingFactory()` |
    `abstract C` | `identify()` | Performs the connection identification phase of the protocol and returns the connection handle implementation for the agreed protocol.
    `protected boolean` | `isLockedByCurrentThread()` |
    `protected LockCloseable` | `withLock()` |

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

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

- - ### Field Detail

    - #### attachProperties

          protected final T extends IAttachProperties<T> attachProperties

  - ### Constructor Detail

    - #### AbstractConnection

          protected AbstractConnection​(T attachProperties,
                                       IEncodingFactory encodingFactory)
                                throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

  - ### Method Detail

    - #### withLock

          protected final LockCloseable withLock()

      See Also:
        `FbAttachment.withLock()`

    - #### isLockedByCurrentThread

          protected final boolean isLockedByCurrentThread()

      See Also:
        `FbAttachment.isLockedByCurrentThread()`

    - #### identify

          public abstract C identify()
                              throws java.sql.SQLException

      Performs the connection identification phase of the protocol and returns the connection handle implementation for the agreed protocol.
      Returns:
        Connection handle (ie `FbDatabase` or `FbService`)
      Throws:
        `java.sql.SQLException` - For exceptions connecting

    - #### getAttachProperties

          public final T getAttachProperties()

      Returns:
        An immutable copy of the current attach properties.

    - #### getEncodingDefinition

          public final EncodingDefinition getEncodingDefinition()

    - #### getEncoding

          public final Encoding getEncoding()

    - #### getEncodingFactory

          public final IEncodingFactory getEncodingFactory()

    - #### createDbCryptCallback

          @InternalApi
          public final DbCryptCallback createDbCryptCallback()
                                                      throws java.sql.SQLException

      Creates an instance of `DbCryptCallback` for this connection.
      Returns:
        Database encryption callback.
      Throws:
        `java.sql.SQLException` - For errors initializing the callback