webflow.core.expression -> webflow.expression
This commit is contained in:
@@ -17,6 +17,8 @@ package org.springframework.webflow.action;
|
||||
|
||||
import org.springframework.binding.expression.Expression;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.webflow.engine.ActionExecutor;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
@@ -71,9 +73,13 @@ public class EvaluateAction extends AbstractAction {
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
Object result = expression.getValue(context);
|
||||
if (evaluationResultExposer != null) {
|
||||
evaluationResultExposer.exposeResult(result, context);
|
||||
if (result instanceof Action) {
|
||||
return ActionExecutor.execute((Action) result, context);
|
||||
} else {
|
||||
if (evaluationResultExposer != null) {
|
||||
evaluationResultExposer.exposeResult(result, context);
|
||||
}
|
||||
return resultEventFactorySelector.forResult(result).createResultEvent(this, result, context);
|
||||
}
|
||||
return resultEventFactorySelector.forResult(result).createResultEvent(this, result, context);
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* Custom EL resolver that searches the current request context for variables to resolve. The search algorithm looks in
|
||||
* request scope first, then flash scope, then flow scope, then conversation scope.
|
||||
*
|
||||
* Suitable for use along side other variable resolvers to support EL binding expressions like "#{bean.property}" where
|
||||
* "bean" could be a property in any supported scope.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class ScopeSearchingELResolver extends ELResolver {
|
||||
|
||||
public Class getCommonPropertyType(ELContext elContext, Object base) {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Iterator getFeatureDescriptors(ELContext elContext, Object base) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class getType(ELContext elContext, Object base, Object property) {
|
||||
RequestContext requestContext;
|
||||
if (base != null && base instanceof RequestContext) {
|
||||
requestContext = (RequestContext) base;
|
||||
} else if (base == null) {
|
||||
requestContext = RequestContextHolder.getRequestContext();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (requestContext == null) {
|
||||
return null;
|
||||
}
|
||||
// flow execution is active: try request/flash/flow/conversation scope
|
||||
String name = property.toString();
|
||||
if (requestContext.getRequestScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getRequestScope().get(name).getClass();
|
||||
} else if (requestContext.getFlashScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlashScope().get(name).getClass();
|
||||
} else if (requestContext.getFlowScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlowScope().get(name).getClass();
|
||||
} else if (requestContext.getConversationScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getConversationScope().get(name).getClass();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getValue(ELContext elContext, Object base, Object property) {
|
||||
RequestContext requestContext;
|
||||
if (base != null && base instanceof RequestContext) {
|
||||
requestContext = (RequestContext) base;
|
||||
} else if (base == null) {
|
||||
requestContext = RequestContextHolder.getRequestContext();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (requestContext == null) {
|
||||
return null;
|
||||
}
|
||||
String name = property.toString();
|
||||
if (requestContext.getRequestScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getRequestScope().get(name);
|
||||
} else if (requestContext.getFlashScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlashScope().get(name);
|
||||
} else if (requestContext.getFlowScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlowScope().get(name);
|
||||
} else if (requestContext.getConversationScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getConversationScope().get(name);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext elContext, Object base, Object property) {
|
||||
RequestContext requestContext;
|
||||
if (base != null && base instanceof RequestContext) {
|
||||
requestContext = (RequestContext) base;
|
||||
} else if (base == null) {
|
||||
requestContext = RequestContextHolder.getRequestContext();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (requestContext == null) {
|
||||
return false;
|
||||
}
|
||||
// flow execution is active: try request/flash/flow/conversation scope
|
||||
String name = property.toString();
|
||||
if (requestContext.getRequestScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getFlashScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getFlowScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getConversationScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(ELContext elContext, Object base, Object property, Object value) {
|
||||
RequestContext requestContext;
|
||||
if (base != null && base instanceof RequestContext) {
|
||||
requestContext = (RequestContext) base;
|
||||
} else if (base == null) {
|
||||
requestContext = RequestContextHolder.getRequestContext();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (requestContext == null) {
|
||||
return;
|
||||
}
|
||||
// flow execution is active: try request/flash/flow/conversation scope
|
||||
String name = property.toString();
|
||||
if (requestContext.getRequestScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getRequestScope().put(name, value);
|
||||
} else if (requestContext.getFlashScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getFlashScope().put(name, value);
|
||||
} else if (requestContext.getFlowScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getFlowScope().put(name, value);
|
||||
} else if (requestContext.getConversationScope().contains(name)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getConversationScope().put(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,13 @@ import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.webflow.action.BeanInvokingActionFactory;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.engine.Flow;
|
||||
import org.springframework.webflow.engine.State;
|
||||
import org.springframework.webflow.engine.builder.FlowArtifactFactory;
|
||||
import org.springframework.webflow.engine.builder.FlowBuilderContext;
|
||||
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
|
||||
/**
|
||||
* A simple holder for services needed by a flow builder. These services are typically exposed via a Flow Builder's
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.core.expression;
|
||||
package org.springframework.webflow.expression;
|
||||
|
||||
import org.springframework.binding.expression.Expression;
|
||||
import org.springframework.binding.expression.ExpressionParser;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.core.expression;
|
||||
package org.springframework.webflow.expression;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
package org.springframework.webflow.expression.el;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -6,10 +6,8 @@ import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
|
||||
import org.springframework.webflow.engine.ActionExecutor;
|
||||
import org.springframework.webflow.engine.AnnotatedAction;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
public class ActionExecutingELResolver extends ELResolver {
|
||||
|
||||
@@ -34,13 +32,9 @@ public class ActionExecutingELResolver extends ELResolver {
|
||||
if (base instanceof Action) {
|
||||
Action action = (Action) base;
|
||||
elContext.setPropertyResolved(true);
|
||||
if (property == null) {
|
||||
return ActionExecutor.execute(action, RequestContextHolder.getRequestContext());
|
||||
} else {
|
||||
AnnotatedAction decorator = new AnnotatedAction(action);
|
||||
decorator.setMethod((String) property);
|
||||
return ActionExecutor.execute(decorator, RequestContextHolder.getRequestContext());
|
||||
}
|
||||
AnnotatedAction decorator = new AnnotatedAction(action);
|
||||
decorator.setMethod((String) property);
|
||||
return decorator;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
package org.springframework.webflow.expression.el;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package org.springframework.webflow.expression.el;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* Custom EL resolver that searches the current request context for variables to resolve. The search algorithm looks in
|
||||
* request scope first, then flash scope, then flow scope, then conversation scope.
|
||||
*
|
||||
* Suitable for use along side other variable resolvers to support EL binding expressions like "#{bean.property}" where
|
||||
* "bean" could be a property in any supported scope.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class ScopeSearchingELResolver extends ELResolver {
|
||||
|
||||
public Class getCommonPropertyType(ELContext elContext, Object base) {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Iterator getFeatureDescriptors(ELContext elContext, Object base) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class getType(ELContext elContext, Object base, Object property) {
|
||||
if (base != null) {
|
||||
return null;
|
||||
}
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
String attributeName = property.toString();
|
||||
if (requestContext.getRequestScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getRequestScope().get(attributeName).getClass();
|
||||
} else if (requestContext.getFlashScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlashScope().get(attributeName).getClass();
|
||||
} else if (requestContext.getFlowScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlowScope().get(attributeName).getClass();
|
||||
} else if (requestContext.getConversationScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getConversationScope().get(attributeName).getClass();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getValue(ELContext elContext, Object base, Object property) {
|
||||
if (base != null) {
|
||||
return null;
|
||||
}
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
String attributeName = property.toString();
|
||||
if (requestContext.getRequestScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getRequestScope().get(attributeName);
|
||||
} else if (requestContext.getFlashScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlashScope().get(attributeName);
|
||||
} else if (requestContext.getFlowScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getFlowScope().get(attributeName);
|
||||
} else if (requestContext.getConversationScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return requestContext.getConversationScope().get(attributeName);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext elContext, Object base, Object property) {
|
||||
if (base != null) {
|
||||
return false;
|
||||
}
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
String attributeName = property.toString();
|
||||
if (requestContext.getRequestScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getFlashScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getFlowScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else if (requestContext.getConversationScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(ELContext elContext, Object base, Object property, Object value) {
|
||||
if (base != null) {
|
||||
return;
|
||||
}
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
String attributeName = property.toString();
|
||||
if (requestContext.getRequestScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getRequestScope().put(attributeName, value);
|
||||
} else if (requestContext.getFlashScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getFlashScope().put(attributeName, value);
|
||||
} else if (requestContext.getFlowScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getFlowScope().put(attributeName, value);
|
||||
} else if (requestContext.getConversationScope().contains(attributeName)) {
|
||||
elContext.setPropertyResolved(true);
|
||||
requestContext.getConversationScope().put(attributeName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
package org.springframework.webflow.expression.el;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.access.el.SpringBeanELResolver;
|
||||
import org.springframework.beans.factory.support.StaticListableBeanFactory;
|
||||
import org.springframework.web.jsf.el.SpringBeanFacesELResolver;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* EL resolver for Spring Beans accessible to the flow's local bean factory.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
* TODO - Extend SpringBeanELResolver when Spring 2.5.2 is available.
|
||||
*/
|
||||
public class SpringBeanWebFlowELResolver extends SpringBeanFacesELResolver {
|
||||
public class SpringBeanWebFlowELResolver extends SpringBeanELResolver {
|
||||
|
||||
private static final BeanFactory EMPTY_BEAN_FACTORY = new StaticListableBeanFactory();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
package org.springframework.webflow.expression.el;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -4,9 +4,9 @@ import org.springframework.beans.factory.support.StaticListableBeanFactory;
|
||||
import org.springframework.binding.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.webflow.action.BeanInvokingActionFactory;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.engine.builder.FlowArtifactFactory;
|
||||
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
|
||||
class FlowBuilderSystemDefaults {
|
||||
private FlowBuilderServices defaultServices;
|
||||
|
||||
@@ -19,7 +19,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.binding.mapping.DefaultAttributeMapper;
|
||||
import org.springframework.binding.mapping.MappingBuilder;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.test.MockRequestContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,11 +9,11 @@ import org.springframework.binding.convert.support.DefaultConversionService;
|
||||
import org.springframework.binding.expression.Expression;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.webflow.core.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
|
||||
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.ViewFactory;
|
||||
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.mvc.MvcViewFactoryCreator;
|
||||
|
||||
public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
|
||||
|
||||
@@ -23,13 +23,13 @@ import org.springframework.binding.mapping.DefaultAttributeMapper;
|
||||
import org.springframework.binding.mapping.Mapping;
|
||||
import org.springframework.binding.mapping.MappingBuilder;
|
||||
import org.springframework.webflow.core.collection.MutableAttributeMap;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.engine.support.DefaultTargetStateResolver;
|
||||
import org.springframework.webflow.engine.support.EventIdTransitionCriteria;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.FlowExecutionException;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.test.MockFlowExecutionContext;
|
||||
import org.springframework.webflow.test.MockFlowSession;
|
||||
import org.springframework.webflow.test.MockRequestControlContext;
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.binding.mapping.MappingBuilder;
|
||||
import org.springframework.webflow.TestException;
|
||||
import org.springframework.webflow.action.TestMultiAction;
|
||||
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.engine.support.DefaultTargetStateResolver;
|
||||
import org.springframework.webflow.engine.support.EventIdTransitionCriteria;
|
||||
import org.springframework.webflow.engine.support.TransitionExecutingFlowExecutionExceptionHandler;
|
||||
@@ -32,6 +31,7 @@ import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.FlowExecutionException;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.TestAction;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.test.MockRequestControlContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.core.expression;
|
||||
package org.springframework.webflow.expression;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.binding.expression.ExpressionParser;
|
||||
import org.springframework.webflow.core.expression.DefaultExpressionParserFactory;
|
||||
import org.springframework.webflow.expression.DefaultExpressionParserFactory;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultExpressionParserFactory}.
|
||||
Reference in New Issue
Block a user