Package net.officefloor.jdbc
Class AbstractJdbcManagedObjectSource
- 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.AbstractJdbcManagedObjectSource
-
- All Implemented Interfaces:
ManagedObjectSource<None,None>
- Direct Known Subclasses:
DataSourceManagedObjectSource
,ReadOnlyConnectionManagedObjectSource
public abstract class AbstractJdbcManagedObjectSource extends AbstractManagedObjectSource<None,None>
AbstractManagedObjectSource
forConnection
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractJdbcManagedObjectSource.ConnectionConnectivity
ConvenientAbstractJdbcManagedObjectSource.Connectivity
implementation to wrap aConnection
.static interface
AbstractJdbcManagedObjectSource.Connectivity
Connectivity.static interface
AbstractJdbcManagedObjectSource.ConnectivityFactory
Factory forAbstractJdbcManagedObjectSource.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 AbstractJdbcManagedObjectSource()
-
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 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(AbstractJdbcManagedObjectSource.ConnectivityFactory connectivityFactory)
SpecifiesAbstractJdbcManagedObjectSource.ConnectivityFactory
for validating connectivity on startup.protected abstract void
setupActive(ManagedObjectSourceContext<None> mosContext)
Sets up theManagedObjectSource
for active use.protected abstract void
setupMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)
Sets up the meta-data.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
.
-
setupMetaData
protected abstract void setupMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws java.lang.Exception
Sets up the meta-data.- Parameters:
context
-AbstractAsyncManagedObjectSource.MetaDataContext
.- Throws:
java.lang.Exception
- If fails to loader further meta-data.
-
setupActive
protected abstract void setupActive(ManagedObjectSourceContext<None> mosContext) throws java.lang.Exception
Sets up theManagedObjectSource
for active use.- Parameters:
mosContext
-ManagedObjectSourceContext
.- Throws:
java.lang.Exception
- If fails to setup.
-
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(AbstractJdbcManagedObjectSource.ConnectivityFactory connectivityFactory)
SpecifiesAbstractJdbcManagedObjectSource.ConnectivityFactory
for validating connectivity on startup.- Parameters:
connectivityFactory
-AbstractJdbcManagedObjectSource.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.
-
-