001package io.ebean; 002 003import io.ebean.config.ContainerConfig; 004import io.ebean.config.ServerConfig; 005 006/** 007 * Deprecated - please migrate to DatabaseFactory. 008 * <p> 009 * Creates EbeanServer instances. 010 * <p> 011 * This uses either a ServerConfig or properties in the ebean.properties file to 012 * configure and create a EbeanServer instance. 013 * </p> 014 * <p> 015 * The EbeanServer instance can either be registered with the Ebean singleton or 016 * not. The Ebean singleton effectively holds a map of EbeanServers by a name. 017 * If the EbeanServer is registered with the Ebean singleton you can retrieve it 018 * later via {@link Ebean#getServer(String)}. 019 * </p> 020 * <p> 021 * One EbeanServer can be nominated as the 'default/primary' EbeanServer. Many 022 * methods on the Ebean singleton such as {@link Ebean#find(Class)} are just a 023 * convenient way of using the 'default/primary' EbeanServer. 024 * </p> 025 */ 026@Deprecated 027public class EbeanServerFactory { 028 029 /** 030 * Initialise the container with clustering configuration. 031 * <p> 032 * Call this prior to creating any EbeanServer instances or alternatively set the 033 * ContainerConfig on the ServerConfig when creating the first EbeanServer instance. 034 */ 035 public static void initialiseContainer(ContainerConfig containerConfig) { 036 DatabaseFactory.initialiseContainer(containerConfig); 037 } 038 039 /** 040 * Create using ebean.properties to configure the database. 041 */ 042 public static EbeanServer create(String name) { 043 return (EbeanServer)DatabaseFactory.create(name); 044 } 045 046 /** 047 * Create using the ServerConfig object to configure the database. 048 */ 049 public static EbeanServer create(ServerConfig config) { 050 return (EbeanServer)DatabaseFactory.create(config); 051 } 052 053 /** 054 * Create using the ServerConfig additionally specifying a classLoader to use as the context class loader. 055 */ 056 public static EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) { 057 return (EbeanServer)DatabaseFactory.createWithContextClassLoader(config, classLoader); 058 } 059 060 /** 061 * Shutdown gracefully all EbeanServers cleaning up any resources as required. 062 * <p> 063 * This is typically invoked via JVM shutdown hook and not explicitly called. 064 * </p> 065 */ 066 public static void shutdown() { 067 DatabaseFactory.shutdown(); 068 } 069 070}