incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1340026 - /incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java
Date Fri, 18 May 2012 08:20:49 GMT
Author: kevin
Date: Fri May 18 08:20:49 2012
New Revision: 1340026

URL: http://svn.apache.org/viewvc?rev=1340026&view=rev
Log:
ISIS-226: Exposed "getWebController" so that users can provide their own controller and install
their own HTML UI components.

Modified:
    incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java

Modified: incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java?rev=1340026&r1=1340025&r2=1340026&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java
(original)
+++ incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/servlet/ControllerServlet.java
Fri May 18 08:20:49 2012
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRes
 import org.apache.log4j.Logger;
 
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.viewer.html.PathBuilder;
 import org.apache.isis.viewer.html.component.Page;
 import org.apache.isis.viewer.html.context.Context;
 import org.apache.isis.viewer.html.request.Request;
@@ -51,32 +52,44 @@ public class ControllerServlet extends A
     @Override
     public void init(final ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
-        encoding = getConfiguration().getString(HtmlServletConstants.ENCODING_KEY, HtmlServletConstants.ENCODING_DEFAULT);
+        encoding =
+            getConfiguration().getString(HtmlServletConstants.ENCODING_KEY, HtmlServletConstants.ENCODING_DEFAULT);
+
+        controller = getWebController(getPathBuilder());
 
-        controller = new WebController(getPathBuilder());
-        
         final boolean debugEnabled = getConfiguration().getBoolean(HtmlServletConstants.DEBUG_KEY);
         controller.setDebug(debugEnabled);
-        
+
         controller.init();
     }
 
+    // Don't remove this - It allows other implementations of HtmlViewer to replace the WebController
+    protected WebController getWebController(PathBuilder pathBuilder) {
+        if (controller == null) {
+            controller = new WebController(getPathBuilder());
+        }
+        return controller;
+    }
+
     // //////////////////////////////////////////////////////////////////
     // doGet, doPost
     // //////////////////////////////////////////////////////////////////
 
     @Override
-    protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
+    protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
+        throws ServletException, IOException {
         request.setCharacterEncoding(encoding);
         processRequest(request, response);
     }
 
     @Override
-    protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
+    protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException,
+        IOException {
         processRequest(request, response);
     }
 
-    private void processRequest(final HttpServletRequest request, final HttpServletResponse
response) throws ServletException, IOException {
+    private void processRequest(final HttpServletRequest request, final HttpServletResponse
response)
+        throws ServletException, IOException {
         LOG.info("request: " + request.getServletPath() + "?" + request.getQueryString());
 
         final Request req = new ServletRequest(request);
@@ -106,7 +119,8 @@ public class ControllerServlet extends A
         return context;
     }
 
-    private void processRequest(final HttpServletRequest request, final HttpServletResponse
response, final Request req, final Context context) throws IOException, ServletException {
+    private void processRequest(final HttpServletRequest request, final HttpServletResponse
response,
+        final Request req, final Context context) throws IOException, ServletException {
         response.setContentType("text/html");
 
         // no need to check if logged in; the IsisSessionFilter would



Mime
View raw message