diff --git a/spring-webflow/changelog.txt b/spring-webflow/changelog.txt index fd09bf50..4a8e4055 100644 --- a/spring-webflow/changelog.txt +++ b/spring-webflow/changelog.txt @@ -20,6 +20,8 @@ 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. +* AnnotatedAction now has a convenience putAttribute(String, Object) method. +* Added annotate(Action) method to AbstractFlowBuilder. 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/AnnotatedAction.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/AnnotatedAction.java index 2e21adfb..05114abf 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/AnnotatedAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/AnnotatedAction.java @@ -134,6 +134,18 @@ public class AnnotatedAction extends AnnotatedObject implements Action { public void setMethod(String method) { getAttributeMap().put(METHOD_ATTRIBUTE, method); } + + /** + * Set an attribute on this annotated object. + * @param attributeName the name of the attribute to set + * @param attributeValue the value of the attribute + * @return this object, to support call chaining + * @since 1.0.4 + */ + public AnnotatedAction putAttribute(String attributeName, Object attributeValue) { + getAttributeMap().put(attributeName, attributeValue); + return this; + } public Event execute(RequestContext context) throws Exception { AttributeMap originalAttributes = getAttributeMap(); 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 3a500c2b..b4ef5079 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 @@ -638,6 +638,22 @@ public abstract class AbstractFlowBuilder extends BaseFlowBuilder { protected ActionResultExposer result(String resultName, ScopeType resultScope) { return new ActionResultExposer(resultName, resultScope); } + + /** + * Wrap given action in an {@link AnnotatedAction}} to be able + * to annotate it with attributes. + * @param action the action to annotate + * @return the wrapped action + * @since 1.0.4 + */ + protected AnnotatedAction annotate(Action action) { + if (action instanceof AnnotatedAction) { + return (AnnotatedAction)action; + } + else { + return new AnnotatedAction(action); + } + } /** * Creates an annotated action decorator that instructs the specified method