#2374 - Bump to Java 11 and module-path

This commit is contained in:
Rob Bygrave committed 2022-03-31 08:42:14 +13:00
1 parent 79be375f54
commit 24d8f38b1d
71 files changed
+149 -366

No files matched your search

@@ -23,6 +23,7 @@ import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
import org.slf4j.Logger;
import javax.persistence.PersistenceException;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
@@ -136,9 +137,21 @@ public final class DefaultContainer implements SpiContainer {
}
if (config.isAutoLoadModuleInfo()) {
// auto register entity classes
boolean found = false;
for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
config.addAll(loader.classesFor(config.getName(), config.isDefaultServer()));
found = true;
}
if (!found) {
checkMissingModulePathProvides();
}
}
}
private void checkMissingModulePathProvides() {
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.ModuleInfoLoader");
if (servicesFile != null) {
log.error("module-info.java is probably missing 'provides io.ebean.config.ModuleInfoLoader with _Ebean$ModuleInfo' clause. ModuleInfoLoader exists but was not service loaded.");
}
}
@@ -562,7 +562,29 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
@SuppressWarnings("unchecked")
public <T> BeanManager<T> beanManager(Class<T> entityType) {
return (BeanManager<T>) beanManager(entityType.getName());
BeanManager<T> mgr = (BeanManager<T>) beanManager(entityType.getName());
if (mgr == null) {
errorBeanNotRegistered(entityType);
}
return mgr;
}
private <T> void errorBeanNotRegistered(Class<T> entityType) {
if (beanManagerMap.isEmpty()) {
throw new PersistenceException(errNothingRegistered());
} else {
throw new PersistenceException(errNotRegistered(entityType));
}
}
private <T> String errNothingRegistered() {
return "There are no registered entities. If using query beans, that generates _Ebean$ModuleInfo.java into " +
"generated sources and is service loaded. If using module-info.java, then probably missing 'provides io.ebean.config.ModuleInfoLoader with _Ebean$ModuleInfo' clause.";
}
private String errNotRegistered(Class<?> beanClass) {
return "The type [" + beanClass + "] is not a registered entity?"
+ " If you don't explicitly list the entity classes to use Ebean will search for them in the classpath.";
}
private BeanManager<?> beanManager(String beanClassName) {
@@ -1196,11 +1196,6 @@ public final class DefaultPersister implements Persister {
return request;
}
private String errNotRegistered(Class<?> beanClass) {
return "The type [" + beanClass + "] is not a registered entity?"
+ " If you don't explicitly list the entity classes to use Ebean will search for them in the classpath.";
}
/**
* Return the BeanDescriptor for a bean that is being persisted.
* <p>
@@ -1210,10 +1205,6 @@ public final class DefaultPersister implements Persister {
*/
@SuppressWarnings("unchecked")
private <T> BeanManager<T> beanManager(Class<?> cls) {
BeanManager<T> mgr = (BeanManager<T>) beanDescriptorManager.beanManager(cls);
if (mgr == null) {
throw new PersistenceException(errNotRegistered(cls));
}
return mgr;
return (BeanManager<T>) beanDescriptorManager.beanManager(cls);
}
}
@@ -6,6 +6,7 @@ module io.ebean.core {
uses io.ebean.config.DatabaseConfigProvider;
uses io.ebean.config.ServerConfigProvider;
uses io.ebean.config.ModuleInfoLoader;
uses io.ebean.config.dbplatform.DatabasePlatformProvider;
uses io.ebean.datasource.DataSourceAlertFactory;
uses io.ebean.core.type.ExtraTypeFactory;
uses io.ebeanservice.docstore.api.DocStoreFactory;
@@ -23,7 +24,7 @@ module io.ebean.core {
requires transitive io.ebean.xmapping.api;
requires transitive io.ebean.core.type;
requires transitive io.ebean.ddl.runner;
requires transitive org.antlr.antlr4.runtime;
requires org.antlr.antlr4.runtime;
requires io.avaje.classpath.scanner;
requires io.ebean.types;
requires org.slf4j;
@@ -41,17 +42,32 @@ module io.ebean.core {
exports io.ebeaninternal.server.cache;
exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test;
exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator;
exports io.ebeaninternal.server.deploy.id to io.ebean.ddl.generator;
exports io.ebeaninternal.server.deploy.meta to io.ebean.ddl.generator;
exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
exports io.ebeaninternal.server.el to io.ebean.autotune;
exports io.ebeaninternal.api.json to io.ebean.test;
exports io.ebeaninternal.json to io.ebean.test;
exports io.ebeaninternal.server.autotune to io.ebean.autotune;
exports io.ebeaninternal.server.querydefn to io.ebean.autotune, io.ebean.querybean;
exports io.ebeaninternal.server.type to io.ebean.postgis;
exports io.ebeaninternal.server.core to io.ebean.test;
exports io.ebeaninternal.server.core.bootup to io.ebean.test;
exports io.ebeaninternal.server.core.timezone to io.ebean.test;
exports io.ebeaninternal.server.cluster to io.ebean.test;
exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator, io.ebean.test;
exports io.ebeaninternal.server.deploy.id to io.ebean.ddl.generator;
exports io.ebeaninternal.server.deploy.meta to io.ebean.ddl.generator, io.ebean.test;
exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
exports io.ebeaninternal.server.el to io.ebean.autotune, io.ebean.test;
exports io.ebeaninternal.server.expression to io.ebean.querybean, io.ebean.test;
exports io.ebeaninternal.server.expression.platform to io.ebean.test;
exports io.ebeaninternal.server.grammer to io.ebean.test;
exports io.ebeaninternal.server.idgen to io.ebean.test;
exports io.ebeaninternal.server.persist to io.ebean.test;
exports io.ebeaninternal.server.query to io.ebean.test;
exports io.ebeaninternal.server.querydefn to io.ebean.autotune, io.ebean.querybean, io.ebean.test;
exports io.ebeaninternal.server.rawsql to io.ebean.test;
exports io.ebeaninternal.server.text.json to io.ebean.test;
exports io.ebeaninternal.server.type to io.ebean.postgis, io.ebean.test;
exports io.ebeaninternal.server.transaction to io.ebean.test;
exports io.ebeaninternal.server.util to io.ebean.querybean;
exports io.ebeaninternal.server.expression to io.ebean.querybean;
exports io.ebeanservice.docstore.api to io.ebean.test;
exports io.ebeanservice.docstore.api.support to io.ebean.test;
provides io.ebean.metric.MetricFactory with io.ebeaninternal.server.profile.DMetricFactory;
provides io.ebean.service.SpiContainerFactory with io.ebeaninternal.server.DContainerFactory;