org.springframework.jca.cci.connection

## Class SingleConnectionFactory

- java.lang.Object
- - org.springframework.jca.cci.connection.DelegatingConnectionFactory
  - - org.springframework.jca.cci.connection.SingleConnectionFactory

- All Implemented Interfaces:
    Serializable, Referenceable, ConnectionFactory, DisposableBean, InitializingBean

  Deprecated.
  as of 5.3, in favor of specific data access APIs (or native CCI usage if there is no alternative)

      @Deprecated
      public class SingleConnectionFactory
      extends DelegatingConnectionFactory
      implements DisposableBean

  A CCI ConnectionFactory adapter that returns the same Connection on all `getConnection` calls, and ignores calls to `Connection.close()`.

  Useful for testing and standalone environments, to keep using the same Connection for multiple CciTemplate calls, without having a pooling ConnectionFactory, also spanning any number of transactions.

  You can either pass in a CCI Connection directly, or let this factory lazily create a Connection via a given target ConnectionFactory.

  Since:
    1.2
  Author:
    Juergen Hoeller
  See Also:
    `getConnection()`, `Connection.close()`, `CciTemplate`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger` Deprecated.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SingleConnectionFactory()` Deprecated. Create a new SingleConnectionFactory for bean-style usage.
    `SingleConnectionFactory(Connection target)` Deprecated. Create a new SingleConnectionFactory that always returns the given Connection.
    `SingleConnectionFactory(ConnectionFactory targetConnectionFactory)` Deprecated. Create a new SingleConnectionFactory that always returns a single Connection which it will lazily create via the given target ConnectionFactory.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Deprecated. Make sure a Connection or ConnectionFactory has been set.
    `protected void` | `closeConnection(Connection con)` Deprecated. Close the given Connection.
    `void` | `destroy()` Deprecated. Close the underlying Connection.
    `protected Connection` | `doCreateConnection()` Deprecated. Create a CCI Connection via this template's ConnectionFactory.
    `protected Connection` | `getCloseSuppressingConnectionProxy(Connection target)` Deprecated. Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls.
    `Connection` | `getConnection()` Deprecated.
    `Connection` | `getConnection(ConnectionSpec connectionSpec)` Deprecated.
    `void` | `initConnection()` Deprecated. Initialize the single underlying Connection.
    `protected void` | `prepareConnection(Connection con)` Deprecated. Prepare the given Connection before it is exposed.
    `void` | `resetConnection()` Deprecated. Reset the underlying shared Connection, to be reinitialized on next access.

    - ### Methods inherited from class org.springframework.jca.cci.connection.DelegatingConnectionFactory

      `getMetaData, getRecordFactory, getReference, getTargetConnectionFactory, obtainTargetConnectionFactory, setReference, setTargetConnectionFactory`

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

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

- - ### Field Detail

    - #### logger

          protected final Log logger

      Deprecated.

  - ### Constructor Detail

    - #### SingleConnectionFactory

          public SingleConnectionFactory()

      Deprecated.
      Create a new SingleConnectionFactory for bean-style usage.
      See Also:
        `DelegatingConnectionFactory.setTargetConnectionFactory(javax.resource.cci.ConnectionFactory)`

    - #### SingleConnectionFactory

          public SingleConnectionFactory(Connection target)

      Deprecated.
      Create a new SingleConnectionFactory that always returns the given Connection.
      Parameters:
        `target` - the single Connection

    - #### SingleConnectionFactory

          public SingleConnectionFactory(ConnectionFactory targetConnectionFactory)

      Deprecated.
      Create a new SingleConnectionFactory that always returns a single Connection which it will lazily create via the given target ConnectionFactory.
      Parameters:
        `targetConnectionFactory` - the target ConnectionFactory

  - ### Method Detail

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Deprecated.
      Make sure a Connection or ConnectionFactory has been set.
      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Overrides:
        `afterPropertiesSet` in class `DelegatingConnectionFactory`

    - #### getConnection

          public Connection getConnection()
                                   throws ResourceException

      Deprecated.
      Specified by:
        `getConnection` in interface `ConnectionFactory`
      Overrides:
        `getConnection` in class `DelegatingConnectionFactory`
      Throws:
        `ResourceException`

    - #### getConnection

          public Connection getConnection(ConnectionSpec connectionSpec)
                                   throws ResourceException

      Deprecated.
      Specified by:
        `getConnection` in interface `ConnectionFactory`
      Overrides:
        `getConnection` in class `DelegatingConnectionFactory`
      Throws:
        `ResourceException`

    - #### destroy

          public void destroy()

      Deprecated.
      Close the underlying Connection. The provider of this ConnectionFactory needs to care for proper shutdown.

      As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.

      Specified by:
        `destroy` in interface `DisposableBean`

    - #### initConnection

          public void initConnection()
                              throws ResourceException

      Deprecated.
      Initialize the single underlying Connection.

      Closes and reinitializes the Connection if an underlying Connection is present already.

      Throws:
        `ResourceException` - if thrown by CCI API methods

    - #### resetConnection

          public void resetConnection()

      Deprecated.
      Reset the underlying shared Connection, to be reinitialized on next access.

    - #### doCreateConnection

          protected Connection doCreateConnection()
                                           throws ResourceException

      Deprecated.
      Create a CCI Connection via this template's ConnectionFactory.
      Returns:
        the new CCI Connection
      Throws:
        `ResourceException` - if thrown by CCI API methods

    - #### prepareConnection

          protected void prepareConnection(Connection con)
                                    throws ResourceException

      Deprecated.
      Prepare the given Connection before it is exposed.

      The default implementation is empty. Can be overridden in subclasses.

      Parameters:
        `con` - the Connection to prepare
      Throws:
        `ResourceException`

    - #### closeConnection

          protected void closeConnection(Connection con)

      Deprecated.
      Close the given Connection.
      Parameters:
        `con` - the Connection to close

    - #### getCloseSuppressingConnectionProxy

          protected Connection getCloseSuppressingConnectionProxy(Connection target)

      Deprecated.
      Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls. This is useful for allowing application code to handle a special framework Connection just like an ordinary Connection from a CCI ConnectionFactory.
      Parameters:
        `target` - the original Connection to wrap
      Returns:
        the wrapped Connection