org.springframework.expression.MethodFilter Java Examples
The following examples show how to use
org.springframework.expression.MethodFilter.
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 |
/** * 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 |
/** * 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 |
/** * 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()); } }
Example #4
Source File: ReflectiveMethodResolver.java From spring-analysis-note with MIT License | 5 votes |
/** * Register a filter for methods on the given type. * @param type the type to filter on * @param filter the corresponding method filter, * or {@code null} to clear any filter for the given type */ public void registerMethodFilter(Class<?> type, @Nullable MethodFilter filter) { if (this.filters == null) { this.filters = new HashMap<>(); } if (filter != null) { this.filters.put(type, filter); } else { this.filters.remove(type); } }
Example #5
Source File: StandardEvaluationContext.java From spring-analysis-note with MIT License | 5 votes |
/** * Register a {@code MethodFilter} which will be called during method resolution * for the specified type. * <p>The {@code MethodFilter} may remove methods and/or sort the methods which * will then be used by SpEL as the candidates to look through for a match. * @param type the type for which the filter should be called * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use */ public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException { initMethodResolvers(); ReflectiveMethodResolver resolver = this.reflectiveMethodResolver; if (resolver == null) { throw new IllegalStateException( "Method filter cannot be set as the reflective method resolver is not in use"); } resolver.registerMethodFilter(type, filter); }
Example #6
Source File: ReflectiveMethodResolver.java From java-technology-stack with MIT License | 5 votes |
/** * Register a filter for methods on the given type. * @param type the type to filter on * @param filter the corresponding method filter, * or {@code null} to clear any filter for the given type */ public void registerMethodFilter(Class<?> type, @Nullable MethodFilter filter) { if (this.filters == null) { this.filters = new HashMap<>(); } if (filter != null) { this.filters.put(type, filter); } else { this.filters.remove(type); } }
Example #7
Source File: StandardEvaluationContext.java From java-technology-stack with MIT License | 5 votes |
/** * Register a {@code MethodFilter} which will be called during method resolution * for the specified type. * <p>The {@code MethodFilter} may remove methods and/or sort the methods which * will then be used by SpEL as the candidates to look through for a match. * @param type the type for which the filter should be called * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use */ public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException { initMethodResolvers(); ReflectiveMethodResolver resolver = this.reflectiveMethodResolver; if (resolver == null) { throw new IllegalStateException( "Method filter cannot be set as the reflective method resolver is not in use"); } resolver.registerMethodFilter(type, filter); }
Example #8
Source File: ReflectiveMethodResolver.java From lams with GNU General Public License v2.0 | 5 votes |
public void registerMethodFilter(Class<?> type, MethodFilter filter) { if (this.filters == null) { this.filters = new HashMap<Class<?>, MethodFilter>(); } if (filter != null) { this.filters.put(type, filter); } else { this.filters.remove(type); } }
Example #9
Source File: StandardEvaluationContext.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Register a {@code MethodFilter} which will be called during method resolution * for the specified type. * <p>The {@code MethodFilter} may remove methods and/or sort the methods which * will then be used by SpEL as the candidates to look through for a match. * @param type the type for which the filter should be called * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use */ public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException { ensureMethodResolversInitialized(); if (this.reflectiveMethodResolver != null) { this.reflectiveMethodResolver.registerMethodFilter(type, filter); } else { throw new IllegalStateException("Method filter cannot be set as the reflective method resolver is not in use"); } }
Example #10
Source File: ReflectiveMethodResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
public void registerMethodFilter(Class<?> type, MethodFilter filter) { if (this.filters == null) { this.filters = new HashMap<Class<?>, MethodFilter>(); } if (filter != null) { this.filters.put(type, filter); } else { this.filters.remove(type); } }
Example #11
Source File: StandardEvaluationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Register a {@code MethodFilter} which will be called during method resolution * for the specified type. * <p>The {@code MethodFilter} may remove methods and/or sort the methods which * will then be used by SpEL as the candidates to look through for a match. * @param type the type for which the filter should be called * @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type * @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use */ public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException { ensureMethodResolversInitialized(); if (this.reflectiveMethodResolver != null) { this.reflectiveMethodResolver.registerMethodFilter(type, filter); } else { throw new IllegalStateException("Method filter cannot be set as the reflective method resolver is not in use"); } }