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/16 22:26:28 UTC
[isis] 02/02: ISIS-1895: fixes context parameters not picked up
during bootstrapping
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
commit 46509221735b51f226b91f40992f88bcbf64e1ff
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Oct 17 00:25:50 2018 +0200
ISIS-1895: fixes context parameters not picked up during bootstrapping
Task-Url: https://issues.apache.org/jira/browse/ISIS-1895
---
.../isis/core/webapp/IsisWebAppConfigProvider.java | 18 ++++++++----------
.../isis/core/webapp/IsisWebAppContextListener.java | 2 +-
.../org/apache/isis/core/webapp/WebAppConstants.java | 7 -------
.../isis/core/webapp/modules/WebModule_Wicket.java | 5 ++---
4 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppConfigProvider.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppConfigProvider.java
index 0e7b8bc..2bb2bca 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppConfigProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppConfigProvider.java
@@ -44,12 +44,13 @@ public class IsisWebAppConfigProvider {
private static final Logger LOG = LoggerFactory.getLogger(IsisWebAppConfigProvider.class);
+ private IsisConfigurationBuilder cfgBuilder;
+
/**
- * Removes any cashed IsisConfigurationBuilder instance from the ServletContext.
- * @param servletContext
+ * Removes any cached IsisConfigurationBuilder instance from this provider.
*/
- public void invalidate(final ServletContext servletContext) {
- servletContext.setAttribute(WebAppConstants.CONFIGURATION_BUILDER_KEY, null);
+ public void invalidate() {
+ cfgBuilder = null;
}
/**
@@ -60,13 +61,10 @@ public class IsisWebAppConfigProvider {
* @return
*/
public synchronized IsisConfigurationBuilder getConfigurationBuilder(final ServletContext servletContext) {
- IsisConfigurationBuilder isisConfigurationBuilder =
- (IsisConfigurationBuilder) servletContext.getAttribute(WebAppConstants.CONFIGURATION_BUILDER_KEY);
- if(isisConfigurationBuilder == null) {
- isisConfigurationBuilder = newIsisConfigurationBuilder(servletContext);
- servletContext.setAttribute(WebAppConstants.CONFIGURATION_BUILDER_KEY, isisConfigurationBuilder);
+ if(cfgBuilder == null) {
+ cfgBuilder = newIsisConfigurationBuilder(servletContext);
}
- return isisConfigurationBuilder;
+ return cfgBuilder;
}
/**
diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppContextListener.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppContextListener.java
index a4559c9..2267032 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppContextListener.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppContextListener.java
@@ -83,7 +83,7 @@ public class IsisWebAppContextListener implements ServletContextListener {
// put the list of viewer names "isis.viewers" into a context parameter
WebModule.ContextUtil.commitViewers(servletContext);
// invalidate config such that next IsisConfigurationBuilder that gets obtained is reinitialized
- configProvider.invalidate(servletContext);
+ configProvider.invalidate();
LOG.info("=== PHASE 2 === Initializing the ServletContext");
diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/WebAppConstants.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/WebAppConstants.java
index 1fde0fe..f3bf67b 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/webapp/WebAppConstants.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/WebAppConstants.java
@@ -25,13 +25,6 @@ import org.apache.isis.core.commons.authentication.AuthenticationSession;
public final class WebAppConstants {
/**
- * Key under which the {@link org.apache.isis.core.commons.configbuilder.IsisConfigurationBuilder} is
- * bound as a servlet context attribute (<tt>ServletContext#getAttribute(String)</tt>); used to pass
- * from the <tt>webserver</tt> module to this.
- */
- public static final String CONFIGURATION_BUILDER_KEY = "isis.configurationBuilder";
-
- /**
* Key under which the {@link AuthenticationSession} is bound as a session
* attribute ( <tt>HttpSession#getAttribute(String)</tt>).
*/
diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/modules/WebModule_Wicket.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/modules/WebModule_Wicket.java
index 1b286db..a5e060c 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/webapp/modules/WebModule_Wicket.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/modules/WebModule_Wicket.java
@@ -31,6 +31,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.webapp.IsisWebAppConfigProvider;
/**
@@ -65,9 +66,7 @@ final class WebModule_Wicket implements WebModule {
configProvider.peekAtOrDefault(ctx, "isis.viewer.wicket.basePath", "/wicket");
{
- //TODO[ahuber] once this class is moved to viewer-wicket-impl, we can utilize
- // IsisWicketApplication's method of determining the deployment code.
- deploymentMode = "true".equalsIgnoreCase(System.getenv("PROTOTYPING"))
+ deploymentMode = IsisContext.getEnvironment().getDeploymentCategory().isPrototyping()
? "development" : "deployment";
}