Package ball.lang.reflect
Class DefaultInvocationHandler
- java.lang.Object
-
- ball.lang.reflect.DefaultInvocationHandler
-
- All Implemented Interfaces:
DefaultInterfaceMethodInvocationHandler,InvocationHandler
- Direct Known Subclasses:
FacadeProxyInvocationHandler,InterceptingInvocationHandler
public class DefaultInvocationHandler extends Object implements DefaultInterfaceMethodInvocationHandler
DefaultInvocationHandlerimplementation. Seeinvoke(Object,Method,Object[]).- Author:
- Allen D. Ball
-
-
Constructor Summary
Constructors Constructor Description DefaultInvocationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Class<?>>getImplementedInterfacesOf(Class<?> type, Class<?>... types)Method available to subclass implementations to get the implemented interfaces of the argumenttypes.Class<?>getProxyClass(Class<?>... interfaces)Objectinvoke(Object proxy, Method method, Object[] argv)If themethod.isDefault(), thatMethodwill be invoked directly.ObjectnewProxyInstance(Class<?>... interfaces)
-
-
-
Constructor Detail
-
DefaultInvocationHandler
public DefaultInvocationHandler()
-
-
Method Detail
-
getProxyClass
public Class<?> getProxyClass(Class<?>... interfaces) throws IllegalArgumentException
- Parameters:
interfaces- The interfaceClasses theProxyClasswill implement.- Returns:
- The
Proxy. - Throws:
IllegalArgumentException
-
newProxyInstance
public Object newProxyInstance(Class<?>... interfaces) throws IllegalArgumentException
SeeProxy.newProxyInstance(ClassLoader,Class[],InvocationHandler). Default implementation invokesgetProxyClass(Class...).- Parameters:
interfaces- The interfaceClasses theProxyClasswill implement.- Returns:
- The
Proxy. - Throws:
IllegalArgumentException
-
invoke
public Object invoke(Object proxy, Method method, Object[] argv) throws Throwable
If themethod.isDefault(), thatMethodwill be invoked directly. If theMethodis declared inObject, it is applied tothisInvocationHandler. Otherwise, the call will be dispatched to a declaredMethodonthisInvocationHandlerwith the same name and compatible parameter types (forcing access if necessary).- Specified by:
invokein interfaceDefaultInterfaceMethodInvocationHandler- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- The proxy instance.method- TheMethod.argv- The argument array.- Returns:
- The value to return from the
Methodinvocation. - Throws:
Exception- If no compatibleMethodis found or theMethodcannot be invoked.Throwable
-
-