You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2006/03/02 00:36:04 UTC
svn commit: r382199 -
/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
Author: danielf
Date: Wed Mar 1 15:36:03 2006
New Revision: 382199
URL: http://svn.apache.org/viewcvs?rev=382199&view=rev
Log:
Made the processing logic more coherent by only using context, not a mix between context and dispatcher.
Modified:
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
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=382199&r1=382198&r2=382199&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 Wed Mar 1 15:36:03 2006
@@ -32,6 +32,7 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
import org.apache.cocoon.blocks.util.ServletContextWrapper;
@@ -318,30 +319,28 @@
private String blockName;
private boolean superCall = false;
- private RequestDispatcher dispatcher;
+ private ServletContext context;
private NamedDispatcher(String blockName) {
this.blockName = blockName;
this.superCall = Block.SUPER.equals(this.blockName);
- String blockId =
- (String) BlockContext.this.connections.get(this.blockName);
- if (blockId != null) {
- // Call to a named block that exists in the current context
- this.dispatcher = BlockContext.super.servletContext.getNamedDispatcher(blockId);
- } else {
+ // Call to a named block that exists in the current context
+ this.context = BlockContext.this.getNamedContext(this.blockName);
+ if (this.context == null) {
// If there is a super block, the connection might
// be defined there instead.
- ServletContext superContext = BlockContext.this.getNamedContext(Block.SUPER);
+ BlockContext superContext =
+ (BlockContext) BlockContext.this.getNamedContext(Block.SUPER);
if (superContext != null) {
- this.dispatcher = superContext.getNamedDispatcher(blockName);
+ this.context = superContext.getNamedContext(this.blockName);
this.superCall = true;
}
}
}
private boolean exists() {
- return this.dispatcher != null;
+ return this.context != null;
}
/*
@@ -355,16 +354,16 @@
// Call to named block
BlockContext.this.log("Enter processing in block " + this.blockName);
- if (this.dispatcher != null) {
+ RequestDispatcher dispatcher =
+ this.context.getRequestDispatcher(((HttpServletRequest)request).getPathInfo());
+ if (dispatcher != null) {
if (!this.superCall) {
try {
// It is important to set the current block each time
// a new block is entered, this is used for the block
// protocol
- ServletContext context = BlockContext.this.getNamedContext(this.blockName);
- BlockCallStack.enterBlock(context);
-
- this.dispatcher.forward(request, response);
+ BlockCallStack.enterBlock(this.context);
+ dispatcher.forward(request, response);
} finally {
BlockCallStack.leaveBlock();
}
@@ -373,14 +372,13 @@
// the called block to get polymorphic calls resolved
// in the right way. Therefore no new current block is
// set.
- this.dispatcher.forward(request, response);
+ dispatcher.forward(request, response);
}
} else {
// Cannot happen
throw new IllegalStateException();
}
- BlockContext.this.log("Leaving processing in block "
- + this.blockName);
+ BlockContext.this.log("Leaving processing in block " + this.blockName);
}
/*