Class JPPFDatasourceFactory

java.lang.Object
org.jppf.persistence.JPPFDatasourceFactory

public final class JPPFDatasourceFactory extends Object
This class represents a registry and factory for data sources defined via JPPF configuration properties.
Author:
Laurent Cohen
  • Method Details

    • getInstance

      public static JPPFDatasourceFactory getInstance()
      Get a data source factory. This method always returns the same instance.
      Returns:
      a JPPFDatasourceFactory instance.
    • getDataSource

      public DataSource getDataSource(String name)
      Get the data source with the specified name.
      Parameters:
      name - the name assigned to the data source.
      Returns:
      a DataSource instance, or null if no such data source could be retrieved.
    • getDataSourceNames

      public List<String> getDataSourceNames()
      Get the names of all currently defined data sources.
      Returns:
      a List of datasource names.
    • createDataSource

      public DataSource createDataSource(String name, Properties props)
      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 DataSource instance.
    • createDataSources

      public Map<String,DataSource> createDataSources(Properties props)
      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 Map whose keys are the names of the created data sources and whose values are the corresponding DataSource objects.
    • removeDataSource

      public boolean removeDataSource(String name)
      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:
      true if the removal was succcessful, false if 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

      public void configure(TypedProperties config, JPPFDatasourceFactory.Scope scope)
      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

      public void configure(Map<String,TypedProperties> definitionsMap)
      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 specified JPPFSystemInformation to 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 Map whose keys are the names of the created datasources and whose values are the corresponding DataSource objects.
    • 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.