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
DefaultInvocationHandler
implementation. 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)
Object
invoke(Object proxy, Method method, Object[] argv)
If themethod.isDefault()
, thatMethod
will be invoked directly.Object
newProxyInstance(Class<?>... interfaces)
-
-
-
Constructor Detail
-
DefaultInvocationHandler
public DefaultInvocationHandler()
-
-
Method Detail
-
getProxyClass
public Class<?> getProxyClass(Class<?>... interfaces) throws IllegalArgumentException
- Parameters:
interfaces
- The interfaceClass
es theProxy
Class
will 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 interfaceClass
es theProxy
Class
will implement.- Returns:
- The
Proxy
. - Throws:
IllegalArgumentException
-
invoke
public Object invoke(Object proxy, Method method, Object[] argv) throws Throwable
If themethod.isDefault()
, thatMethod
will be invoked directly. If theMethod
is declared inObject
, it is applied tothis
InvocationHandler
. Otherwise, the call will be dispatched to a declaredMethod
onthis
InvocationHandler
with the same name and compatible parameter types (forcing access if necessary).- Specified by:
invoke
in interfaceDefaultInterfaceMethodInvocationHandler
- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- The proxy instance.method
- TheMethod
.argv
- The argument array.- Returns:
- The value to return from the
Method
invocation. - Throws:
Exception
- If no compatibleMethod
is found or theMethod
cannot be invoked.Throwable
-
-