1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package java.lang.reflect;
19
20/**
21 * Implementors of this interface dispatch methods invoked on proxy instances.
22 *
23 * @see Proxy
24 */
25public interface InvocationHandler {
26
27    /**
28     * Handles the method which was originally invoked on the proxy instance. A
29     * typical usage pattern follows below:
30     *
31     * <pre>
32     * public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
33     *     //do some processing before the method invocation
34     *
35     *     //invoke the method
36     *     Object result = method.invoke(proxy, args);
37     *
38     *     //do some processing after the method invocation
39     *     return result;
40     * }</pre>
41     *
42     * @param proxy
43     *            the proxy instance on which the method was invoked
44     * @param method
45     *            the method invoked on the proxy instance
46     * @param args
47     *            an array of objects containing the parameters passed to the
48     *            method, or {@code null} if no arguments are expected.
49     *            Primitive types are boxed.
50     *
51     * @return the result of executing the method. Primitive types are boxed.
52     *
53     * @throws Throwable
54     *             the exception to throw from the invoked method on the proxy.
55     *             The exception must match one of the declared exception types
56     *             of the invoked method or any unchecked exception type. If not
57     *             then an {@code UndeclaredThrowableException} is thrown
58     */
59    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable;
60}
61