Package net.officefloor.jdbc.datasource
Class DefaultDataSourceFactory
- java.lang.Object
-
- net.officefloor.jdbc.datasource.DefaultDataSourceFactory
-
- All Implemented Interfaces:
ConnectionPoolDataSourceFactory
,DataSourceFactory
public class DefaultDataSourceFactory extends java.lang.Object implements DataSourceFactory, ConnectionPoolDataSourceFactory
DefaultDataSourceFactory
.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_DATA_SOURCE_CLASS_NAME
-
Constructor Summary
Constructors Constructor Description DefaultDataSourceFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.sql.ConnectionPoolDataSource
createConnectionPoolDataSource(SourceContext context)
Creates theConnectionPoolDataSource
.static javax.sql.DataSource
createDataSource(java.lang.String propertiesFileName)
Convenience method to create aDataSource
.static javax.sql.DataSource
createDataSource(java.util.Properties properties)
Convenience method to create aDataSource
.javax.sql.DataSource
createDataSource(SourceContext context)
Creates theDataSource
.static <S> void
loadProperties(S dataSource, SourceContext context)
Loads the properties onto theDataSource
.
-
-
-
Field Detail
-
PROPERTY_DATA_SOURCE_CLASS_NAME
public static final java.lang.String PROPERTY_DATA_SOURCE_CLASS_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDataSource
public static javax.sql.DataSource createDataSource(java.lang.String propertiesFileName) throws java.lang.Exception
Convenience method to create a
DataSource
.This is typically used in testing.
- Parameters:
propertiesFileName
- Name of theProperties
file on the class path.- Returns:
DataSource
.- Throws:
java.lang.Exception
- If fails to load theDataSource
.
-
createDataSource
public static javax.sql.DataSource createDataSource(java.util.Properties properties) throws java.lang.Exception
Convenience method to create a
DataSource
.This is typically used in testing.
- Parameters:
properties
-Properties
to configure theDataSource
.- Returns:
DataSource
.- Throws:
java.lang.Exception
- If fails to load theDataSource
.
-
loadProperties
public static <S> void loadProperties(S dataSource, SourceContext context) throws java.lang.Exception
Loads the properties onto theDataSource
.- Type Parameters:
S
-DataSource
type.- Parameters:
dataSource
-DataSource
.context
-SourceContext
.- Throws:
java.lang.Exception
- If fails to load properties.
-
createDataSource
public javax.sql.DataSource createDataSource(SourceContext context) throws java.lang.Exception
Description copied from interface:DataSourceFactory
Creates theDataSource
.- Specified by:
createDataSource
in interfaceDataSourceFactory
- Parameters:
context
-SourceContext
to configure theDataSource
.- Returns:
DataSource
.- Throws:
java.lang.Exception
- If fails to create theDataSource
.
-
createConnectionPoolDataSource
public javax.sql.ConnectionPoolDataSource createConnectionPoolDataSource(SourceContext context) throws java.lang.Exception
Description copied from interface:ConnectionPoolDataSourceFactory
Creates theConnectionPoolDataSource
.- Specified by:
createConnectionPoolDataSource
in interfaceConnectionPoolDataSourceFactory
- Parameters:
context
-SourceContext
to configure theConnectionPoolDataSource
.- Returns:
ConnectionPoolDataSource
.- Throws:
java.lang.Exception
- If fails to create theConnectionPoolDataSource
.
-
-