Class DatabaseFactory
- java.lang.Object
-
- io.ebean.DatabaseFactory
-
public class DatabaseFactory extends Object
Creates Database instances.This uses either DatabaseConfig or properties in the application.properties file to configure and create a Database instance.
The Database instance can either be registered with the DB singleton or not. The DB singleton effectively holds a map of Database by a name. If the Database is registered with the DB singleton you can retrieve it later via
DB.byName(String)
.One Database can be nominated as the 'default/primary' Database. Many methods on the DB singleton such as
DB.find(Class)
are just a convenient way of using the 'default/primary' Database.
-
-
Constructor Summary
Constructors Constructor Description DatabaseFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Database
create(DatabaseConfig config)
Create using the DatabaseConfig object to configure the database.static Database
create(String name)
Create using properties to configure the database.static Database
createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader)
Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader.static void
initialiseContainer(ContainerConfig containerConfig)
Initialise the container with clustering configuration.static void
shutdown()
Shutdown gracefully all Database instances cleaning up any resources as required.
-
-
-
Constructor Detail
-
DatabaseFactory
public DatabaseFactory()
-
-
Method Detail
-
initialiseContainer
public static void initialiseContainer(ContainerConfig containerConfig)
Initialise the container with clustering configuration.Call this prior to creating any Database instances or alternatively set the ContainerConfig on the DatabaseConfig when creating the first Database instance.
-
create
public static Database create(String name)
Create using properties to configure the database.
-
create
public static Database create(DatabaseConfig config)
Create using the DatabaseConfig object to configure the database.
-
createWithContextClassLoader
public static Database createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader)
Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader.
-
shutdown
public static void shutdown()
Shutdown gracefully all Database instances cleaning up any resources as required.This is typically invoked via JVM shutdown hook and not explicitly called.
-
-