public EbeanManaged(final Config config, final ServerConfig conf) { ebean = Suppliers.memoize(() -> { EbeanServer ebean = EbeanServerFactory.create(conf); // move .sql file to tmp directory... didn't find any other way of dealing with this if (conf.isDdlGenerate()) { String tmpdir = config.getString("application.tmpdir"); move(conf.getName() + "-drop-all.sql", tmpdir); move(conf.getName() + "-create-all.sql", tmpdir); } return ebean; }); }
/** * Initialise the container with clustering configuration. * <p> * Call this prior to creating any EbeanServer instances or alternatively set the * ContainerConfig on the ServerConfig when creating the first EbeanServer instance. */ public static synchronized void initialiseContainer(ContainerConfig containerConfig) { getContainer(containerConfig); }
/** * Create using the ServerConfig object to configure the server. */ public static synchronized EbeanServer create(ServerConfig config) { if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } EbeanServer server = createInternal(config); if (config.isRegister()) { PrimaryServer.setSkip(true); Ebean.register(server, config.isDefaultServer()); } return server; }
/** * Get the EbeanContainer initialising it if necessary. * * @param containerConfig the configuration controlling clustering communication */ private static SpiContainer getContainer(ContainerConfig containerConfig) { // thread safe in that all calling methods are synchronized if (container != null) { return container; } if (containerConfig == null) { // effectively load configuration from ebean.properties Properties properties = PrimaryServer.getProperties(); containerConfig = new ContainerConfig(); containerConfig.loadFromProperties(properties); } container = createContainer(containerConfig); return container; }
/** * Create using the ServerConfig additionally specifying a classLoader to use as the context class loader. */ public static synchronized Database createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader) { return EbeanServerFactory.createWithContextClassLoader(config, classLoader); }
/** * Create using the ServerConfig object to configure the server. */ public static synchronized EbeanServer create(ServerConfig config) { if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } EbeanServer server = createInternal(config); if (config.isRegister()) { PrimaryServer.setSkip(true); Ebean.register(server, config.isDefaultServer()); } return server; }
/** * Get the EbeanContainer initialising it if necessary. * * @param containerConfig the configuration controlling clustering communication */ private static SpiContainer getContainer(ContainerConfig containerConfig) { // thread safe in that all calling methods are synchronized if (container != null) { return container; } if (containerConfig == null) { // effectively load configuration from ebean.properties Properties properties = PrimaryServer.getProperties(); containerConfig = new ContainerConfig(); containerConfig.loadFromProperties(properties); } container = createContainer(containerConfig); return container; }
/** * Create using the ServerConfig additionally specifying a classLoader to use as the context class loader. */ public static synchronized EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) { ClassLoader currentContextLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); try { return EbeanServerFactory.create(config); } finally { // set the currentContextLoader back Thread.currentThread().setContextClassLoader(currentContextLoader); } }
/** * Create using ebean.properties to configure the server. */ public static synchronized EbeanServer create(String name) { // construct based on loading properties files // and if invoked by Ebean then it handles registration SpiContainer serverFactory = getContainer(null); return serverFactory.createServer(name); }
/** * Synchronized read, create and put of EbeanServers. */ private EbeanServer getWithCreate(String name) { synchronized (monitor) { EbeanServer server = syncMap.get(name); if (server == null) { // register when creating server this way server = EbeanServerFactory.create(name); register(server, false); } return server; } }
private static EbeanServer createInternal(ServerConfig config) { return getContainer(config.getContainerConfig()).createServer(config); }
/** * Create using ebean.properties to configure the server. */ public static synchronized Database create(String name) { return EbeanServerFactory.create(name); }
/** * Initialise the container with clustering configuration. * <p> * Call this prior to creating any EbeanServer instances or alternatively set the * ContainerConfig on the ServerConfig when creating the first EbeanServer instance. */ public static synchronized void initialiseContainer(ContainerConfig containerConfig) { getContainer(containerConfig); }
/** * Create using the ServerConfig object to configure the server. */ public static synchronized Database create(DatabaseConfig config) { return EbeanServerFactory.create(config); }
/** * Create using ebean.properties to configure the server. */ public static synchronized EbeanServer create(String name) { // construct based on loading properties files // and if invoked by Ebean then it handles registration SpiContainer serverFactory = getContainer(null); return serverFactory.createServer(name); }
/** * Create using the ServerConfig additionally specifying a classLoader to use as the context class loader. */ public static synchronized EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) { ClassLoader currentContextLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); try { return EbeanServerFactory.create(config); } finally { // set the currentContextLoader back Thread.currentThread().setContextClassLoader(currentContextLoader); } }
private static EbeanServer createInternal(ServerConfig config) { return getContainer(config.getContainerConfig()).createServer(config); }
/** * Initialise the Ebean servers. */ public void start() { config.serverConfigs().forEach((key, serverConfig) -> servers.put(key, EbeanServerFactory.create(serverConfig))); }
/** * Synchronized read, create and put of EbeanServers. */ private EbeanServer getWithCreate(String name) { synchronized (monitor) { EbeanServer server = syncMap.get(name); if (server == null) { // register when creating server this way server = EbeanServerFactory.create(name); register(server, false); } return server; } }
public EbeanManaged(final Config config, final ServerConfig conf) { ebean = Suppliers.memoize(() -> { EbeanServer ebean = EbeanServerFactory.create(conf); // move .sql file to tmp directory... didn't find any other way of dealing with this if (conf.isDdlGenerate()) { String tmpdir = config.getString("application.tmpdir"); move(conf.getName() + "-drop-all.sql", tmpdir); move(conf.getName() + "-create-all.sql", tmpdir); } return ebean; }); }