CDI-based frameworks are expected to use invokers when they need to invoke application methods. Applications are not supposed to use invokers, as they can invoke their own methods directly.
For example, assume the following managed bean exists:
@Dependent
public class MyService {
public String hello(String name) {
return "Hello " + name + "!";
}
}
Further, assume that invoker is an invoker for the hello() method
of the MyService bean and myService is a contextual reference for the bean.
Then, to invoke the hello() method indirectly, a framework would call
invoker.invoke(myService, new Object[] { "world" })
The return value would be "Hello world!".
invoke(Object, Object[])
| Modifier and Type | Method and Description |
|---|---|
| public R | Returns: return value of the target method, ornull if the target method
is declared voidthe instance of the target bean on which the target method is to be invoked;
may only be instance, Object[] null if the target method is staticarguments to be passed to the target method; may only be arguments)null
if the target method declares no parameterInvokes the target method on the given |
| invoke | back to summary |
|---|---|
| public R invoke(T instance, Object[] arguments) throws Exception Invokes the target method on the given
| |