Package org.jppf.persistence
Class JPPFDatasourceFactory
java.lang.Object
org.jppf.persistence.JPPFDatasourceFactory
This class represents a registry and factory for data sources defined via JPPF configuration properties.
- Author:
- Laurent Cohen
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Close and remove all the data sources in this registry.voidconfigure(Map<String, TypedProperties> definitionsMap) Create and configure the datasources defined in the specified configurations.configure(Map<String, TypedProperties> definitionsMap, JPPFSystemInformation info) Create and configure the datasources defined in the specified configurations.voidconfigure(TypedProperties config, JPPFDatasourceFactory.Scope scope) Create and configure the datasources defined in the specified configuration.voidconfigure(TypedProperties config, JPPFDatasourceFactory.Scope scope, JPPFSystemInformation info) Create and configure the datasources defined in the specified configuration.createDataSource(String name, Properties props) Create a data source from the specified configuration properties.createDataSources(Properties props) Create one or more data sources from the specified configuration properties.static Map<String,TypedProperties> extractDefinitions(TypedProperties config, JPPFDatasourceFactory.Scope requestedScope) Create and configure the datasources defined in the specified configuration.getDataSource(String name) Get the data source with the specified name.Get the names of all currently defined data sources.static JPPFDatasourceFactoryGet a data source factory.booleanremoveDataSource(String name) Remove the data source with the specified name.
-
Method Details
-
getInstance
Get a data source factory. This method always returns the same instance.- Returns:
- a
JPPFDatasourceFactoryinstance.
-
getDataSource
Get the data source with the specified name.- Parameters:
name- the name assigned to the data source.- Returns:
- a DataSource instance, or
nullif no such data source could be retrieved.
-
getDataSourceNames
Get the names of all currently defined data sources.- Returns:
- a
Listof datasource names.
-
createDataSource
Create a data source from the specified configuration properties. This method assumes the property names have no prefix.- Parameters:
name- the name of the data source to create.props- the data source configuration properties.- Returns:
- a
DataSourceinstance.
-
createDataSources
Create one or more data sources from the specified configuration properties. This method assumes the property names have the same format as for static datasources configurations, that is:
jppf.datasource.<configId>.<property_name> = <property_value>.- Parameters:
props- the data sources configuration properties.- Returns:
- a
Mapwhose keys are the names of the created data sources and whose values are the correspondingDataSourceobjects.
-
removeDataSource
Remove the data source with the specified name. This method also closes the data source and releases the resources it is using.- Parameters:
name- the name assigned to the datasource.- Returns:
trueif the removal was succcessful,falseif it fails for any reason, including if no data source with the specified name exists.
-
clear
public void clear()Close and remove all the data sources in this registry. -
configure
Create and configure the datasources defined in the specified configuration.- Parameters:
config- the configuration properties that define the datasources.scope- determines which scope to create data sources for.
-
configure
public void configure(TypedProperties config, JPPFDatasourceFactory.Scope scope, JPPFSystemInformation info) Create and configure the datasources defined in the specified configuration.- Parameters:
config- the configuration properties that define the datasources.scope- determines which scope to create datasources for.info- the system information match an eventual execution policy.
-
configure
Create and configure the datasources defined in the specified configurations.- Parameters:
definitionsMap- a mapping of config ids and corresponding map of properties.
-
configure
public Map<String,DataSource> configure(Map<String, TypedProperties> definitionsMap, JPPFSystemInformation info) Create and configure the datasources defined in the specified configurations. The definitions may contain an execution policy which is then matched against the specifiedJPPFSystemInformationto determine whteher the datasource should b created.- Parameters:
definitionsMap- a mapping of config ids and corresponding map of properties.info- the system information match an eventual execution policy.- Returns:
- a
Mapwhose keys are the names of the created datasources and whose values are the correspondingDataSourceobjects.
-
extractDefinitions
public static Map<String,TypedProperties> extractDefinitions(TypedProperties config, JPPFDatasourceFactory.Scope requestedScope) Create and configure the datasources defined in the specified configuration.- Parameters:
config- the configuration properties that define the datasources.requestedScope- in a driver, determines whether the definitions are intended for the nodes (true) or for the local JVM (false).- Returns:
- a mapping of config ids to the corresponding properties.
-