Java Code Examples for org.springframework.expression.spel.ExpressionState#getEvaluationContext()

The following examples show how to use org.springframework.expression.spel.ExpressionState#getEvaluationContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConstructorReference.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Go through the list of registered constructor resolvers and see if any can find a
 * constructor that takes the specified set of arguments.
 * @param typeName the type trying to be constructed
 * @param argumentTypes the types of the arguments supplied that the constructor must take
 * @param state the current state of the expression
 * @return a reusable ConstructorExecutor that can be invoked to run the constructor or null
 * @throws SpelEvaluationException if there is a problem locating the constructor
 */
private ConstructorExecutor findExecutorForConstructor(String typeName,
		List<TypeDescriptor> argumentTypes, ExpressionState state) throws SpelEvaluationException {

	EvaluationContext evalContext = state.getEvaluationContext();
	List<ConstructorResolver> ctorResolvers = evalContext.getConstructorResolvers();
	for (ConstructorResolver ctorResolver : ctorResolvers) {
		try {
			ConstructorExecutor ce = ctorResolver.resolve(state.getEvaluationContext(), typeName, argumentTypes);
			if (ce != null) {
				return ce;
			}
		}
		catch (AccessException ex) {
			throw new SpelEvaluationException(getStartPosition(), ex,
					SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
					FormatHelper.formatMethodForMessage("", argumentTypes));
		}
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.CONSTRUCTOR_NOT_FOUND, typeName,
			FormatHelper.formatMethodForMessage("", argumentTypes));
}
 
Example 2
Source File: ConstructorReference.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Go through the list of registered constructor resolvers and see if any can find a
 * constructor that takes the specified set of arguments.
 * @param typeName the type trying to be constructed
 * @param argumentTypes the types of the arguments supplied that the constructor must take
 * @param state the current state of the expression
 * @return a reusable ConstructorExecutor that can be invoked to run the constructor or null
 * @throws SpelEvaluationException if there is a problem locating the constructor
 */
private ConstructorExecutor findExecutorForConstructor(String typeName,
		List<TypeDescriptor> argumentTypes, ExpressionState state)
		throws SpelEvaluationException {

	EvaluationContext evalContext = state.getEvaluationContext();
	List<ConstructorResolver> ctorResolvers = evalContext.getConstructorResolvers();
	if (ctorResolvers != null) {
		for (ConstructorResolver ctorResolver : ctorResolvers) {
			try {
				ConstructorExecutor ce = ctorResolver.resolve(state.getEvaluationContext(), typeName, argumentTypes);
				if (ce != null) {
					return ce;
				}
			}
			catch (AccessException ex) {
				throw new SpelEvaluationException(getStartPosition(), ex,
						SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
						FormatHelper.formatMethodForMessage("", argumentTypes));
			}
		}
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.CONSTRUCTOR_NOT_FOUND, typeName,
			FormatHelper.formatMethodForMessage("", argumentTypes));
}
 
Example 3
Source File: ConstructorReference.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Go through the list of registered constructor resolvers and see if any can find a
 * constructor that takes the specified set of arguments.
 * @param typeName the type trying to be constructed
 * @param argumentTypes the types of the arguments supplied that the constructor must take
 * @param state the current state of the expression
 * @return a reusable ConstructorExecutor that can be invoked to run the constructor or null
 * @throws SpelEvaluationException if there is a problem locating the constructor
 */
private ConstructorExecutor findExecutorForConstructor(String typeName,
		List<TypeDescriptor> argumentTypes, ExpressionState state) throws SpelEvaluationException {

	EvaluationContext evalContext = state.getEvaluationContext();
	List<ConstructorResolver> ctorResolvers = evalContext.getConstructorResolvers();
	for (ConstructorResolver ctorResolver : ctorResolvers) {
		try {
			ConstructorExecutor ce = ctorResolver.resolve(state.getEvaluationContext(), typeName, argumentTypes);
			if (ce != null) {
				return ce;
			}
		}
		catch (AccessException ex) {
			throw new SpelEvaluationException(getStartPosition(), ex,
					SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
					FormatHelper.formatMethodForMessage("", argumentTypes));
		}
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.CONSTRUCTOR_NOT_FOUND, typeName,
			FormatHelper.formatMethodForMessage("", argumentTypes));
}
 
Example 4
Source File: ConstructorReference.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Go through the list of registered constructor resolvers and see if any can find a
 * constructor that takes the specified set of arguments.
 * @param typeName the type trying to be constructed
 * @param argumentTypes the types of the arguments supplied that the constructor must take
 * @param state the current state of the expression
 * @return a reusable ConstructorExecutor that can be invoked to run the constructor or null
 * @throws SpelEvaluationException if there is a problem locating the constructor
 */
private ConstructorExecutor findExecutorForConstructor(String typeName,
		List<TypeDescriptor> argumentTypes, ExpressionState state)
		throws SpelEvaluationException {

	EvaluationContext evalContext = state.getEvaluationContext();
	List<ConstructorResolver> ctorResolvers = evalContext.getConstructorResolvers();
	if (ctorResolvers != null) {
		for (ConstructorResolver ctorResolver : ctorResolvers) {
			try {
				ConstructorExecutor ce = ctorResolver.resolve(state.getEvaluationContext(), typeName, argumentTypes);
				if (ce != null) {
					return ce;
				}
			}
			catch (AccessException ex) {
				throw new SpelEvaluationException(getStartPosition(), ex,
						SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
						FormatHelper.formatMethodForMessage("", argumentTypes));
			}
		}
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.CONSTRUCTOR_NOT_FOUND, typeName,
			FormatHelper.formatMethodForMessage("", argumentTypes));
}
 
Example 5
Source File: VariableReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws SpelEvaluationException {
	if (this.name.equals(THIS)) {
		return new ValueRef.TypedValueHolderValueRef(state.getActiveContextObject(),this);
	}
	if (this.name.equals(ROOT)) {
		return new ValueRef.TypedValueHolderValueRef(state.getRootContextObject(),this);
	}
	TypedValue result = state.lookupVariable(this.name);
	// a null value will mean either the value was null or the variable was not found
	return new VariableRef(this.name,result,state.getEvaluationContext());
}
 
Example 6
Source File: MethodReference.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example 7
Source File: VariableReference.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws SpelEvaluationException {
	if (this.name.equals(THIS)) {
		return new ValueRef.TypedValueHolderValueRef(state.getActiveContextObject(),this);
	}
	if (this.name.equals(ROOT)) {
		return new ValueRef.TypedValueHolderValueRef(state.getRootContextObject(),this);
	}
	TypedValue result = state.lookupVariable(this.name);
	// a null value will mean either the value was null or the variable was not found
	return new VariableRef(this.name,result,state.getEvaluationContext());
}
 
Example 8
Source File: MethodReference.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example 9
Source File: VariableReference.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws SpelEvaluationException {
	if (this.name.equals(THIS)) {
		return new ValueRef.TypedValueHolderValueRef(state.getActiveContextObject(),this);
	}
	if (this.name.equals(ROOT)) {
		return new ValueRef.TypedValueHolderValueRef(state.getRootContextObject(),this);
	}
	TypedValue result = state.lookupVariable(this.name);
	// a null value will mean either the value was null or the variable was not found
	return new VariableRef(this.name,result,state.getEvaluationContext());
}
 
Example 10
Source File: MethodReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example 11
Source File: VariableReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws SpelEvaluationException {
	if (this.name.equals(THIS)) {
		return new ValueRef.TypedValueHolderValueRef(state.getActiveContextObject(),this);
	}
	if (this.name.equals(ROOT)) {
		return new ValueRef.TypedValueHolderValueRef(state.getRootContextObject(),this);
	}
	TypedValue result = state.lookupVariable(this.name);
	// a null value will mean either the value was null or the variable was not found
	return new VariableRef(this.name,result,state.getEvaluationContext());
}
 
Example 12
Source File: MethodReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example 13
Source File: PropertyOrFieldReference.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	return new AccessorLValue(this, state.getActiveContextObject(), state.getEvaluationContext(),
			state.getConfiguration().isAutoGrowNullReferences());
}
 
Example 14
Source File: MethodReference.java    From java-technology-stack with MIT License 4 votes vote down vote up
public MethodValueRef(ExpressionState state, Object[] arguments) {
	this.evaluationContext = state.getEvaluationContext();
	this.value = state.getActiveContextObject().getValue();
	this.targetType = state.getActiveContextObject().getTypeDescriptor();
	this.arguments = arguments;
}
 
Example 15
Source File: MethodReference.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public MethodValueRef(ExpressionState state, Object[] arguments) {
	this.evaluationContext = state.getEvaluationContext();
	this.value = state.getActiveContextObject().getValue();
	this.targetType = state.getActiveContextObject().getTypeDescriptor();
	this.arguments = arguments;
}
 
Example 16
Source File: PropertyOrFieldReference.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	return new AccessorLValue(this, state.getActiveContextObject(), state.getEvaluationContext(),
			state.getConfiguration().isAutoGrowNullReferences());
}
 
Example 17
Source File: PropertyOrFieldReference.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	return new AccessorLValue(this, state.getActiveContextObject(), state.getEvaluationContext(),
			state.getConfiguration().isAutoGrowNullReferences());
}
 
Example 18
Source File: MethodReference.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public MethodValueRef(ExpressionState state, Object[] arguments) {
	this.evaluationContext = state.getEvaluationContext();
	this.value = state.getActiveContextObject().getValue();
	this.targetType = state.getActiveContextObject().getTypeDescriptor();
	this.arguments = arguments;
}
 
Example 19
Source File: MethodReference.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public MethodValueRef(ExpressionState state, Object[] arguments) {
	this.evaluationContext = state.getEvaluationContext();
	this.value = state.getActiveContextObject().getValue();
	this.targetType = state.getActiveContextObject().getTypeDescriptor();
	this.arguments = arguments;
}
 
Example 20
Source File: PropertyOrFieldReference.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	return new AccessorLValue(this, state.getActiveContextObject(), state.getEvaluationContext(),
			state.getConfiguration().isAutoGrowNullReferences());
}