You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2019/12/04 13:03:47 UTC

[isis] 03/08: ISIS-2212: injects IsisConfiguration into WebModuleRestfulObjects

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit fef973c92669596028c416bcc05a684203dd651e
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Dec 4 12:35:38 2019 +0000

    ISIS-2212: injects IsisConfiguration into WebModuleRestfulObjects
---
 .../restfulobjects/WebModuleRestfulObjects.java      | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/core/viewers/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/WebModuleRestfulObjects.java b/core/viewers/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/WebModuleRestfulObjects.java
index 26c12c9..568b648 100644
--- a/core/viewers/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/WebModuleRestfulObjects.java
+++ b/core/viewers/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/WebModuleRestfulObjects.java
@@ -18,10 +18,12 @@
  */
 package org.apache.isis.viewer.restfulobjects;
 
+import javax.inject.Inject;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextListener;
 import javax.servlet.ServletException;
 
+import org.apache.isis.config.IsisConfiguration;
 import org.apache.isis.viewer.restfulobjects.server.auth.AuthenticationSessionStrategyBasicAuth;
 import org.apache.isis.viewer.restfulobjects.server.webapp.IsisTransactionFilterForRestfulObjects;
 import org.springframework.core.annotation.Order;
@@ -55,7 +57,14 @@ public final class WebModuleRestfulObjects implements WebModule  {
     private final static String RESTEASY_BOOTSTRAPPER = "org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap";
     private final static String RESTEASY_DISPATCHER = "RestfulObjectsRestEasyDispatcher";
 
-    String restfulPathConfigValue;
+    private final IsisConfiguration isisConfiguration;
+    private final String restfulPathConfigValue;
+
+    @Inject
+    public WebModuleRestfulObjects(final IsisConfiguration isisConfiguration) {
+        this.isisConfiguration = isisConfiguration;
+        this.restfulPathConfigValue = isisConfiguration.getViewer().getRestfulobjects().getBasePath();
+    }
 
     @Override
     public String getName() {
@@ -69,15 +78,11 @@ public final class WebModuleRestfulObjects implements WebModule  {
             return;
         }
 
-        val restfulPath = ctx.getConfiguration().getViewer().getRestfulobjects().getBasePath();
-
-        putRestfulPath(restfulPath);
-
-        this.restfulPathConfigValue = restfulPath; // store locally for reuse
+        putRestfulPath(this.restfulPathConfigValue);
 
         // register this module as a viewer
         ctx.addViewer("restfulobjects");
-        ctx.addProtectedPath(suffix(prefix(restfulPath, "/"), "/") + "*" );
+        ctx.addProtectedPath(suffix(prefix(this.restfulPathConfigValue, "/"), "/") + "*" );
     }
 
     @Override
@@ -161,5 +166,4 @@ public final class WebModuleRestfulObjects implements WebModule  {
         return restfulPathEnclosedWithSlashes;
     }
 
-
 }