Package org.apache.commons.lang3.event
Class EventListenerSupport.ProxyInvocationHandler
- java.lang.Object
-
- org.apache.commons.lang3.event.EventListenerSupport.ProxyInvocationHandler
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
- Enclosing class:
- EventListenerSupport<L>
protected class EventListenerSupport.ProxyInvocationHandler extends java.lang.Object implements java.lang.reflect.InvocationHandler
An invocation handler used to dispatch the event(s) to all the listeners.
-
-
Constructor Summary
Constructors Constructor Description ProxyInvocationHandler()
Constructs a new instance.ProxyInvocationHandler(FailableConsumer<java.lang.Throwable,java.lang.IllegalAccessException> handler)
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
handle(java.lang.Throwable t)
Handles an exception thrown by a listener.java.lang.Object
invoke(java.lang.Object unusedProxy, java.lang.reflect.Method method, java.lang.Object[] args)
Propagates the method call to all registered listeners in place of the proxy listener object.
-
-
-
Constructor Detail
-
ProxyInvocationHandler
public ProxyInvocationHandler()
Constructs a new instance.
-
ProxyInvocationHandler
public ProxyInvocationHandler(FailableConsumer<java.lang.Throwable,java.lang.IllegalAccessException> handler)
Constructs a new instance.- Parameters:
handler
- Handles Throwables.- Since:
- 3.15.0
-
-
Method Detail
-
handle
protected void handle(java.lang.Throwable t) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
Handles an exception thrown by a listener. By default rethrows the given Throwable.- Parameters:
t
- The Throwable- Throws:
java.lang.IllegalAccessException
- thrown by the listener.java.lang.IllegalArgumentException
- thrown by the listener.java.lang.reflect.InvocationTargetException
- thrown by the listener.- Since:
- 3.15.0
-
invoke
public java.lang.Object invoke(java.lang.Object unusedProxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
Propagates the method call to all registered listeners in place of the proxy listener object.- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Parameters:
unusedProxy
- the proxy object representing a listener on which the invocation was called; not usedmethod
- the listener method that will be called on all of the listeners.args
- event arguments to propagate to the listeners.- Returns:
- the result of the method call
- Throws:
java.lang.reflect.InvocationTargetException
- if an error occursjava.lang.IllegalArgumentException
- if an error occursjava.lang.IllegalAccessException
- if an error occurs
-
-