001/* 002 * Copyright 2002-2013 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.expression; 018 019/** 020 * MethodExecutors are built by the resolvers and can be cached by the infrastructure to 021 * repeat an operation quickly without going back to the resolvers. For example, the 022 * particular method to run on an object may be discovered by the reflection method 023 * resolver - it will then build a MethodExecutor that executes that method and the 024 * MethodExecutor can be reused without needing to go back to the resolver to discover 025 * the method again. 026 * 027 * <p>They can become stale, and in that case should throw an AccessException: 028 * This will cause the infrastructure to go back to the resolvers to ask for a new one. 029 * 030 * @author Andy Clement 031 * @since 3.0 032 */ 033public interface MethodExecutor { 034 035 /** 036 * Execute a command using the specified arguments, and using the specified expression state. 037 * @param context the evaluation context in which the command is being executed 038 * @param target the target object of the call - null for static methods 039 * @param arguments the arguments to the executor, should match (in terms of number 040 * and type) whatever the command will need to run 041 * @return the value returned from execution 042 * @throws AccessException if there is a problem executing the command or the 043 * MethodExecutor is no longer valid 044 */ 045 TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException; 046 047}