Java Code Examples for org.springframework.expression.spel.support.StandardEvaluationContext#registerMethodFilter()

The following examples show how to use org.springframework.expression.spel.support.StandardEvaluationContext#registerMethodFilter() . 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: EvaluationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Verifies behavior requested in SPR-9621.
 */
@Test
public void customMethodFilter() {
	StandardEvaluationContext context = new StandardEvaluationContext();

	// Register a custom MethodResolver...
	List<MethodResolver> customResolvers = new ArrayList<>();
	customResolvers.add(new CustomMethodResolver());
	context.setMethodResolvers(customResolvers);

	// or simply...
	// context.setMethodResolvers(new ArrayList<MethodResolver>());

	// Register a custom MethodFilter...
	MethodFilter filter = new CustomMethodFilter();
	try {
		context.registerMethodFilter(String.class, filter);
		fail("should have failed");
	}
	catch (IllegalStateException ise) {
		assertEquals(
				"Method filter cannot be set as the reflective method resolver is not in use",
				ise.getMessage());
	}
}
 
Example 2
Source File: EvaluationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Verifies behavior requested in SPR-9621.
 */
@Test
public void customMethodFilter() {
	StandardEvaluationContext context = new StandardEvaluationContext();

	// Register a custom MethodResolver...
	List<MethodResolver> customResolvers = new ArrayList<>();
	customResolvers.add(new CustomMethodResolver());
	context.setMethodResolvers(customResolvers);

	// or simply...
	// context.setMethodResolvers(new ArrayList<MethodResolver>());

	// Register a custom MethodFilter...
	MethodFilter filter = new CustomMethodFilter();
	try {
		context.registerMethodFilter(String.class, filter);
		fail("should have failed");
	}
	catch (IllegalStateException ise) {
		assertEquals(
				"Method filter cannot be set as the reflective method resolver is not in use",
				ise.getMessage());
	}
}
 
Example 3
Source File: EvaluationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies behavior requested in SPR-9621.
 */
@Test
public void customMethodFilter() throws Exception {
	StandardEvaluationContext context = new StandardEvaluationContext();

	// Register a custom MethodResolver...
	List<MethodResolver> customResolvers = new ArrayList<MethodResolver>();
	customResolvers.add(new CustomMethodResolver());
	context.setMethodResolvers(customResolvers);

	// or simply...
	// context.setMethodResolvers(new ArrayList<MethodResolver>());

	// Register a custom MethodFilter...
	MethodFilter filter = new CustomMethodFilter();
	try {
		context.registerMethodFilter(String.class, filter);
		fail("should have failed");
	} catch (IllegalStateException ise) {
		assertEquals(
				"Method filter cannot be set as the reflective method resolver is not in use",
				ise.getMessage());
	}
}