Better support for annotating actions in Java flow builders.

This commit is contained in:
Erwin Vervaet
2007-05-25 13:47:55 +00:00
parent cb401461f1
commit c3565abd04
3 changed files with 30 additions and 0 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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