CayenneRuntimeBuilder (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.runtime, class: CayenneRuntimeBuilder

# Class CayenneRuntimeBuilder

java.lang.Object
org.apache.cayenne.runtime.CayenneRuntimeBuilder

public class CayenneRuntimeBuilder extends Object
A convenience class to assemble custom `CayenneRuntime`. It allows to easily configure custom modules, multiple config locations, or quickly create a global `DataSource`.

Since:
  5.0 renamed from ServerRuntimeBuilder and moved to `org.apache.cayenne.runtime` package

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `CayenneRuntimeBuilder(String name)`
  Creates a builder with a fixed name of the DataDomain of the resulting CayenneRuntime.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CayenneRuntimeBuilder`
  `addConfig(String configurationLocation)`
  `CayenneRuntimeBuilder`
  `addConfigs(String... configurationLocations)`
  `CayenneRuntimeBuilder`
  `addConfigs(Collection<String> configurationLocations)`
  `CayenneRuntimeBuilder`
  `addModule(Module module)`
  `CayenneRuntimeBuilder`
  `addModules(Collection<Module> modules)`
  `CayenneRuntime`
  `build()`
  `CayenneRuntimeBuilder`
  `dataSource(DataSource dataSource)`
  Sets a DataSource that will override any DataSources found in the mapping.
  `CayenneRuntimeBuilder`
  `disableModulesAutoLoading()`
  Disables DI module auto-loading.
  `CayenneRuntimeBuilder`
  `jdbcDriver(String driver)`
  Sets a driver Java class for the default DataSource.
  `CayenneRuntimeBuilder`
  `maxConnections(int maxConnections)`
  `CayenneRuntimeBuilder`
  `maxQueueWaitTime(long maxQueueWaitTime)`
  `CayenneRuntimeBuilder`
  `minConnections(int minConnections)`
  `CayenneRuntimeBuilder`
  `password(String password)`
  Sets a password for the default DataSource.
  `CayenneRuntimeBuilder`
  `url(String url)`
  Sets a database URL for the default DataSource.
  `CayenneRuntimeBuilder`
  `user(String user)`
  Sets a user name for the default DataSource.
  `CayenneRuntimeBuilder`
  `validationQuery(String validationQuery)`
  Sets a validation query for the default DataSource.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CayenneRuntimeBuilder

    protected CayenneRuntimeBuilder(String name)
    Creates a builder with a fixed name of the DataDomain of the resulting CayenneRuntime. Specifying explicit name is often needed for consistency in runtimes merged from multiple configs, each having its own name.

- ## Method Details

  - ### disableModulesAutoLoading

    public CayenneRuntimeBuilder disableModulesAutoLoading()
    Disables DI module auto-loading. By default, auto-loading is enabled based on `ModuleLoader` service provider interface. If you decide to disable auto-loading, make sure you provide all the modules that you need.
    Returns:
      this builder instance.

  - ### dataSource

    public CayenneRuntimeBuilder dataSource(DataSource dataSource)
    Sets a DataSource that will override any DataSources found in the mapping. If the mapping contains no DataNodes, and the DataSource is set with this method, the builder would create a single default DataNode.
    See Also:
      - `DataSourceBuilder`

  - ### url

    public CayenneRuntimeBuilder url(String url)
    Sets a database URL for the default DataSource.

  - ### jdbcDriver

    public CayenneRuntimeBuilder jdbcDriver(String driver)
    Sets a driver Java class for the default DataSource.

  - ### validationQuery

    public CayenneRuntimeBuilder validationQuery(String validationQuery)
    Sets a validation query for the default DataSource.
    Parameters:
      `validationQuery` - a SQL string that returns some result. It will be used to validate connections in the pool.

  - ### maxQueueWaitTime

    public CayenneRuntimeBuilder maxQueueWaitTime(long maxQueueWaitTime)

  - ### user

    public CayenneRuntimeBuilder user(String user)
    Sets a user name for the default DataSource.

  - ### password

    public CayenneRuntimeBuilder password(String password)
    Sets a password for the default DataSource.

  - ### minConnections

    public CayenneRuntimeBuilder minConnections(int minConnections)

  - ### maxConnections

    public CayenneRuntimeBuilder maxConnections(int maxConnections)

  - ### addConfig

    public CayenneRuntimeBuilder addConfig(String configurationLocation)

  - ### addConfigs

    public CayenneRuntimeBuilder addConfigs(String... configurationLocations)

  - ### addConfigs

    public CayenneRuntimeBuilder addConfigs(Collection<String> configurationLocations)

  - ### addModule

    public CayenneRuntimeBuilder addModule(Module module)

  - ### addModules

    public CayenneRuntimeBuilder addModules(Collection<Module> modules)

  - ### build

    public CayenneRuntime build()