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>
AbstractManagedObjectSourceforConnection.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractJdbcManagedObjectSource.ConnectionConnectivityConvenientAbstractJdbcManagedObjectSource.Connectivityimplementation to wrap aConnection.static interfaceAbstractJdbcManagedObjectSource.ConnectivityConnectivity.static interfaceAbstractJdbcManagedObjectSource.ConnectivityFactoryFactory 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.StringPROPERTY_DATA_SOURCE_FACTORYPropertyname to specify theDataSourceFactoryimplementation.static java.lang.StringPROPERTY_DATA_SOURCE_VALIDATE_SQLPropertyname to specify the SQL to run to validate theDataSourceis configured correctly.
-
Constructor Summary
Constructors Constructor Description AbstractJdbcManagedObjectSource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcloseDataSource(javax.sql.DataSource dataSource, java.util.logging.Logger logger)Closes theDataSource.protected ConnectionPoolDataSourceFactorygetConnectionPoolDataSourceFactory(SourceContext context)Allows overriding to configure a differentConnectionPoolDataSourceFactory.protected DataSourceFactorygetDataSourceFactory(SourceContext context)Allows overriding to configure a differentDataSourceFactory.protected voidloadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)Overridden to load meta-data.protected voidloadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)Overridden to load specifications.protected voidloadValidateConnectivity(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)Loads validation of connectivity on start up.protected javax.sql.ConnectionPoolDataSourcenewConnectionPoolDataSource(SourceContext context)Creates theConnectionPoolDataSource.protected javax.sql.DataSourcenewDataSource(SourceContext context)Creates theDataSource.voidsetConnectivity(AbstractJdbcManagedObjectSource.ConnectivityFactory connectivityFactory)SpecifiesAbstractJdbcManagedObjectSource.ConnectivityFactoryfor validating connectivity on startup.protected abstract voidsetupActive(ManagedObjectSourceContext<None> mosContext)Sets up theManagedObjectSourcefor active use.protected abstract voidsetupMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context)Sets up the meta-data.protected voidvalidateConnectivity(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
Propertyname to specify theDataSourceFactoryimplementation.- See Also:
- Constant Field Values
-
PROPERTY_DATA_SOURCE_VALIDATE_SQL
public static final java.lang.String PROPERTY_DATA_SOURCE_VALIDATE_SQL
Propertyname to specify the SQL to run to validate theDataSourceis 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 theManagedObjectSourcefor 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.ConnectivityFactoryfor validating connectivity on startup.- Parameters:
connectivityFactory-AbstractJdbcManagedObjectSource.ConnectivityFactory.
-
validateConnectivity
protected void validateConnectivity(java.lang.String sql) throws java.lang.ExceptionValidates 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-DataSourceto be closed.logger-Logger.
-
loadSpecification
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from class:AbstractAsyncManagedObjectSourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractAsyncManagedObjectSource<None,None>- Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None,None> context) throws java.lang.Exception
Description copied from class:AbstractAsyncManagedObjectSourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractAsyncManagedObjectSource<None,None>- Parameters:
context- Meta-data.- Throws:
java.lang.Exception- If fails to load the meta-data.
-
-