From a3b8d2fae7046d2430d6e186ebc7f4799babdd94 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Fri, 25 Apr 2008 01:02:09 +0000 Subject: [PATCH] addressed cyclical dependency with view package --- .../faces/webflow/JsfViewFactoryCreator.java | 2 +- ...FlowBuilderServicesBeanDefinitionParserTests.java | 2 +- .../webflow/engine/builder/ViewFactoryCreator.java | 6 +++--- .../engine/builder/model/FlowModelFlowBuilder.java | 2 +- .../mvc/builder/DelegatingFlowViewResolver.java | 6 +++--- .../builder/InternalResourceFlowViewResolver.java | 8 ++++---- .../webflow/mvc/builder/MvcViewFactoryCreator.java | 8 ++++---- .../webflow/mvc/portlet/PortletMvcViewFactory.java | 4 ++-- .../webflow/mvc/servlet/ServletMvcViewFactory.java | 4 ++-- .../webflow/mvc/view/AbstractMvcViewFactory.java | 12 ++++++------ .../webflow/mvc/view/FlowViewResolver.java | 2 +- .../webflow/test/MockViewFactoryCreator.java | 2 +- ...FlowBuilderServicesBeanDefinitionParserTests.java | 2 +- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java index 7eaee387..060ac6b4 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactoryCreator.java @@ -39,7 +39,7 @@ public class JsfViewFactoryCreator implements ViewFactoryCreator { return new JsfViewFactory(viewIdExpression, getLifecycle()); } - public String getViewNameByConvention(String viewStateId) { + public String getViewIdByConvention(String viewStateId) { return viewStateId + FACELETS_EXTENSION; } diff --git a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java index 494502ef..923a03c8 100644 --- a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java @@ -66,7 +66,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase throw new UnsupportedOperationException("Auto-generated method stub"); } - public String getViewNameByConvention(String viewStateId) { + public String getViewIdByConvention(String viewStateId) { return viewStateId; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java index 033690cc..4f46e05e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/ViewFactoryCreator.java @@ -30,12 +30,12 @@ public interface ViewFactoryCreator { /** * Create a view factory capable of creating {@link View} objects that can render the view template with the * provided identifier. - * @param viewName an expression that resolves the name of the view template + * @param viewId an expression that resolves the id of the view to render * @param expressionParser an optional expression parser to use to resolve view expressions * @param formatterRegistry an optional formatter registry to use to format text values * @return the view factory */ - public ViewFactory createViewFactory(Expression viewName, ExpressionParser expressionParser, + public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, FormatterRegistry formatterRegistry); /** @@ -43,5 +43,5 @@ public interface ViewFactoryCreator { * @param viewStateId the view state id * @return the default view id */ - public String getViewNameByConvention(String viewStateId); + public String getViewIdByConvention(String viewStateId); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java index a39b1bbd..0810b53e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java @@ -588,7 +588,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { if (endState) { return null; } else { - view = getLocalContext().getViewFactoryCreator().getViewNameByConvention(stateId); + view = getLocalContext().getViewFactoryCreator().getViewIdByConvention(stateId); Expression viewId = getLocalContext().getExpressionParser().parseExpression(view, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return createViewFactory(viewId); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java index 5d996462..748abc93 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java @@ -41,16 +41,16 @@ public class DelegatingFlowViewResolver implements FlowViewResolver { this.viewResolvers = viewResolvers; } - public View resolveView(String viewName, RequestContext context) { + public View resolveView(String viewId, RequestContext context) { for (Iterator it = viewResolvers.iterator(); it.hasNext();) { ViewResolver viewResolver = (ViewResolver) it.next(); try { - View view = viewResolver.resolveViewName(viewName, context.getExternalContext().getLocale()); + View view = viewResolver.resolveViewName(viewId, context.getExternalContext().getLocale()); if (view != null) { return view; } } catch (Exception e) { - throw new IllegalStateException("Exception resolving view with name '" + viewName + "'", e); + throw new IllegalStateException("Exception resolving view with name '" + viewId + "'", e); } } return null; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/InternalResourceFlowViewResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/InternalResourceFlowViewResolver.java index 8e539470..760c8eb5 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/InternalResourceFlowViewResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/InternalResourceFlowViewResolver.java @@ -34,15 +34,15 @@ public class InternalResourceFlowViewResolver implements FlowViewResolver { private static final boolean JSTL_PRESENT = ClassUtils.isPresent("javax.servlet.jsp.jstl.fmt.LocalizationContext"); - public View resolveView(String viewName, RequestContext context) { - if (viewName.startsWith("/")) { - return getViewInternal(viewName, context, context.getActiveFlow().getApplicationContext()); + public View resolveView(String viewId, RequestContext context) { + if (viewId.startsWith("/")) { + return getViewInternal(viewId, context, context.getActiveFlow().getApplicationContext()); } else { ApplicationContext flowContext = context.getActiveFlow().getApplicationContext(); if (flowContext == null) { throw new IllegalStateException("A Flow ApplicationContext is required to resolve Flow View Resources"); } - Resource viewResource = flowContext.getResource(viewName); + Resource viewResource = flowContext.getResource(viewId); if (!(viewResource instanceof ContextResource)) { throw new IllegalStateException( "A ContextResource is required to get relative view paths within this context"); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java index 63fd60e9..d8c078c0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java @@ -96,18 +96,18 @@ public class MvcViewFactoryCreator implements ViewFactoryCreator { this.flowViewResolver = flowViewResolver; } - public ViewFactory createViewFactory(Expression viewName, ExpressionParser expressionParser, + public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, FormatterRegistry formatterRegistry) { if (environment == null || environment == MvcEnvironment.SERVLET) { - return new ServletMvcViewFactory(viewName, flowViewResolver, expressionParser, formatterRegistry); + return new ServletMvcViewFactory(viewId, flowViewResolver, expressionParser, formatterRegistry); } else if (environment == MvcEnvironment.PORTLET) { - return new PortletMvcViewFactory(viewName, flowViewResolver, expressionParser, formatterRegistry); + return new PortletMvcViewFactory(viewId, flowViewResolver, expressionParser, formatterRegistry); } else { throw new IllegalStateException("Environment not supported " + environment); } } - public String getViewNameByConvention(String viewStateId) { + public String getViewIdByConvention(String viewStateId) { if (flowViewResolver instanceof DelegatingFlowViewResolver) { return viewStateId; } else { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcViewFactory.java index 16eedb40..f4554dae 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcViewFactory.java @@ -31,9 +31,9 @@ import org.springframework.webflow.mvc.view.FlowViewResolver; */ public class PortletMvcViewFactory extends AbstractMvcViewFactory { - public PortletMvcViewFactory(Expression viewName, FlowViewResolver viewResolver, ExpressionParser expressionParser, + public PortletMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser, FormatterRegistry formatterRegistry) { - super(viewName, viewResolver, expressionParser, formatterRegistry); + super(viewId, viewResolver, expressionParser, formatterRegistry); } protected AbstractMvcView createMvcView(View view, RequestContext context) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcViewFactory.java index cabbac54..fe895cd6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcViewFactory.java @@ -31,9 +31,9 @@ import org.springframework.webflow.mvc.view.FlowViewResolver; */ public class ServletMvcViewFactory extends AbstractMvcViewFactory { - public ServletMvcViewFactory(Expression viewName, FlowViewResolver viewResolver, ExpressionParser expressionParser, + public ServletMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser, FormatterRegistry formatterRegistry) { - super(viewName, viewResolver, expressionParser, formatterRegistry); + super(viewId, viewResolver, expressionParser, formatterRegistry); } protected AbstractMvcView createMvcView(View view, RequestContext context) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcViewFactory.java index 6ddb7926..b002139e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcViewFactory.java @@ -29,7 +29,7 @@ import org.springframework.webflow.execution.ViewFactory; */ public abstract class AbstractMvcViewFactory implements ViewFactory { - private Expression viewName; + private Expression viewId; private FlowViewResolver viewResolver; @@ -37,9 +37,9 @@ public abstract class AbstractMvcViewFactory implements ViewFactory { private FormatterRegistry formatterRegistry; - public AbstractMvcViewFactory(Expression viewName, FlowViewResolver viewResolver, - ExpressionParser expressionParser, FormatterRegistry formatterRegistry) { - this.viewName = viewName; + public AbstractMvcViewFactory(Expression viewId, FlowViewResolver viewResolver, ExpressionParser expressionParser, + FormatterRegistry formatterRegistry) { + this.viewId = viewId; this.viewResolver = viewResolver; this.expressionParser = expressionParser; this.formatterRegistry = formatterRegistry; @@ -54,8 +54,8 @@ public abstract class AbstractMvcViewFactory implements ViewFactory { } public View getView(RequestContext context) { - String viewName = (String) this.viewName.getValue(context); - org.springframework.web.servlet.View view = viewResolver.resolveView(viewName, context); + String viewId = (String) this.viewId.getValue(context); + org.springframework.web.servlet.View view = viewResolver.resolveView(viewId, context); return createMvcView(view, context); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowViewResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowViewResolver.java index f4499cb0..0b0a9a62 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowViewResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowViewResolver.java @@ -26,5 +26,5 @@ import org.springframework.webflow.execution.RequestContext; * @see ViewResolver */ public interface FlowViewResolver { - public View resolveView(String viewName, RequestContext context); + public View resolveView(String viewId, RequestContext context); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java index 23b7236f..8178cab1 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockViewFactoryCreator.java @@ -39,7 +39,7 @@ class MockViewFactoryCreator implements ViewFactoryCreator { return new MockViewFactory(viewIdExpression); } - public String getViewNameByConvention(String viewStateId) { + public String getViewIdByConvention(String viewStateId) { return viewStateId; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java index b12f60bf..cebb811e 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java @@ -49,7 +49,7 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase { throw new UnsupportedOperationException("Auto-generated method stub"); } - public String getViewNameByConvention(String viewStateId) { + public String getViewIdByConvention(String viewStateId) { return viewStateId; }