From c90f331b1cac0b2ae5f4ba9814d94f7ca468ca07 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 24 Apr 2008 13:52:02 +0000 Subject: [PATCH] cachSeconds = 0 --- .../webflow/mvc/servlet/FlowController.java | 27 ++++++++++++------- .../mvc/servlet/FlowHandlerAdapter.java | 7 +++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java index 697c05e7..4437728a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java @@ -21,10 +21,13 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.js.mvc.servlet.AjaxHandler; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.AbstractController; +import org.springframework.web.servlet.mvc.Controller; import org.springframework.webflow.context.servlet.FlowUrlHandler; import org.springframework.webflow.executor.FlowExecutor; @@ -36,24 +39,24 @@ import org.springframework.webflow.executor.FlowExecutor; * * @author Keith Donald */ -public class FlowController extends AbstractController implements InitializingBean { +public class FlowController implements Controller, ApplicationContextAware, InitializingBean { private FlowHandlerAdapter flowHandlerAdapter = new FlowHandlerAdapter(); private Map flowHandlers = new HashMap(); - private boolean customFlowHandlerAdapter; + private boolean customFlowHandlerAdapterSet; /** * Creates a new flow controller. * @see #setFlowExecutor(FlowExecutor) * @see #setFlowUrlHandler(FlowUrlHandler) * @see #setAjaxHandler(AjaxHandler) + * @see #setFlowHandlerAdapter(FlowHandlerAdapter) * @see #afterPropertiesSet() */ public FlowController() { - // turn caching off for flows by default - setCacheSeconds(0); + } /** @@ -132,20 +135,24 @@ public class FlowController extends AbstractController implements InitializingBe */ public void setFlowHandlerAdapter(FlowHandlerAdapter flowHandlerAdapter) { this.flowHandlerAdapter = flowHandlerAdapter; - customFlowHandlerAdapter = true; + customFlowHandlerAdapterSet = true; + } + + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + if (!customFlowHandlerAdapterSet) { + flowHandlerAdapter.setApplicationContext(applicationContext); + } } public void afterPropertiesSet() throws Exception { - if (!customFlowHandlerAdapter) { - flowHandlerAdapter.setApplicationContext(getApplicationContext()); + if (!customFlowHandlerAdapterSet) { flowHandlerAdapter.afterPropertiesSet(); } } // subclassing hooks - protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) - throws Exception { + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { FlowHandler handler = getFlowHandler(request); return flowHandlerAdapter.handle(request, response, handler); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java index 357d2ab1..9cc21e74 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java @@ -30,9 +30,9 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.js.mvc.servlet.AjaxHandler; import org.springframework.js.mvc.servlet.SpringJavascriptAjaxHandler; import org.springframework.util.Assert; -import org.springframework.web.context.support.WebApplicationObjectSupport; import org.springframework.web.servlet.HandlerAdapter; import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.support.WebContentGenerator; import org.springframework.webflow.context.servlet.DefaultFlowUrlHandler; import org.springframework.webflow.context.servlet.FlowUrlHandler; import org.springframework.webflow.context.servlet.ServletExternalContext; @@ -51,7 +51,7 @@ import org.springframework.webflow.executor.FlowExecutor; * * @author Keith Donald */ -public class FlowHandlerAdapter extends WebApplicationObjectSupport implements HandlerAdapter, InitializingBean { +public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAdapter, InitializingBean { private static final Log logger = LogFactory.getLog(FlowHandlerAdapter.class); @@ -86,6 +86,8 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H * @see #afterPropertiesSet() */ public FlowHandlerAdapter() { + // prevent caching of flow pages by default + setCacheSeconds(0); } /** @@ -149,6 +151,7 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + checkAndPrepare(request, response, false); FlowHandler flowHandler = (FlowHandler) handler; String flowExecutionKey = flowUrlHandler.getFlowExecutionKey(request); if (flowExecutionKey != null) {