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>
Abstract
ManagedObjectSource for Connection.- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConvenientAbstractJdbcManagedObjectSource.Connectivityimplementation to wrap aConnection.static interfaceConnectivity.static interfaceFactory forAbstractJdbcManagedObjectSource.Connectivity.Nested classes/interfaces inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
AbstractAsyncManagedObjectSource.DependencyLabeller<K extends Enum<K>>, AbstractAsyncManagedObjectSource.ExecutionLabeller, AbstractAsyncManagedObjectSource.Labeller<K extends Enum<K>>, AbstractAsyncManagedObjectSource.MetaDataContext<O extends Enum<O>,F extends Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPropertyname to specify theDataSourceFactoryimplementation.static final StringPropertyname to specify the SQL to run to validate theDataSourceis configured correctly. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcloseDataSource(DataSource dataSource, Logger logger) Closes theDataSource.protected ConnectionPoolDataSourceFactoryAllows overriding to configure a differentConnectionPoolDataSourceFactory.protected DataSourceFactorygetDataSourceFactory(SourceContext context) Allows overriding to configure a differentDataSourceFactory.protected voidOverridden to load meta-data.protected voidOverridden to load specifications.protected voidLoads validation of connectivity on start up.protected final ConnectionPoolDataSourcenewConnectionPoolDataSource(SourceContext context) Creates theConnectionPoolDataSource.protected final 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 voidSets up the meta-data.protected voidValidates connectivity.Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource
getManagedObject, sourceManagedObjectMethods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
getSpecification, init, start, stop
-
Field Details
-
PROPERTY_DATA_SOURCE_FACTORY
Propertyname to specify theDataSourceFactoryimplementation.- See Also:
-
PROPERTY_DATA_SOURCE_VALIDATE_SQL
Propertyname to specify the SQL to run to validate theDataSourceis configured correctly.- See Also:
-
-
Constructor Details
-
AbstractJdbcManagedObjectSource
public AbstractJdbcManagedObjectSource()
-
-
Method Details
-
newDataSource
Creates theDataSource.- Parameters:
context-SourceContext.- Returns:
- Created
DataSource. - Throws:
Exception- If fails to create theDataSource.
-
getDataSourceFactory
Allows overriding to configure a differentDataSourceFactory.- Parameters:
context-SourceContext.- Returns:
DataSourceFactory.- Throws:
Exception- If fails to obtainDataSourceFactory.
-
newConnectionPoolDataSource
protected final ConnectionPoolDataSource newConnectionPoolDataSource(SourceContext context) throws Exception Creates theConnectionPoolDataSource.- Parameters:
context-SourceContext.- Returns:
- Created
ConnectionPoolDataSource. - Throws:
Exception- If fails to create theConnectionPoolDataSource.
-
getConnectionPoolDataSourceFactory
protected ConnectionPoolDataSourceFactory getConnectionPoolDataSourceFactory(SourceContext context) throws Exception Allows overriding to configure a differentConnectionPoolDataSourceFactory.- Parameters:
context-SourceContext.- Returns:
ConnectionPoolDataSourceFactory.- Throws:
Exception- If fails to obtainConnectionPoolDataSourceFactory.
-
setupMetaData
protected abstract void setupMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None, None> context) throws ExceptionSets up the meta-data.- Parameters:
context-AbstractAsyncManagedObjectSource.MetaDataContext.- Throws:
Exception- If fails to loader further meta-data.
-
setupActive
Sets up theManagedObjectSourcefor active use.- Parameters:
mosContext-ManagedObjectSourceContext.- Throws:
Exception- If fails to setup.
-
loadValidateConnectivity
protected void loadValidateConnectivity(AbstractAsyncManagedObjectSource.MetaDataContext<None, None> context) throws ExceptionLoads validation of connectivity on start up.- Parameters:
context-AbstractAsyncManagedObjectSource.MetaDataContext.- Throws:
Exception- If fails to load validation.
-
setConnectivity
public void setConnectivity(AbstractJdbcManagedObjectSource.ConnectivityFactory connectivityFactory) SpecifiesAbstractJdbcManagedObjectSource.ConnectivityFactoryfor validating connectivity on startup.- Parameters:
connectivityFactory-AbstractJdbcManagedObjectSource.ConnectivityFactory.
-
validateConnectivity
Validates connectivity.- Parameters:
sql- Optional SQL to be executed against theConnection. May benull.- Throws:
Exception- If fails connectivity.
-
closeDataSource
Closes theDataSource.- Parameters:
dataSource-DataSourceto be closed.logger-Logger.
-
loadSpecification
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 ExceptionDescription copied from class:AbstractAsyncManagedObjectSourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractAsyncManagedObjectSource<None,None> - Parameters:
context- Meta-data.- Throws:
Exception- If fails to load the meta-data.
-