Package net.officefloor.jdbc
Class AbstractConnectionManagedObjectSource
- java.lang.Object
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource<O,F>
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource<None,None>
-
- net.officefloor.jdbc.AbstractConnectionManagedObjectSource
-
- All Implemented Interfaces:
ManagedObjectSource<None,None>
- Direct Known Subclasses:
ConnectionManagedObjectSource
,DataSourceManagedObjectSource
,ReadOnlyConnectionManagedObjectSource
public abstract class AbstractConnectionManagedObjectSource extends AbstractManagedObjectSource<None,None>
AbstractManagedObjectSource
forConnection
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractConnectionManagedObjectSource.ConnectionConnectivity
ConvenientAbstractConnectionManagedObjectSource.Connectivity
implementation to wrap aConnection
.static interface
AbstractConnectionManagedObjectSource.Connectivity
Connectivity.static interface
AbstractConnectionManagedObjectSource.ConnectivityFactory
Factory forAbstractConnectionManagedObjectSource.Connectivity
.-
Nested classes/interfaces inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
AbstractAsyncManagedObjectSource.DependencyLabeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.ExecutionLabeller, AbstractAsyncManagedObjectSource.Labeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.MetaDataContext<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_DATA_SOURCE_FACTORY
Property
name to specify theDataSourceFactory
implementation.static java.lang.String
PROPERTY_DATA_SOURCE_VALIDATE_SQL
Property
name to specify the SQL to run to validate theDataSource
is configured correctly.
-
Constructor Summary
Constructors Constructor Description AbstractConnectionManagedObjectSource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
closeDataSource(javax.sql.DataSource dataSource, java.util.logging.Logger logger)
Closes theDataSource
.protected ConnectionPoolDataSourceFactory
getConnectionPoolDataSourceFactory(SourceContext context)
Allows overriding to configure a differentConnectionPoolDataSourceFactory
.protected DataSourceFactory
getDataSourceFactory(SourceContext context)
Allows overriding to configure a differentDataSourceFactory
.protected abstract void
loadFurtherMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)
Enables overriding to load further meta-data.protected void
loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)
Overridden to load meta-data.protected void
loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Overridden to load specifications.protected void
loadValidateConnectivity(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)
Loads validation of connectivity on start up.protected javax.sql.ConnectionPoolDataSource
newConnectionPoolDataSource(SourceContext context)
Creates theConnectionPoolDataSource
.protected javax.sql.DataSource
newDataSource(SourceContext context)
Creates theDataSource
.void
setConnectivity(AbstractConnectionManagedObjectSource.ConnectivityFactory connectivityFactory)
SpecifiesAbstractConnectionManagedObjectSource.ConnectivityFactory
for validating connectivity on startup.protected void
validateConnectivity(java.lang.String sql)
Validates connectivity.-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource
getManagedObject, sourceManagedObject
-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
getSpecification, init, start, stop
-
-
-
-
Field Detail
-
PROPERTY_DATA_SOURCE_FACTORY
public static final java.lang.String PROPERTY_DATA_SOURCE_FACTORY
Property
name to specify theDataSourceFactory
implementation.- See Also:
- Constant Field Values
-
PROPERTY_DATA_SOURCE_VALIDATE_SQL
public static final java.lang.String PROPERTY_DATA_SOURCE_VALIDATE_SQL
Property
name to specify the SQL to run to validate theDataSource
is configured correctly.- See Also:
- Constant Field Values
-
-
Method Detail
-
newDataSource
protected final javax.sql.DataSource newDataSource(SourceContext context) throws java.lang.Exception
Creates theDataSource
.- Parameters:
context
-SourceContext
.- Returns:
- Created
DataSource
. - Throws:
java.lang.Exception
- If fails to create theDataSource
.
-
getDataSourceFactory
protected DataSourceFactory getDataSourceFactory(SourceContext context) throws java.lang.Exception
Allows overriding to configure a differentDataSourceFactory
.- Parameters:
context
-SourceContext
.- Returns:
DataSourceFactory
.- Throws:
java.lang.Exception
- If fails to obtainDataSourceFactory
.
-
newConnectionPoolDataSource
protected final javax.sql.ConnectionPoolDataSource newConnectionPoolDataSource(SourceContext context) throws java.lang.Exception
Creates theConnectionPoolDataSource
.- Parameters:
context
-SourceContext
.- Returns:
- Created
ConnectionPoolDataSource
. - Throws:
java.lang.Exception
- If fails to create theConnectionPoolDataSource
.
-
getConnectionPoolDataSourceFactory
protected ConnectionPoolDataSourceFactory getConnectionPoolDataSourceFactory(SourceContext context) throws java.lang.Exception
Allows overriding to configure a differentConnectionPoolDataSourceFactory
.- Parameters:
context
-SourceContext
.- Returns:
ConnectionPoolDataSourceFactory
.- Throws:
java.lang.Exception
- If fails to obtainConnectionPoolDataSourceFactory
.
-
loadFurtherMetaData
protected abstract void loadFurtherMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws java.lang.Exception
Enables overriding to load further meta-data.- Parameters:
context
-AbstractAsyncManagedObjectSource.MetaDataContext
.- Throws:
java.lang.Exception
- If fails to loader further meta-data.
-
loadValidateConnectivity
protected void loadValidateConnectivity(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws java.lang.Exception
Loads validation of connectivity on start up.- Parameters:
context
-AbstractAsyncManagedObjectSource.MetaDataContext
.- Throws:
java.lang.Exception
- If fails to load validation.
-
setConnectivity
public void setConnectivity(AbstractConnectionManagedObjectSource.ConnectivityFactory connectivityFactory)
SpecifiesAbstractConnectionManagedObjectSource.ConnectivityFactory
for validating connectivity on startup.- Parameters:
connectivityFactory
-AbstractConnectionManagedObjectSource.ConnectivityFactory
.
-
validateConnectivity
protected void validateConnectivity(java.lang.String sql) throws java.lang.Exception
Validates connectivity.- Parameters:
sql
- Optional SQL to be executed against theConnection
. May benull
.- Throws:
java.lang.Exception
- If fails connectivity.
-
closeDataSource
protected void closeDataSource(javax.sql.DataSource dataSource, java.util.logging.Logger logger)
Closes theDataSource
.- Parameters:
dataSource
-DataSource
to be closed.logger
-Logger
.
-
loadSpecification
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load specifications.- Specified by:
loadSpecification
in classAbstractAsyncManagedObjectSource<None,None>
- Parameters:
context
- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws java.lang.Exception
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load meta-data.- Specified by:
loadMetaData
in classAbstractAsyncManagedObjectSource<None,None>
- Parameters:
context
- Meta-data.- Throws:
java.lang.Exception
- If fails to load the meta-data.
-
-