mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge pull request #2662 from ebean-orm/feature/deprecated-remove-Ebean
Remove deprecated Ebean, EbeanServer, EbeanServerFactory, ServerConfig migrate to DB, Database, DatabaseFactory, DatabaseConfig
This commit is contained in:
12 files changed
+13
-1423
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,15 +0,0 @@
|
|||||||
package io.ebean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - please migrate to <code>io.ebean.Database</code>.
|
|
||||||
* Provides the API for fetching and saving beans to a particular Database.
|
|
||||||
* <p>
|
|
||||||
* Effectively this is an alias for {@link Database} which is now the new
|
|
||||||
* and improved name for EbeanServer.
|
|
||||||
* <p>
|
|
||||||
* The preference is to use DB and Database rather than Ebean and EbeanServer.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface EbeanServer extends Database {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package io.ebean;
|
|
||||||
|
|
||||||
import io.ebean.config.ContainerConfig;
|
|
||||||
import io.ebean.config.ServerConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - please migrate to DatabaseFactory.
|
|
||||||
* <p>
|
|
||||||
* Creates EbeanServer instances.
|
|
||||||
* <p>
|
|
||||||
* This uses either a ServerConfig or properties in the ebean.properties file to
|
|
||||||
* configure and create a EbeanServer instance.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* The EbeanServer instance can either be registered with the Ebean singleton or
|
|
||||||
* not. The Ebean singleton effectively holds a map of EbeanServers by a name.
|
|
||||||
* If the EbeanServer is registered with the Ebean singleton you can retrieve it
|
|
||||||
* later via {@link Ebean#getServer(String)}.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* One EbeanServer can be nominated as the 'default/primary' EbeanServer. Many
|
|
||||||
* methods on the Ebean singleton such as {@link Ebean#find(Class)} are just a
|
|
||||||
* convenient way of using the 'default/primary' EbeanServer.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class EbeanServerFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 void initialiseContainer(ContainerConfig containerConfig) {
|
|
||||||
DatabaseFactory.initialiseContainer(containerConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create using ebean.properties to configure the database.
|
|
||||||
*/
|
|
||||||
public static EbeanServer create(String name) {
|
|
||||||
return (EbeanServer)DatabaseFactory.create(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create using the ServerConfig object to configure the database.
|
|
||||||
*/
|
|
||||||
public static EbeanServer create(ServerConfig config) {
|
|
||||||
return (EbeanServer)DatabaseFactory.create(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create using the ServerConfig additionally specifying a classLoader to use as the context class loader.
|
|
||||||
*/
|
|
||||||
public static EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) {
|
|
||||||
return (EbeanServer)DatabaseFactory.createWithContextClassLoader(config, classLoader);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shutdown gracefully all EbeanServers cleaning up any resources as required.
|
|
||||||
* <p>
|
|
||||||
* This is typically invoked via JVM shutdown hook and not explicitly called.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public static void shutdown() {
|
|
||||||
DatabaseFactory.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package io.ebean.config;
|
|
||||||
|
|
||||||
import io.ebean.DatabaseFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - please migrate to <code>io.ebean.DatabaseConfig</code>.
|
|
||||||
*
|
|
||||||
* The configuration used for creating a Database.
|
|
||||||
* <p>
|
|
||||||
* Used to programmatically construct a Database and optionally register it
|
|
||||||
* with the DB singleton.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* If you just use DB without this programmatic configuration DB will read
|
|
||||||
* the application.properties file and take the configuration from there. This usually
|
|
||||||
* includes searching the class path and automatically registering any entity
|
|
||||||
* classes and listeners etc.
|
|
||||||
* </p>
|
|
||||||
* <pre>{@code
|
|
||||||
*
|
|
||||||
* ServerConfig config = new ServerConfig();
|
|
||||||
*
|
|
||||||
* // read the ebean.properties and load
|
|
||||||
* // those settings into this serverConfig object
|
|
||||||
* config.loadFromProperties();
|
|
||||||
*
|
|
||||||
* // explicitly register the entity beans to avoid classpath scanning
|
|
||||||
* config.addClass(Customer.class);
|
|
||||||
* config.addClass(User.class);
|
|
||||||
*
|
|
||||||
* Database database = DatabaseFactory.create(config);
|
|
||||||
*
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Note that ServerConfigProvider provides a standard Java ServiceLoader mechanism that can
|
|
||||||
* be used to apply configuration to the ServerConfig.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author emcgreal
|
|
||||||
* @author rbygrave
|
|
||||||
* @see DatabaseFactory
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class ServerConfig extends DatabaseConfig {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package io.ebean.config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated - migrate to DatabaseConfigProvider.
|
|
||||||
* <p>
|
|
||||||
* Provides a ServiceLoader based mechanism to configure a ServerConfig.
|
|
||||||
* <p>
|
|
||||||
* Provide an implementation and register it via the standard Java ServiceLoader mechanism
|
|
||||||
* via a file at <code>META-INF/services/io.ebean.config.ServerConfigProvider</code>.
|
|
||||||
* <p>
|
|
||||||
* If you are using a DI container like Spring or Guice you are unlikely to use this but instead use a
|
|
||||||
* spring specific configuration. When we are not using a DI container we may use this mechanism to
|
|
||||||
* explicitly register the entity beans and avoid classpath scanning.
|
|
||||||
* </p>
|
|
||||||
* <pre>{@code
|
|
||||||
*
|
|
||||||
* public class EbeanConfigProvider implements ServerConfigProvider {
|
|
||||||
*
|
|
||||||
* @Override
|
|
||||||
* public void apply(ServerConfig config) {
|
|
||||||
*
|
|
||||||
* // register the entity bean classes explicitly
|
|
||||||
* config.addClass(Customer.class);
|
|
||||||
* config.addClass(User.class);
|
|
||||||
* ...
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* }</pre>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface ServerConfigProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply the configuration to the ServerConfig.
|
|
||||||
* <p>
|
|
||||||
* Typically we explicitly register entity bean classes and thus avoid classpath scanning.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
void apply(ServerConfig config);
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ import java.util.stream.Stream;
|
|||||||
/**
|
/**
|
||||||
* Service Provider extension to EbeanServer.
|
* Service Provider extension to EbeanServer.
|
||||||
*/
|
*/
|
||||||
public interface SpiEbeanServer extends SpiServer, ExtendedServer, EbeanServer, BeanCollectionLoader {
|
public interface SpiEbeanServer extends SpiServer, ExtendedServer, BeanCollectionLoader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the L2 cache has been disabled.
|
* Return true if the L2 cache has been disabled.
|
||||||
@@ -55,7 +55,6 @@ public interface SpiEbeanServer extends SpiServer, ExtendedServer, EbeanServer,
|
|||||||
* <p>
|
* <p>
|
||||||
* Typically used to identify the origin of queries for AutoTune and object
|
* Typically used to identify the origin of queries for AutoTune and object
|
||||||
* graph costing.
|
* graph costing.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
CallOrigin createCallOrigin();
|
CallOrigin createCallOrigin();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.ebeaninternal.server.cluster;
|
package io.ebeaninternal.server.cluster;
|
||||||
|
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.Database;
|
||||||
import io.ebean.config.ContainerConfig;
|
import io.ebean.config.ContainerConfig;
|
||||||
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -20,7 +20,7 @@ public class ClusterManager implements ServerLookup {
|
|||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, EbeanServer> serverMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Database> serverMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Object monitor = new Object();
|
private final Object monitor = new Object();
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class ClusterManager implements ServerLookup {
|
|||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerServer(EbeanServer server) {
|
public void registerServer(Database server) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
serverMap.put(server.name(), server);
|
serverMap.put(server.name(), server);
|
||||||
@@ -66,7 +66,7 @@ public class ClusterManager implements ServerLookup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EbeanServer getServer(String name) {
|
public Database getServer(String name) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
return serverMap.get(name);
|
return serverMap.get(name);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package io.ebeaninternal.server.cluster;
|
package io.ebeaninternal.server.cluster;
|
||||||
|
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.Database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns EbeanServer instances for remote message reading.
|
* Returns Database instances for remote message reading.
|
||||||
*/
|
*/
|
||||||
public interface ServerLookup {
|
public interface ServerLookup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the EbeanServer instance by name.
|
* Return the EbeanServer instance by name.
|
||||||
*/
|
*/
|
||||||
EbeanServer getServer(String name);
|
Database getServer(String name);
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,6 @@ import io.ebean.config.ContainerConfig;
|
|||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebean.config.DatabaseConfigProvider;
|
import io.ebean.config.DatabaseConfigProvider;
|
||||||
import io.ebean.config.ModuleInfoLoader;
|
import io.ebean.config.ModuleInfoLoader;
|
||||||
import io.ebean.config.ServerConfig;
|
|
||||||
import io.ebean.config.ServerConfigProvider;
|
|
||||||
import io.ebean.config.TenantMode;
|
import io.ebean.config.TenantMode;
|
||||||
import io.ebean.config.UnderscoreNamingConvention;
|
import io.ebean.config.UnderscoreNamingConvention;
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
@@ -124,15 +122,8 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
|
|
||||||
private void applyConfigServices(DatabaseConfig config) {
|
private void applyConfigServices(DatabaseConfig config) {
|
||||||
if (config.isDefaultServer()) {
|
if (config.isDefaultServer()) {
|
||||||
boolean appliedConfig = false;
|
|
||||||
for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) {
|
for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) {
|
||||||
configProvider.apply(config);
|
configProvider.apply(config);
|
||||||
appliedConfig = true;
|
|
||||||
}
|
|
||||||
if (!appliedConfig && config instanceof ServerConfig) {
|
|
||||||
for (ServerConfigProvider configProvider : ServiceLoader.load(ServerConfigProvider.class)) {
|
|
||||||
configProvider.apply((ServerConfig)config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.isAutoLoadModuleInfo()) {
|
if (config.isAutoLoadModuleInfo()) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.ebeaninternal.server.querydefn;
|
package io.ebeaninternal.server.querydefn;
|
||||||
|
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.Database;
|
||||||
import io.ebean.Update;
|
import io.ebean.Update;
|
||||||
import io.ebeaninternal.api.BindParams;
|
import io.ebeaninternal.api.BindParams;
|
||||||
import io.ebeaninternal.api.SpiUpdate;
|
import io.ebeaninternal.api.SpiUpdate;
|
||||||
@@ -14,7 +14,7 @@ public final class DefaultOrmUpdate<T> implements SpiUpdate<T>, Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -8791423602246515438L;
|
private static final long serialVersionUID = -8791423602246515438L;
|
||||||
|
|
||||||
private transient final EbeanServer server;
|
private transient final Database server;
|
||||||
private final Class<?> beanType;
|
private final Class<?> beanType;
|
||||||
private final String name;
|
private final String name;
|
||||||
private String label;
|
private String label;
|
||||||
@@ -35,7 +35,7 @@ public final class DefaultOrmUpdate<T> implements SpiUpdate<T>, Serializable {
|
|||||||
* Create with a specific server. This means you can use the
|
* Create with a specific server. This means you can use the
|
||||||
* UpdateSql.execute() method.
|
* UpdateSql.execute() method.
|
||||||
*/
|
*/
|
||||||
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, String updateStatement) {
|
public DefaultOrmUpdate(Class<?> beanType, Database server, String baseTable, String updateStatement) {
|
||||||
this.beanType = beanType;
|
this.beanType = beanType;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.baseTable = baseTable;
|
this.baseTable = baseTable;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ module io.ebean.core {
|
|||||||
uses io.ebean.cache.ServerCachePlugin;
|
uses io.ebean.cache.ServerCachePlugin;
|
||||||
uses io.ebean.cache.ServerCacheNotifyPlugin;
|
uses io.ebean.cache.ServerCacheNotifyPlugin;
|
||||||
uses io.ebean.config.DatabaseConfigProvider;
|
uses io.ebean.config.DatabaseConfigProvider;
|
||||||
uses io.ebean.config.ServerConfigProvider;
|
|
||||||
uses io.ebean.config.ModuleInfoLoader;
|
uses io.ebean.config.ModuleInfoLoader;
|
||||||
uses io.ebean.config.dbplatform.DatabasePlatformProvider;
|
uses io.ebean.config.dbplatform.DatabasePlatformProvider;
|
||||||
uses io.ebean.datasource.DataSourceAlertFactory;
|
uses io.ebean.datasource.DataSourceAlertFactory;
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package io.ebean.xtest.internal.server.cluster.binarymessage;
|
package io.ebean.xtest.internal.server.cluster.binarymessage;
|
||||||
|
|
||||||
|
import io.ebean.Database;
|
||||||
import io.ebean.xtest.BaseTestCase;
|
import io.ebean.xtest.BaseTestCase;
|
||||||
import io.ebean.EbeanServer;
|
|
||||||
import io.ebean.xtest.internal.api.TDSpiEbeanServer;
|
import io.ebean.xtest.internal.api.TDSpiEbeanServer;
|
||||||
import io.ebeaninternal.api.TransactionEventTable;
|
import io.ebeaninternal.api.TransactionEventTable;
|
||||||
import io.ebeaninternal.server.cache.RemoteCacheEvent;
|
import io.ebeaninternal.server.cache.RemoteCacheEvent;
|
||||||
@@ -94,7 +94,7 @@ public class BinaryTransactionEventReadWriteTest extends BaseTestCase {
|
|||||||
|
|
||||||
class TDServerLookup implements ServerLookup {
|
class TDServerLookup implements ServerLookup {
|
||||||
@Override
|
@Override
|
||||||
public EbeanServer getServer(String name) {
|
public Database getServer(String name) {
|
||||||
return mockEbeanServer;
|
return mockEbeanServer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user