You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/01/31 10:43:19 UTC
[isis] branch master updated: ISIS-2504: revert some changes of the
prev. commit
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 26c11fa ISIS-2504: revert some changes of the prev. commit
26c11fa is described below
commit 26c11fae1f7bab895aefb122ffd20bffe335579f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 31 11:43:01 2021 +0100
ISIS-2504: revert some changes of the prev. commit
instead of removing the entire datanucleus config, just remove the
datasource part of it
---
.../modules/ROOT/pages/2020/2.0.0-M5/mignotes.adoc | 4 +-
.../apache/isis/core/config/IsisConfiguration.java | 231 +++++++++++++++++++++
.../DataSourceIntrospectionService.java | 4 +-
.../jdo/datanucleus/schema/_DnApplication.java | 2 +
.../schema/_DnApplicationComponents.java | 16 +-
5 files changed, 250 insertions(+), 7 deletions(-)
diff --git a/antora/components/relnotes/modules/ROOT/pages/2020/2.0.0-M5/mignotes.adoc b/antora/components/relnotes/modules/ROOT/pages/2020/2.0.0-M5/mignotes.adoc
index b13d969..802c2c8 100644
--- a/antora/components/relnotes/modules/ROOT/pages/2020/2.0.0-M5/mignotes.adoc
+++ b/antora/components/relnotes/modules/ROOT/pages/2020/2.0.0-M5/mignotes.adoc
@@ -85,8 +85,8 @@ VIEW_CONTRIBUTIONS_ONLY,
| was
| new
-| isis.persistence.???jdo??? //TODO
-| isis.persistence.schema
+| isis.persistence.jdo-datanucleus.impl.javax
+| removed, instead configure datasources the Spring way
| isis.core.runtimeservices.exception-recognizer.jdo
| isis.core.runtimeservices.exception-recognizer.dae
diff --git a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
index 75b0869..6dbbee4 100644
--- a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
@@ -1646,6 +1646,237 @@ public class IsisConfiguration {
private final Persistence persistence = new Persistence();
@Data
public static class Persistence {
+ private final JdoDatanucleus jdoDatanucleus = new JdoDatanucleus();
+ @Data
+ public static class JdoDatanucleus {
+
+ private String classMetadataLoadedListener = "org.apache.isis.persistence.jdo.datanucleus.config.CreateSchemaObjectFromClassMetadata";
+
+ private final Impl impl = new Impl();
+ @Data
+ public static class Impl {
+ private final Datanucleus datanucleus = new Datanucleus();
+ @Data
+ public static class Datanucleus {
+
+
+ /**
+ * The JNDI name for a connection factory for transactional connections.
+ *
+ * <p>
+ * For RBDMS, it must be a JNDI name that points to a javax.sql.DataSource object.
+ * </p>
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private String connectionFactoryName;
+
+ /**
+ * The JNDI name for a connection factory for non-transactional connections.
+ *
+ * <p>
+ * For RBDMS, it must be a JNDI name that points to a javax.sql.DataSource object.
+ * </p>
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private String connectionFactory2Name;
+
+
+ /**
+ * Name of a class that implements <code>org.datanucleus.store.connection.DecryptionProvider</code>
+ * and should only be specified if the password is encrypted in the persistence properties.
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private String connectionPasswordDecrypter;
+
+
+ /**
+ * Used when we have specified the persistence-unit name for a PMF/EMF and where we want the
+ * datastore "tables" for all classes of that persistence-unit loading up into the StoreManager.
+ *
+ * <p>
+ * Defaults to true, which is the opposite of DataNucleus' own default.
+ * (The reason that DN defaults to false is because some databases are slow so such an
+ * operation would slow down the startup process).
+ * </p>
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private boolean persistenceUnitLoadClasses = true;
+
+ public enum TransactionTypeEnum {
+ RESOURCE_LOCAL,
+ JTA
+ }
+
+ /**
+ * Type of transaction to use.
+ *
+ * <p>
+ * If running under JavaSE the default is RESOURCE_LOCAL, and if running under JavaEE the default is JTA.
+ * </p>
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private TransactionTypeEnum transactionType;
+
+ private final Cache cache = new Cache();
+ @Data
+ public static class Cache {
+ private final Level2 level2 = new Level2();
+ @Data
+ public static class Level2 {
+ /**
+ * Name of the type of Level 2 Cache to use.
+ *
+ * <p>
+ * Can be used to interface with external caching products.
+ * Use "none" to turn off L2 caching.
+ * </p>
+ *
+ * <p>
+ * See also Cache docs for JDO, and for JPA
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ @NotNull @NotEmpty
+ private String type = "none";
+ }
+ }
+ private final Schema schema = new Schema();
+ @Data
+ public static class Schema {
+ /**
+ * Whether DN should automatically create the database schema on bootstrapping.
+ *
+ * <p>
+ * This should be set to <tt>true</tt> when running against an in-memory database, but
+ * set to <tt>false</tt> when running against a persistent database (use something like
+ * flyway instead to manage schema evolution).
+ * </p>
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ *
+ * @implNote - this config property isn't used by the core framework, but is used by one the flyway extension.
+ */
+ private boolean autoCreateAll = false;
+
+ /**
+ * Previously we defaulted this property to "true", but that could cause the target database
+ * to be modified
+ *
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private boolean autoCreateDatabase = false;
+
+ /**
+ * <p>
+ * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+ * </p>
+ *
+ * @implNote - this config property isn't used by the framework, but is provided as a convenience for IDE autocomplete.
+ */
+ private boolean validateAll = true;
+ }
+ }
+
+ // configure datasources with Spring instead
+
+// private final Javax javax = new Javax();
+// @Data
+// public static class Javax {
+// private final Jdo jdo = new Jdo();
+// @Data
+// public static class Jdo {
+//
+// /**
+// * <p>
+// * See also <tt>additional-spring-configuration-metadata.json</tt> (camelCasing instead of kebab-casing).
+// * </p>
+// *
+// * @implNote - changing this property from its default is used to enable the flyway extension (in combination with {@link Datanucleus.Schema#isAutoCreateAll()}
+// */
+// @NotNull @NotEmpty
+// private String persistenceManagerFactoryClass = "org.datanucleus.api.jdo.JDOPersistenceManagerFactory";
+//
+// private final Option option = new Option();
+// @Data
+// public static class Option {
+// /**
+// * JDBC driver used by JDO/DataNucleus object store to connect.
+// *
+// * <p>
+// * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+// * </p>
+// *
+// * @implNote - this config property isn't used by the framework, but provided as a convenience for IDE autocomplete (and is mandatory if using JDO Datanucleus).
+// */
+// private String connectionDriverName;
+// /**
+// * URL used by JDO/DataNucleus object store to connect.
+// *
+// * <p>
+// * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+// * </p>
+// *
+// * @implNote - some extensions (H2Console, MsqlDbManager) peek at this URL to determine if they should be enabled. Note that it is also mandatory if using JDO Datanucleus.
+// */
+// private String connectionUrl;
+// /**
+// * User account used by JDO/DataNucleus object store to connect.
+// *
+// * <p>
+// * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+// * </p>
+// *
+// * @implNote - this config property isn't used by the framework, but provided as a convenience for IDE autocomplete (and is mandatory if using JDO Datanucleus).
+// */
+// private String connectionUserName;
+// /**
+// * Password for the user account used by JDO/DataNucleus object store to connect.
+// *
+// * <p>
+// * See also <tt>additional-spring-configuration-metadata.json</tt> (PascalCasing instead of kebab-casing).
+// * </p>
+// *
+// * @implNote - this config property isn't used by the framework, but provided as a convenience for IDE autocomplete. It is not necessarily mandatory, some databases accept an empty password.
+// */
+// private String connectionPassword;
+// }
+// }
+// }
+ }
+ }
private final Schema schema = new Schema();
@Data
diff --git a/core/config/src/main/java/org/apache/isis/core/config/datasources/DataSourceIntrospectionService.java b/core/config/src/main/java/org/apache/isis/core/config/datasources/DataSourceIntrospectionService.java
index 85ee2c6..4a9cdfa 100644
--- a/core/config/src/main/java/org/apache/isis/core/config/datasources/DataSourceIntrospectionService.java
+++ b/core/config/src/main/java/org/apache/isis/core/config/datasources/DataSourceIntrospectionService.java
@@ -25,6 +25,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.core.annotation.Order;
@@ -56,7 +57,8 @@ import bsh.EvalError;
@Log4j2
public class DataSourceIntrospectionService {
- @Inject private List<DataSource> dataSources;
+ @Autowired(required = false)
+ private List<DataSource> dataSources;
@Value
public static class DataSourceInfo {
diff --git a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplication.java b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplication.java
index e87f091..9a7a012 100644
--- a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplication.java
+++ b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplication.java
@@ -52,6 +52,7 @@ public class _DnApplication {
final MetaModelContext metaModelContext,
final DnSettings dnSettings) {
+ val configuration = metaModelContext.getConfiguration();
val isisBeanTypeRegistry = metaModelContext.getServiceRegistry()
.lookupServiceElseFail(IsisBeanTypeRegistry.class);
@@ -64,6 +65,7 @@ public class _DnApplication {
}
val dataNucleusApplicationComponents = new _DnApplicationComponents(
+ configuration,
dnSettings.getAsProperties(),
classesToBePersisted);
diff --git a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplicationComponents.java b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplicationComponents.java
index 673f7c3..58d0f7d 100644
--- a/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplicationComponents.java
+++ b/persistence/jdo/datanucleus/src/main/java/org/apache/isis/persistence/jdo/datanucleus/schema/_DnApplicationComponents.java
@@ -18,6 +18,8 @@
*/
package org.apache.isis.persistence.jdo.datanucleus.schema;
+import static org.apache.isis.commons.internal.base._NullSafe.stream;
+
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -39,15 +41,14 @@ import org.datanucleus.store.schema.SchemaAwareStoreManager;
import org.apache.isis.commons.internal.base._NullSafe;
import org.apache.isis.commons.internal.collections._Maps;
import org.apache.isis.commons.internal.context._Context;
+import org.apache.isis.commons.internal.factory._InstanceUtil;
+import org.apache.isis.core.config.IsisConfiguration;
import org.apache.isis.core.metamodel.context.MetaModelContext;
import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.persistence.jdo.datanucleus.config.CreateSchemaObjectFromClassMetadata;
import org.apache.isis.persistence.jdo.datanucleus.config.DataNucleusPropertiesAware;
import org.apache.isis.persistence.jdo.provider.metamodel.facets.object.query.JdoNamedQuery;
import org.apache.isis.persistence.jdo.provider.metamodel.facets.object.query.JdoQueryFacet;
-import static org.apache.isis.commons.internal.base._NullSafe.stream;
-
import lombok.Getter;
import lombok.val;
import lombok.extern.log4j.Log4j2;
@@ -57,14 +58,17 @@ import lombok.extern.log4j.Log4j2;
final class _DnApplicationComponents {
private final Set<String> persistableClassNameSet;
+ private final IsisConfiguration configuration;
private final Map<String, Object> datanucleusProps;
@Getter private PersistenceManagerFactory persistenceManagerFactory;
public _DnApplicationComponents(
+ final IsisConfiguration configuration,
final Map<String, Object> datanucleusProps,
final Set<String> persistableClassNameSet) {
+ this.configuration = configuration;
this.datanucleusProps = datanucleusProps;
this.persistableClassNameSet = persistableClassNameSet;
@@ -216,9 +220,13 @@ final class _DnApplicationComponents {
}
private MetaDataListener createMetaDataListener() {
- return new CreateSchemaObjectFromClassMetadata();
+ final String classMetadataListenerClassName = configuration.getPersistence().getJdoDatanucleus().getClassMetadataLoadedListener();
+ return classMetadataListenerClassName != null
+ ? _InstanceUtil.createInstance(classMetadataListenerClassName, MetaDataListener.class)
+ : null;
}
+
private static Properties asProperties(final Map<String, Object> props) {
final Properties properties = new Properties();
properties.putAll(props);