Search in sources :

Example 1 with MethodInvoker

use of org.platformlayer.ops.reflection.MethodInvoker in project platformlayer by platformlayer.

the class OperationInvoker method invoke.

public void invoke(Object controller) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    final BindingScope scope = BindingScope.get();
    Method method = findTargetMethod(controller, scope);
    if (method == null) {
        throw new IllegalStateException("Cannot find handler for operation on " + controller.getClass());
    }
    MethodInvoker invoker = invokerProvider.get();
    if (scope != null) {
        invoker.addProvider(new Function<Class<?>, Object>() {

            @Override
            public Object apply(Class<?> clazz) {
                return scope.getInstance(clazz);
            }
        });
    }
    invoker.invokeMethod(controller, method);
}
Also used : Method(java.lang.reflect.Method) BindingScope(org.platformlayer.ops.BindingScope) MethodInvoker(org.platformlayer.ops.reflection.MethodInvoker)

Aggregations

Method (java.lang.reflect.Method)1 BindingScope (org.platformlayer.ops.BindingScope)1 MethodInvoker (org.platformlayer.ops.reflection.MethodInvoker)1