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 2018/10/24 20:44:57 UTC
[isis] branch v2 updated: ISIS-1991: allows for the Isis system
environment to be primed from config values
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new e3e3c48 ISIS-1991: allows for the Isis system environment to be primed from config values
e3e3c48 is described below
commit e3e3c48667b5c77f75c0a763c154bb027b7a47e7
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Oct 24 22:43:55 2018 +0200
ISIS-1991: allows for the Isis system environment to be primed from
config values
that is "isis.deploymentType=SERVER" or
"isis.deploymentType=SERVER_PROTOTYPE"
to prime the system environment one can use
IsisContext.primeEnvironment(IsisConfiguration conf)
---
.../isis/core/runtime/headless/IsisSystem.java | 15 +++++------
.../core/runtime/system/context/IsisContext.java | 10 +++++++
.../system/context/IsisSystemEnvironment.java | 31 +++++++++++++++++++---
.../viewer/integration/isis/IsisInjectModule.java | 4 +--
4 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystem.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystem.java
index 6398380..16ad411 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystem.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/IsisSystem.java
@@ -187,8 +187,13 @@ public class IsisSystem {
configurationOverride
);
- final IsisSessionFactoryBuilder isisSessionFactoryBuilder = new IsisSessionFactoryBuilder(componentProvider,
- deploymentTypeFrom(configurationOverride), appManifestIfAny);
+ IsisContext.primeEnvironment(configurationOverride);
+
+ final IsisSessionFactoryBuilder isisSessionFactoryBuilder =
+ new IsisSessionFactoryBuilder(
+ componentProvider,
+ IsisContext.getEnvironment().getDeploymentCategory(),
+ appManifestIfAny);
// ensures that a FixtureClock is installed as the singleton underpinning the ClockService
FixtureClock.initialize();
@@ -221,12 +226,6 @@ public class IsisSystem {
openSession();
}
- public static DeploymentCategory deploymentTypeFrom(final IsisConfiguration configurationOverride) {
- final DeploymentType deploymentType = DeploymentType.lookup(
- configurationOverride.getString("isis.deploymentType", "SERVER"));
- return deploymentType.getDeploymentCategory();
- }
-
// -- isisSystem (populated during setup)
protected IsisSessionFactory isisSessionFactory;
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
index 9e220b5..fb45ee3 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
@@ -76,6 +76,14 @@ public interface IsisContext {
return _Context.getOrElse(IsisSystemEnvironment.class, IsisSystemEnvironment::getDefault);
}
+ /**
+ * For integration testing allows to prime the environment via provided configuration. Will not override
+ * any IsisSystemEnvironment instance, that is already registered with the current context, because the
+ * IsisSystemEnvironment is expected to be an immutable singleton within an application's life-cycle.
+ */
+ public static void primeEnvironment(IsisConfiguration conf) {
+ _Context.computeIfAbsent(IsisSystemEnvironment.class, __->IsisSystemEnvironment.of(conf));
+ }
// -- LIFE-CYCLING
@@ -153,4 +161,6 @@ public interface IsisContext {
System.out.println("================================================");
}
+
+
}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisSystemEnvironment.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisSystemEnvironment.java
index 7fc8b13..a639e82 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisSystemEnvironment.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisSystemEnvironment.java
@@ -19,12 +19,14 @@
package org.apache.isis.core.runtime.system.context;
+import org.apache.isis.commons.internal.base._Strings;
+import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
+import org.apache.isis.core.runtime.system.DeploymentType;
/**
- * Represents configuration, that is available in an early phase of bootstrapping,
- * hence can itself not depend on services or information that only get
- * available during bootstrapping.
+ * Represents configuration, that is available in an early phase of bootstrapping
+ * and should is regarded immutable during application's life-cycle.
*
* @since 2.0.0-M2
*/
@@ -32,6 +34,27 @@ public interface IsisSystemEnvironment {
public DeploymentCategory getDeploymentCategory();
+ public static IsisSystemEnvironment of(IsisConfiguration config) {
+
+ final String deploymentTypeLiteral = config.getString("isis.deploymentType");
+ if(_Strings.isNullOrEmpty(deploymentTypeLiteral)) {
+ return getDefault();
+ }
+
+ // at this point, the deploymentType seem explicitly set via config, so we override any
+ // environment variables that might be present
+
+ // throws if type can not be parsed
+ final DeploymentType deploymentType = DeploymentType.lookup(deploymentTypeLiteral);
+
+ switch(deploymentType.getDeploymentCategory()) {
+ case PROTOTYPING:
+ return getPrototyping();
+ default:
+ return getProduction();
+ }
+ }
+
// -- DEFAULT IMPLEMENTATIONS
public static IsisSystemEnvironment getDefault() {
@@ -54,6 +77,8 @@ public interface IsisSystemEnvironment {
}
+
+
}
diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/isis/IsisInjectModule.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/isis/IsisInjectModule.java
index f5ae362..a96667d 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/isis/IsisInjectModule.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/isis/IsisInjectModule.java
@@ -33,8 +33,8 @@ import org.apache.isis.core.commons.config.IsisConfigurationDefault;
import org.apache.isis.core.commons.factory.InstanceUtil;
import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.runtime.headless.IsisSystem;
import org.apache.isis.core.runtime.system.SystemConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
import org.apache.isis.core.runtime.systemusinginstallers.IsisComponentProvider;
@@ -81,7 +81,7 @@ public class IsisInjectModule extends AbstractModule {
public IsisInjectModule(
final IsisConfigurationDefault isisConfiguration) {
this.isisConfiguration = isisConfiguration;
- this.deploymentCategory = IsisSystem.deploymentTypeFrom(isisConfiguration);
+ this.deploymentCategory = IsisContext.getEnvironment().getDeploymentCategory();
}
/**