copyright on action package, better javadoc

removed obsolete types
This commit is contained in:
Keith Donald
2008-04-13 02:36:34 +00:00
parent f60ecee6fd
commit 118c8d5e9b
23 changed files with 107 additions and 339 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,144 +0,0 @@
/*
* Copyright 2004-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.convert.service.DefaultConversionService;
import org.springframework.binding.method.MethodInvoker;
import org.springframework.binding.method.MethodSignature;
import org.springframework.util.Assert;
import org.springframework.webflow.execution.Action;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
/**
* Base class for actions that delegate to methods on beans (POJOs - Plain Old Java Objects). Acts as an adapter that
* adapts an {@link Object} method to the Spring Web Flow {@link Action} contract.
* <p>
* Subclasses are required to implement the {@link #getBean(RequestContext)} method, returning the bean on which a
* method should be invoked.
*
* @see BeanInvokingActionFactory
*
* @author Keith Donald
*/
public abstract class AbstractBeanInvokingAction extends AbstractAction {
/**
* The signature of the method to invoke on the target bean, capable of resolving the method when used with a
* {@link MethodInvoker}. Required.
*/
private MethodSignature methodSignature;
/**
* The method invoker that performs the action-&gt;bean method binding, accepting a {@link MethodSignature} and
* {@link #getBean(RequestContext) target bean} instance.
*/
private MethodInvoker methodInvoker = new MethodInvoker();
/**
* The specification (configuration) for how bean method return values should be exposed to an executing flow that
* invokes this action.
*/
private ActionResultExposer methodResultExposer;
/**
* The strategy that adapts bean method return values to Event objects.
*/
private ResultEventFactory resultEventFactory = new SuccessEventFactory();
/**
* Creates a new bean invoking action.
* @param methodSignature the signature of the method to invoke
*/
protected AbstractBeanInvokingAction(MethodSignature methodSignature) {
Assert.notNull(methodSignature, "The signature of the target method to invoke is required");
this.methodSignature = methodSignature;
}
/**
* Returns the signature of the method to invoke on the target bean.
*/
public MethodSignature getMethodSignature() {
return methodSignature;
}
/**
* Returns the configuration for how bean method return values should be exposed to an executing flow that invokes
* this action.
*/
public ActionResultExposer getMethodResultExposer() {
return methodResultExposer;
}
/**
* Configures how bean method return values should be exposed to an executing flow that invokes this action. This is
* optional. By default the bean method return values do not get exposed to the executing flow.
*/
public void setMethodResultExposer(ActionResultExposer methodResultExposer) {
this.methodResultExposer = methodResultExposer;
}
/**
* Returns the event adaption strategy used by this action.
*/
protected ResultEventFactory getResultEventFactory() {
return resultEventFactory;
}
/**
* Set the bean return value-&gt;event adaption strategy. Defaults to {@link SuccessEventFactory}, so all bean
* method return values will be interpreted as "success".
*/
public void setResultEventFactory(ResultEventFactory resultEventFactory) {
this.resultEventFactory = resultEventFactory;
}
/**
* Set the conversion service to perform type conversion of event parameters to method arguments as neccessary.
* Defaults to {@link DefaultConversionService}.
*/
public void setConversionService(ConversionService conversionService) {
methodInvoker.setConversionService(conversionService);
}
/**
* Returns the bean method invoker helper.
*/
protected MethodInvoker getMethodInvoker() {
return methodInvoker;
}
protected Event doExecute(RequestContext context) throws Exception {
Object bean = getBean(context);
Object returnValue = getMethodInvoker().invoke(methodSignature, bean, context);
if (methodResultExposer != null) {
methodResultExposer.exposeResult(returnValue, context);
}
return resultEventFactory.createResultEvent(bean, returnValue, context);
}
// subclassing hooks
/**
* Retrieves the bean to invoke a method on. Subclasses need to implement this method.
* @param context the flow execution request context
* @return the bean on which to invoke methods
* @throws Exception when the bean cannot be retreived
*/
protected abstract Object getBean(RequestContext context) throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import org.springframework.webflow.execution.RequestContext;
* attribute in a configured scope.
*
* @see EvaluateAction
* @see AbstractBeanInvokingAction
*
* @author Keith Donald
*/

View File

@@ -1,82 +0,0 @@
/*
* Copyright 2004-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.method.MethodKey;
import org.springframework.binding.method.MethodSignature;
import org.springframework.webflow.core.collection.AttributeMap;
import org.springframework.webflow.execution.Action;
/**
* A helper factory for {@link Action} instances that invoke methods on beans managed in a Spring bean factory.
* <p>
* This factory encapsulates the logic required to take an arbitrary <code>java.lang.Object</code> from a Spring bean
* factory and adapt a method on it to the {@link Action} interface. If the bean you want to use is not managed in a
* Spring bean factory, consider subclassing {@link AbstractBeanInvokingAction} and using it directly.
*
* @see AbstractBeanInvokingAction
*
* @author Keith Donald
*/
public class BeanInvokingActionFactory {
/**
* Determines which result event factory should be used for each bean invoking action created by this factory.
*/
private ResultEventFactorySelector resultEventFactorySelector = new ResultEventFactorySelector();
/**
* Returns the strategy for calculating the result event factory to configure for each bean invoking action created
* by this factory.
*/
public ResultEventFactorySelector getResultEventFactorySelector() {
return resultEventFactorySelector;
}
/**
* Sets the strategy to calculate the result event factory to configure for each bean invoking action created by
* this factory.
*/
public void setResultEventFactorySelector(ResultEventFactorySelector resultEventFactorySelector) {
this.resultEventFactorySelector = resultEventFactorySelector;
}
/**
* Factory method that creates a bean invoking action, an adapter that adapts a method on an abitrary {@link Object}
* to the {@link Action} interface. This method is an atomic operation that returns a fully initialized Action. It
* encapsulates the selection of the action implementation as well as the action assembly.
* @param beanId the id of the bean to be adapted to an Action instance
* @param beanFactory the bean factory where the bean is managed
* @param methodSignature the method to invoke on the bean when the action is executed (required)
* @param resultExposer the specification for what to do with the method return value (optional)
* @param conversionService the conversion service to be used to convert method parameters (optional)
* @param attributes attributes that may be used to affect the bean invoking action's construction
* @return the fully configured bean invoking action instance
*/
public Action createBeanInvokingAction(String beanId, BeanFactory beanFactory, MethodSignature methodSignature,
ActionResultExposer resultExposer, ConversionService conversionService, AttributeMap attributes) {
Object bean = beanFactory.getBean(beanId);
AbstractBeanInvokingAction action = new LocalBeanInvokingAction(methodSignature, bean);
action.setMethodResultExposer(resultExposer);
MethodKey methodKey = new MethodKey(bean.getClass(), methodSignature.getMethodName(), methodSignature
.getParameters().getTypesArray());
action.setResultEventFactory(resultEventFactorySelector.forMethod(methodKey.getMethod()));
action.setConversionService(conversionService);
return action;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import org.springframework.binding.expression.Expression;
@@ -5,10 +20,19 @@ import org.springframework.util.Assert;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
/**
* An action that sends an external redirect when executed.
*
* @author Keith Donald
*/
public class ExternalRedirectAction extends AbstractAction {
private Expression resourceUri;
/**
* Creates a new external redirect action
* @param resourceUri an expression for the resource Uri to redirect to
*/
public ExternalRedirectAction(Expression resourceUri) {
Assert.notNull(resourceUri, "The URI of the resource to redirect to is required");
this.resourceUri = resourceUri;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import org.springframework.binding.expression.Expression;
@@ -7,9 +22,19 @@ import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
/**
* An action that sends a flow definition redirect when executed.
*
* @author Keith Donald
*/
public class FlowDefinitionRedirectAction extends AbstractAction {
private Expression expression;
/**
* Creates a new flow definition redirect action.
* @param expression a encoded flow redirect expression
*/
public FlowDefinitionRedirectAction(Expression expression) {
Assert.notNull(expression, "The flow definition redirect expression is required");
this.expression = expression;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +35,8 @@ import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.ScopeType;
/**
* Multi-action that implements common logic dealing with input forms. This class leverages the Spring Web data binding
* code to do binding and validation.
* Multi-action that implements common logic dealing with input forms. This class uses the Spring Web data binding code
* to do binding and validation.
* <p>
* Several action execution methods are provided:
* <ul>
@@ -79,22 +79,17 @@ import org.springframework.webflow.execution.ScopeType;
* <li> If business processing is ok, continue to a view state to display the success view. </li>
* </ol>
* <p>
* Here is an example implementation of such a compact form flow:
* Here is an example implementation of such a form flow:
*
* <pre>
* &lt;view-state id=&quot;displayCriteria&quot; view=&quot;searchCriteria&quot;&gt;
* &lt;render-actions&gt;
* &lt;action bean=&quot;formAction&quot; method=&quot;setupForm&quot;/&gt;
* &lt;/render-actions&gt;
* &lt;view-state id=&quot;displayCriteria&quot;&gt;
* &lt;on-render&gt;
* &lt;evaluate expression=&quot;formAction.setupForm&quot;/&gt;
* &lt;/on-render&gt;
* &lt;transition on=&quot;search&quot; to=&quot;executeSearch&quot;&gt;
* &lt;action bean=&quot;formAction&quot; method=&quot;bindAndValidate&quot;/&gt;
* &lt;evaluate expression=&quot;formAction.bindAndValidate&quot;/&gt;
* &lt;/transition&gt;
* &lt;/view-state&gt;
*
* &lt;action-state id=&quot;executeSearch&quot;&gt;
* &lt;action bean=&quot;formAction&quot; method=&quot;executeSearch&quot;/&gt;
* &lt;transition on=&quot;success&quot; to=&quot;displayResults&quot;/&gt;
* &lt;/action-state&gt;
* </pre>
*
* <p>
@@ -137,11 +132,11 @@ import org.springframework.webflow.execution.ScopeType;
* ... and then invoke it like this:
*
* <pre>
* &lt;view-state id=&quot;displayCriteria&quot; view=&quot;searchCriteria&quot;&gt;
* &lt;render-actions&gt;
* &lt;action bean=&quot;searchFormAction&quot; method=&quot;setupForm&quot;/&gt;
* &lt;action bean=&quot;searchFormAction&quot; method=&quot;setupReferenceData&quot;/&gt;
* &lt;/render-actions&gt;
* &lt;view-state id=&quot;displayCriteria&quot;&gt;
* &lt;on-render&gt;
* &lt;evaluate expression=&quot;formAction.setupForm&quot;/&gt;
* &lt;evaluate expression=&quot;formAction.setupRefernenceData&quot;/&gt;
* &lt;/on-render&gt;
* ...
* &lt;/view-state&gt;
* </pre>
@@ -166,9 +161,9 @@ import org.springframework.webflow.execution.ScopeType;
* For instance, having a action definition like this:
*
* <pre>
* &lt;action bean=&quot;searchFormAction&quot; method=&quot;bindAndValidate&quot;&gt;
* &lt;evaluate expression=&quot;formAction.bindAndValidate&quot;&gt;
* &lt;attribute name=&quot;validatorMethod&quot; value=&quot;validateSearchCriteria&quot;/&gt;
* &lt;/action&gt;
* &lt;/evaluate&gt;
* </pre>
*
* Would result in the <tt>public void validateSearchCriteria(SearchCriteria, Errors)</tt> method of the registered

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,58 +0,0 @@
/*
* Copyright 2004-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import java.io.Serializable;
import org.springframework.binding.method.MethodSignature;
import org.springframework.util.Assert;
import org.springframework.webflow.execution.RequestContext;
/**
* Thin action proxy that delegates to a method on an arbitrary bean. The bean instance is managed locally by this
* Action in an instance variable.
*
* @author Keith Donald
*/
class LocalBeanInvokingAction extends AbstractBeanInvokingAction implements Serializable {
/**
* The target bean (any POJO) to invoke.
*/
private Object bean;
/**
* Creates a bean invoking action that invokes a method on the specified bean. The bean may be a proxy providing a
* layer of indirection if necessary.
* @param bean the bean to invoke
*/
public LocalBeanInvokingAction(MethodSignature methodSignature, Object bean) {
super(methodSignature);
Assert.notNull(bean, "The bean to invoke by this action cannot be null");
this.bean = bean;
}
/**
* Returns the target bean to invoke methods on.
*/
public Object getBean() {
return bean;
}
protected Object getBean(RequestContext context) throws Exception {
return getBean();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.springframework.webflow.execution.RequestContext;
*
* <pre>
* &lt;action-state id=&quot;search&quot;&gt;
* &lt;action bean=&quot;searchAction&quot;/&gt;
* &lt;evaluate expression=&quot;searchAction.executeSearch&quot;/&gt;
* &lt;transition on=&quot;success&quot; to=&quot;results&quot;/&gt;
* &lt;/action-state&gt;
* </pre>
@@ -46,19 +46,10 @@ import org.springframework.webflow.execution.RequestContext;
* public Event search(RequestContext context) throws Exception;
* </pre>
*
* Alternatively (and typically recommended), you may explictly specify the method name:
*
* <pre>
* &lt;action-state id=&quot;search&quot;&gt;
* &lt;action bean=&quot;searchAction&quot; method=&quot;executeSearch&quot;/&gt;
* &lt;transition on=&quot;success&quot; to=&quot;results&quot;/&gt;
* &lt;/action-state&gt;
* </pre>
*
* <p>
* A typical use of the MultiAction is to centralize all command logic for a flow in one place. Another common use is to
* centralize form setup and submit logic in one place, or CRUD (create/read/update/delete) operations for a single
* domain object in one place.
* One use of the MultiAction is to centralize all command logic for a flow in one place. Another use is to centralize
* form setup and submit logic in one place, or CRUD (create/read/update/delete) operations for a single domain object
* in one place.
*
* @see MultiAction.MethodResolver
* @see org.springframework.webflow.action.DefaultMultiActionMethodResolver

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
* Helper that selects the {@link ResultEventFactory} to use for a particular result object.
*
* @see EvaluateAction
* @see BeanInvokingActionFactory
*
* @author Keith Donald
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007 the original author or authors.
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2004-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.webflow.action;
import org.springframework.webflow.execution.Event;
@@ -9,8 +24,13 @@ import org.springframework.webflow.execution.ViewFactory;
* @author Keith Donald
*/
public class ViewFactoryActionAdapter extends AbstractAction {
private ViewFactory viewFactory;
/**
* Creates a new view factory action adapter
* @param viewFactory the view factory to adapt to the Action interface.
*/
public ViewFactoryActionAdapter(ViewFactory viewFactory) {
this.viewFactory = viewFactory;
}

View File

@@ -8,7 +8,6 @@ import org.springframework.binding.format.FormatterRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.util.Assert;
import org.springframework.webflow.action.BeanInvokingActionFactory;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.engine.State;
import org.springframework.webflow.engine.builder.FlowArtifactFactory;
@@ -19,9 +18,9 @@ import org.springframework.webflow.engine.builder.ViewFactoryCreator;
* A simple holder for configuring the services used by flow builders. These services are exposed to a builder in a
* {@link FlowBuilderContext}.
*
* Note this class does not attempt to default any service implementations other than the {@link FlowArtifactFactory}
* and {@link BeanInvokingActionFactory}, which are more like builder helper objects than services. It is expected
* clients inject non-null references to concrete service implementations appropriate for their environment.
* Note this class does not attempt to default any service implementations other than the {@link FlowArtifactFactory},
* which is more like builder helper objects than a service. It is expected clients inject non-null references to
* concrete service implementations appropriate for their environment.
*
* @see FlowBuilderContextImpl
*