From cb401461f14ce6f01c2b4c8036e2a1cc2b14774f Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Mon, 14 May 2007 13:23:25 +0000 Subject: [PATCH] Added name(String, Action) method to AbstractFlowBuilder for convenient creation of named actions. --- spring-webflow/changelog.txt | 1 + .../engine/builder/AbstractFlowBuilder.java | 38 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/spring-webflow/changelog.txt b/spring-webflow/changelog.txt index 292a9e72..fd09bf50 100644 --- a/spring-webflow/changelog.txt +++ b/spring-webflow/changelog.txt @@ -19,6 +19,7 @@ Package org.springframework.webflow.conversation Package org.springframework.webflow.engine * Added invoke(String, Action) method to AbstractFlowBuilder. * Added initBuilder() hook method to AbstractFlowBuilder. +* Added name(String, Action) method to AbstractFlowBuilder for convenient creation of named actions. Package org.springframework.webflow.executor * JSF integration code now manages flow execution locks properly in exceptional situations and when the diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/AbstractFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/AbstractFlowBuilder.java index 9326581e..3a500c2b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/AbstractFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/AbstractFlowBuilder.java @@ -22,7 +22,6 @@ import org.springframework.binding.mapping.Mapping; import org.springframework.binding.mapping.MappingBuilder; import org.springframework.binding.method.MethodSignature; import org.springframework.core.style.ToStringCreator; -import org.springframework.util.Assert; import org.springframework.webflow.action.AbstractBeanInvokingAction; import org.springframework.webflow.action.ActionResultExposer; import org.springframework.webflow.action.BeanInvokingActionFactory; @@ -653,12 +652,17 @@ public abstract class AbstractFlowBuilder extends BaseFlowBuilder { * used by the multi action to instruct it with what method to invoke * @since 1.0.4 */ - protected AnnotatedAction invoke(String methodName, Action multiAction) throws FlowArtifactLookupException { - Assert.isInstanceOf(MultiAction.class, multiAction, - "The action passed into invoke() should be a MultiAction"); - AnnotatedAction action = new AnnotatedAction(multiAction); - action.setMethod(methodName); - return action; + protected AnnotatedAction invoke(String methodName, Action multiAction) { + AnnotatedAction annotatedAction; + if (multiAction instanceof AnnotatedAction) { + // already wrapped in an AnnotatedAction + annotatedAction = (AnnotatedAction)multiAction; + } + else { + annotatedAction = new AnnotatedAction(multiAction); + } + annotatedAction.setMethod(methodName); + return annotatedAction; } /** @@ -676,6 +680,26 @@ public abstract class AbstractFlowBuilder extends BaseFlowBuilder { protected AnnotatedAction invoke(String methodName, MultiAction multiAction) throws FlowArtifactLookupException { return invoke(methodName, (Action)multiAction); } + + /** + * Creates an annotated action decorator that makes the given action + * an named action. + * @param name the action name + * @param action the action to name + * @return the annotated named action + */ + protected AnnotatedAction name(String name, Action action) { + AnnotatedAction annotatedAction; + if (action instanceof AnnotatedAction) { + // already wrapped in an AnnotatedAction + annotatedAction = (AnnotatedAction)action; + } + else { + annotatedAction = new AnnotatedAction(action); + } + annotatedAction.setName(name); + return annotatedAction; + } /** * Request that the attribute mapper with the specified name be used to map