cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r371423 - in /cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks: Block.java BlockContext.java BlockManager.java BlocksContext.java
Date Sun, 22 Jan 2006 23:43:49 GMT
Author: danielf
Date: Sun Jan 22 15:43:44 2006
New Revision: 371423

URL: http://svn.apache.org/viewcvs?rev=371423&view=rev
Log:
Changed the Block interface so that it makes the BlockContext available instead of the block
Servlet. The end goal is to get rid of the Block interface and remove the knowledge about
the BlockManager from the BlockContext. The Blockmanager should just be a container it shouldn't
be responsible for any servlet processing.

Modified:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/Block.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksContext.java

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/Block.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/Block.java?rev=371423&r1=371422&r2=371423&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/Block.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/Block.java
Sun Jan 22 15:43:44 2006
@@ -16,6 +16,7 @@
 package org.apache.cocoon.blocks;
 
 import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
 
 import org.apache.avalon.framework.service.ServiceManager;
 
@@ -34,5 +35,5 @@
      */
     public ServiceManager getServiceManager();
     
-    public Servlet getBlockServlet();
+    public ServletContext getBlockContext();
 }

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java?rev=371423&r1=371422&r2=371423&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
Sun Jan 22 15:43:44 2006
@@ -41,12 +41,11 @@
 
     private Hashtable attributes;
     private BlockWiring wiring;
-    private Block block;
+    private Servlet servlet;
     
-    public BlockContext(ServletContext parentContext, BlockWiring wiring, Block block) {
+    public BlockContext(ServletContext parentContext, BlockWiring wiring) {
         super(parentContext);
         this.wiring = wiring;
-        this.block = block;
     }
 
     /*
@@ -229,6 +228,14 @@
     }
 
     // Block specific methods
+    
+    /**
+     * Set the servlet of the block
+     * @param servlet
+     */
+    public void setServlet(Servlet servlet) {
+        this.servlet = servlet;
+    }
 
     /**
      * Takes the scheme specific part of a block URI (the scheme is the
@@ -363,16 +370,13 @@
      */
     private class PathDispatcher implements RequestDispatcher {
         
-        Servlet servlet;
-
         // Ignores path, as the assumed only servlet within the block is
         // implicitly mounted on '/*'
         private PathDispatcher(String path) {
-            this.servlet = BlockContext.this.block.getBlockServlet();
         }
 
         private boolean exists() {
-            return this.servlet != null;
+            return BlockContext.this.servlet != null;
         }
 
         /* (non-Javadoc)
@@ -380,7 +384,7 @@
          */
         public void forward(ServletRequest request, ServletResponse response)
         throws ServletException, IOException {
-            this.servlet.service(request, response);
+            BlockContext.this.servlet.service(request, response);
         }
 
         /* (non-Javadoc)

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java?rev=371423&r1=371422&r2=371423&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
Sun Jan 22 15:43:44 2006
@@ -20,6 +20,7 @@
 
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -90,7 +91,7 @@
         getLogger().debug("Initializing new Block Manager: " + this.blockWiring.getId());
 
         this.blockContext =
-            new BlockContext(this.getServletContext(), this.blockWiring, this);
+            new BlockContext(this.getServletContext(), this.blockWiring);
         ServletConfig blockServletConfig =
             new ServletConfigurationWrapper(this.getServletConfig(), this.blockContext);
 
@@ -133,7 +134,9 @@
             } catch (Exception e) {
                 throw new ServletException(e);
             }
-            this.blockServlet.init(blockServletConfig);            
+            this.blockServlet.init(blockServletConfig);
+            
+            this.blockContext.setServlet(this.blockServlet);
         }
     }
     
@@ -172,7 +175,7 @@
         }
     }
 
-    public Servlet getBlockServlet() {
-        return this.blockServlet;
+    public ServletContext getBlockContext() {
+        return this.blockContext;
     }
 }

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksContext.java?rev=371423&r1=371422&r2=371423&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksContext.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksContext.java
Sun Jan 22 15:43:44 2006
@@ -73,7 +73,7 @@
         ServletContext context = null;
         block = BlocksContext.this.blocks.getBlock(name);
         if (block != null)
-            context = block.getBlockServlet().getServletConfig().getServletContext();
+            context = block.getBlockContext();
 
         return context;
     }
@@ -88,9 +88,12 @@
             this.block = BlocksContext.this.blocks.getBlock(name);
         }
 
-        public void forward(ServletRequest request, ServletResponse response)
+        public void forward(ServletRequest request0, ServletResponse response)
                 throws ServletException, IOException {
-            this.block.getBlockServlet().service(request, response);
+            HttpServletRequest request = (HttpServletRequest) request0;
+            RequestDispatcher dispatcher =
+                this.block.getBlockContext().getRequestDispatcher(request.getPathInfo());
+            dispatcher.forward(request, response);
         }
 
         public void include(ServletRequest request, ServletResponse response)



Mime
View raw message