Search in sources :

Example 6 with JoynrVersion

use of io.joynr.JoynrVersion in project joynr by bmwcarit.

the class RequestInterpreter method execute.

public void execute(final ProviderCallback<Reply> callback, RequestCaller requestCaller, final Request request) {
    Promise<? extends AbstractDeferred> promise;
    logger.debug("execute request on provider: {}", request);
    try {
        promise = (Promise<?>) invokeMethod(requestCaller, request);
    } catch (MethodInvocationException | ProviderRuntimeException e) {
        logger.warn("execute request on provider failed with exception: {}, request: {}", e, request);
        callback.onFailure(e);
        return;
    } catch (Exception e) {
        JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
        MethodInvocationException methodInvocationException = new MethodInvocationException(e, new Version(joynrVersion.major(), joynrVersion.minor()));
        logger.warn("execute request on provider failed with exception: {}, request: {}", methodInvocationException, request);
        callback.onFailure(methodInvocationException);
        return;
    }
    promise.then(new PromiseListener() {

        @Override
        public void onRejection(JoynrException error) {
            logger.debug("execute request on provider onRejection: {}, request: {}", error, request);
            callback.onFailure(error);
        }

        @Override
        public void onFulfillment(Object... values) {
            logger.debug("execute request on provider onFulfillment: {}, request: {}", values, request);
            callback.onSuccess(createReply(request, values));
        }
    });
}
Also used : JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version) PromiseListener(io.joynr.provider.PromiseListener) JoynrException(io.joynr.exceptions.JoynrException) MethodInvocationException(joynr.exceptions.MethodInvocationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) MethodInvocationException(joynr.exceptions.MethodInvocationException) JoynrException(io.joynr.exceptions.JoynrException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 7 with JoynrVersion

use of io.joynr.JoynrVersion in project joynr by bmwcarit.

the class RequestInterpreter method ensureMethodMetaInformationPresent.

private void ensureMethodMetaInformationPresent(RequestCaller requestCaller, OneWayRequest request, MethodSignature methodSignature) {
    try {
        if (!methodSignatureToMethodMap.containsKey(methodSignature)) {
            Method method;
            method = ReflectionUtils.findMethodByParamTypeNames(methodSignature.getRequestCaller().getProxy().getClass(), methodSignature.getMethodName(), methodSignature.getParameterTypeNames());
            methodSignatureToMethodMap.putIfAbsent(methodSignature, method);
        }
    } catch (NoSuchMethodException e) {
        logger.error("RequestInterpreter: Received an RPC invocation for a non existing method" + request, e);
        JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
        throw new MethodInvocationException(e.toString(), new Version(joynrVersion.major(), joynrVersion.minor()));
    }
}
Also used : JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version) Method(java.lang.reflect.Method) MethodInvocationException(joynr.exceptions.MethodInvocationException)

Example 8 with JoynrVersion

use of io.joynr.JoynrVersion in project joynr by bmwcarit.

the class AnnotationUtilTest method testMinorVersionAnnotation.

@Test
public void testMinorVersionAnnotation() {
    JoynrVersion joynrVersionnAnnotation = AnnotationUtil.getAnnotation(DefaulttestProvider.class, JoynrVersion.class);
    assertThat(joynrVersionnAnnotation.minor(), equalTo(11));
}
Also used : JoynrVersion(io.joynr.JoynrVersion) Test(org.junit.Test)

Example 9 with JoynrVersion

use of io.joynr.JoynrVersion in project joynr by bmwcarit.

the class AnnotationUtilTest method testMajorVersionAnnotation.

@Test
public void testMajorVersionAnnotation() {
    JoynrVersion joynrVersionnAnnotation = AnnotationUtil.getAnnotation(DefaulttestProvider.class, JoynrVersion.class);
    assertThat(joynrVersionnAnnotation.major(), equalTo(47));
}
Also used : JoynrVersion(io.joynr.JoynrVersion) Test(org.junit.Test)

Example 10 with JoynrVersion

use of io.joynr.JoynrVersion in project joynr by bmwcarit.

the class VersionUtil method getVersionFromAnnotation.

public static Version getVersionFromAnnotation(Class<?> annotatedClass) {
    JoynrVersion versionAnnotation = AnnotationUtil.getAnnotation(annotatedClass, JoynrVersion.class);
    if (versionAnnotation == null) {
        throw new IllegalStateException("No @JoynrVersion found on " + annotatedClass);
    }
    Version version = new Version(versionAnnotation.major(), versionAnnotation.minor());
    logger.trace("Created version {} for interface class {}", version, annotatedClass);
    return version;
}
Also used : JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version)

Aggregations

JoynrVersion (io.joynr.JoynrVersion)10 Version (joynr.types.Version)6 Test (org.junit.Test)5 MethodInvocationException (joynr.exceptions.MethodInvocationException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)3 Method (java.lang.reflect.Method)2 RequestCaller (io.joynr.dispatching.RequestCaller)1 JoynrException (io.joynr.exceptions.JoynrException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 PromiseListener (io.joynr.provider.PromiseListener)1 Callback (io.joynr.proxy.Callback)1 MethodSignature (io.joynr.proxy.MethodSignature)1 Nonnull (javax.annotation.Nonnull)1 DiscoveryEntry (joynr.types.DiscoveryEntry)1