blob: 08dd4cd124b1b32eb0213e5be8599026af554e10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package org.apache.tuscany.core.injection;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Performs an invocation on a method of a given instance
*
* @version $Rev$ $Date$
*/
public class MethodEventInvoker<T> implements EventInvoker<T> {
private final Method method;
//----------------------------------
// Constructors
//----------------------------------
/**
* Intantiates an invoker for the given method
*/
public MethodEventInvoker(Method method) {
this.method = method;
}
//----------------------------------
// Methods
//----------------------------------
public void invokeEvent(T instance) throws ObjectCallbackException {
try {
method.invoke(instance, (Object[]) null);
} catch (IllegalAccessException e) {
throw new AssertionError("Method is not accessible [" + method + "]");
} catch (InvocationTargetException e) {
throw new ObjectCallbackException("Exception thrown by callback method [" + method + "]", e);
}
}
}
|