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

The following examples show how to use org.springframework.expression.spel.ExpressionState#pushActiveContextObject() . 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: MethodReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Object[] getArguments(ExpressionState state) {
	Object[] arguments = new Object[getChildCount()];
	for (int i = 0; i < arguments.length; i++) {
		// Make the root object the active context again for evaluating the parameter expressions
		try {
			state.pushActiveContextObject(state.getScopeRootContextObject());
			arguments[i] = this.children[i].getValueInternal(state).getValue();
		}
		finally {
			state.popActiveContextObject();
		}
	}
	return arguments;
}
 
Example 2
Source File: CompoundExpression.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	if (getChildCount() == 1) {
		return this.children[0].getValueRef(state);
	}

	SpelNodeImpl nextNode = this.children[0];
	try {
		TypedValue result = nextNode.getValueInternal(state);
		int cc = getChildCount();
		for (int i = 1; i < cc - 1; i++) {
			try {
				state.pushActiveContextObject(result);
				nextNode = this.children[i];
				result = nextNode.getValueInternal(state);
			}
			finally {
				state.popActiveContextObject();
			}
		}
		try {
			state.pushActiveContextObject(result);
			nextNode = this.children[cc - 1];
			return nextNode.getValueRef(state);
		}
		finally {
			state.popActiveContextObject();
		}
	}
	catch (SpelEvaluationException ex) {
		// Correct the position for the error before re-throwing
		ex.setPosition(nextNode.getStartPosition());
		throw ex;
	}
}
 
Example 3
Source File: MethodReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Object[] getArguments(ExpressionState state) {
	Object[] arguments = new Object[getChildCount()];
	for (int i = 0; i < arguments.length; i++) {
		// Make the root object the active context again for evaluating the parameter expressions
		try {
			state.pushActiveContextObject(state.getScopeRootContextObject());
			arguments[i] = this.children[i].getValueInternal(state).getValue();
		}
		finally {
			state.popActiveContextObject();
		}
	}
	return arguments;
}
 
Example 4
Source File: CompoundExpression.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	if (getChildCount() == 1) {
		return this.children[0].getValueRef(state);
	}

	SpelNodeImpl nextNode = this.children[0];
	try {
		TypedValue result = nextNode.getValueInternal(state);
		int cc = getChildCount();
		for (int i = 1; i < cc - 1; i++) {
			try {
				state.pushActiveContextObject(result);
				nextNode = this.children[i];
				result = nextNode.getValueInternal(state);
			}
			finally {
				state.popActiveContextObject();
			}
		}
		try {
			state.pushActiveContextObject(result);
			nextNode = this.children[cc - 1];
			return nextNode.getValueRef(state);
		}
		finally {
			state.popActiveContextObject();
		}
	}
	catch (SpelEvaluationException ex) {
		// Correct the position for the error before re-throwing
		ex.setPosition(nextNode.getStartPosition());
		throw ex;
	}
}
 
Example 5
Source File: MethodReference.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private Object[] getArguments(ExpressionState state) {
	Object[] arguments = new Object[getChildCount()];
	for (int i = 0; i < arguments.length; i++) {
		// Make the root object the active context again for evaluating the parameter expressions
		try {
			state.pushActiveContextObject(state.getScopeRootContextObject());
			arguments[i] = this.children[i].getValueInternal(state).getValue();
		}
		finally {
			state.popActiveContextObject();
		}
	}
	return arguments;
}
 
Example 6
Source File: CompoundExpression.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	if (getChildCount() == 1) {
		return this.children[0].getValueRef(state);
	}

	SpelNodeImpl nextNode = this.children[0];
	try {
		TypedValue result = nextNode.getValueInternal(state);
		int cc = getChildCount();
		for (int i = 1; i < cc - 1; i++) {
			try {
				state.pushActiveContextObject(result);
				nextNode = this.children[i];
				result = nextNode.getValueInternal(state);
			}
			finally {
				state.popActiveContextObject();
			}
		}
		try {
			state.pushActiveContextObject(result);
			nextNode = this.children[cc - 1];
			return nextNode.getValueRef(state);
		}
		finally {
			state.popActiveContextObject();
		}
	}
	catch (SpelEvaluationException ex) {
		// Correct the position for the error before re-throwing
		ex.setPosition(nextNode.getStartPosition());
		throw ex;
	}
}
 
Example 7
Source File: MethodReference.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Object[] getArguments(ExpressionState state) {
	Object[] arguments = new Object[getChildCount()];
	for (int i = 0; i < arguments.length; i++) {
		// Make the root object the active context again for evaluating the parameter expressions
		try {
			state.pushActiveContextObject(state.getScopeRootContextObject());
			arguments[i] = this.children[i].getValueInternal(state).getValue();
		}
		finally {
			state.popActiveContextObject();
		}
	}
	return arguments;
}
 
Example 8
Source File: CompoundExpression.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException {
	if (getChildCount() == 1) {
		return this.children[0].getValueRef(state);
	}

	SpelNodeImpl nextNode = this.children[0];
	try {
		TypedValue result = nextNode.getValueInternal(state);
		int cc = getChildCount();
		for (int i = 1; i < cc - 1; i++) {
			try {
				state.pushActiveContextObject(result);
				nextNode = this.children[i];
				result = nextNode.getValueInternal(state);
			}
			finally {
				state.popActiveContextObject();
			}
		}
		try {
			state.pushActiveContextObject(result);
			nextNode = this.children[cc - 1];
			return nextNode.getValueRef(state);
		}
		finally {
			state.popActiveContextObject();
		}
	}
	catch (SpelEvaluationException ex) {
		// Correct the position for the error before re-throwing
		ex.setPosition(nextNode.getStartPosition());
		throw ex;
	}
}