Class AbstractDataSourceInfo<T>

java.lang.Object
org.synchronoss.cpo.core.AbstractDataSourceInfo<T>
Type Parameters:
T - the type of the underlying datasource object
All Implemented Interfaces:
DataSourceInfo<T>

public abstract class AbstractDataSourceInfo<T> extends Object implements DataSourceInfo<T>
Base DataSourceInfo implementation that holds the common name/fetchSize/batchSize configuration and lazily creates the underlying datasource object on first access, guarding creation with a lock so concurrent callers cannot race to create it twice.
Author:
dberry
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractDataSourceInfo(String dataSourceName, int fetchSize, int batchSize)
    Creates an instance with the given configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the number of statements to accumulate before executing a batch against this datasource.
    Gets the underlying datasource object, creating it on first access.
    Gets the configured name of this datasource, as declared in cpoConfig.xml.
    int
    Gets the number of rows the driver should fetch per round-trip when reading result sets from this datasource.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractDataSourceInfo

      public AbstractDataSourceInfo(String dataSourceName, int fetchSize, int batchSize)
      Creates an instance with the given configuration. The underlying datasource object itself is not created until getDataSource() is first called.
      Parameters:
      dataSourceName - the configured name of this datasource
      fetchSize - the number of rows to fetch per round-trip
      batchSize - the number of statements to accumulate before executing a batch
  • Method Details

    • getDataSourceName

      public String getDataSourceName()
      Gets the configured name of this datasource, as declared in cpoConfig.xml.
      Specified by:
      getDataSourceName in interface DataSourceInfo<T>
      Returns:
      the dataSourceName
    • getFetchSize

      public int getFetchSize()
      Gets the number of rows the driver should fetch per round-trip when reading result sets from this datasource.
      Specified by:
      getFetchSize in interface DataSourceInfo<T>
      Returns:
      the fetchSize for this datasource
    • getBatchSize

      public int getBatchSize()
      Gets the number of statements to accumulate before executing a batch against this datasource.
      Specified by:
      getBatchSize in interface DataSourceInfo<T>
      Returns:
      the batchSize for this datasource
    • getDataSource

      public T getDataSource() throws CpoException
      Gets the underlying datasource object, creating it on first access.

      The datasource object is created lazily on first call via createDataSource() and cached for subsequent calls; creation is synchronized to be thread-safe.

      Specified by:
      getDataSource in interface DataSourceInfo<T>
      Returns:
      the datasource
      Throws:
      CpoException - if the datasource cannot be found or created