Search in sources :

Example 1 with MethodSignature

use of io.joynr.proxy.MethodSignature in project joynr by bmwcarit.

the class RequestInterpreter method invokeMethod.

public Object invokeMethod(RequestCaller requestCaller, OneWayRequest request) {
    // A method is identified by its defining request caller, its name and the types of its arguments
    MethodSignature methodSignature = new MethodSignature(requestCaller, request.getMethodName(), request.getParamDatatypes());
    ensureMethodMetaInformationPresent(requestCaller, request, methodSignature);
    Method method = methodSignatureToMethodMap.get(methodSignature);
    Object[] params = null;
    try {
        if (method.getParameterTypes().length > 0) {
            // method with parameters
            params = request.getParams();
        }
        joynrMessageScope.activate();
        setContext(requestCaller, request);
        logger.trace("invoke provider method {}({})", method.getName(), params == null ? "" : params);
        return requestCaller.invoke(method, params);
    } catch (IllegalAccessException e) {
        logger.error("RequestInterpreter: Received an RPC invocation for a non public method {}", request);
        JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
        throw new MethodInvocationException(e, new Version(joynrVersion.major(), joynrVersion.minor()));
    } catch (InvocationTargetException e) {
        logger.debug("invokeMethod error", e);
        Throwable cause = e.getCause();
        logger.error("RequestInterpreter: Could not perform an RPC invocation: {}", cause == null ? e.toString() : cause.getMessage());
        throw new ProviderRuntimeException(cause == null ? e.toString() : cause.toString());
    } finally {
        requestCaller.removeContext();
        joynrMessageScope.deactivate();
    }
}
Also used : MethodSignature(io.joynr.proxy.MethodSignature) JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version) Method(java.lang.reflect.Method) MethodInvocationException(joynr.exceptions.MethodInvocationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

JoynrVersion (io.joynr.JoynrVersion)1 MethodSignature (io.joynr.proxy.MethodSignature)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 MethodInvocationException (joynr.exceptions.MethodInvocationException)1 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)1 Version (joynr.types.Version)1