Package org.synchronoss.cpo.core
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>
- Direct Known Subclasses:
AbstractJdbcDataSourceInfo,ClusterDataSourceInfo
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
ConstructorsConstructorDescriptionAbstractDataSourceInfo(String dataSourceName, int fetchSize, int batchSize) Creates an instance with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionintGets 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 incpoConfig.xml.intGets the number of rows the driver should fetch per round-trip when reading result sets from this datasource.
-
Constructor Details
-
AbstractDataSourceInfo
Creates an instance with the given configuration. The underlying datasource object itself is not created untilgetDataSource()is first called.- Parameters:
dataSourceName- the configured name of this datasourcefetchSize- the number of rows to fetch per round-tripbatchSize- the number of statements to accumulate before executing a batch
-
-
Method Details
-
getDataSourceName
Gets the configured name of this datasource, as declared incpoConfig.xml.- Specified by:
getDataSourceNamein interfaceDataSourceInfo<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:
getFetchSizein interfaceDataSourceInfo<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:
getBatchSizein interfaceDataSourceInfo<T>- Returns:
- the batchSize for this datasource
-
getDataSource
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:
getDataSourcein interfaceDataSourceInfo<T>- Returns:
- the datasource
- Throws:
CpoException- if the datasource cannot be found or created
-