use of joynr.types.Version 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));
}
});
}
use of joynr.types.Version 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()));
}
}
use of joynr.types.Version 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;
}
use of joynr.types.Version in project joynr by bmwcarit.
the class SerializationTest method serializeAndDeserializeGlobalDiscoveryEntryTest.
@Test
public void serializeAndDeserializeGlobalDiscoveryEntryTest() throws Exception {
ProviderQos qos = new ProviderQos();
String channelAddress = "channelId";
final GlobalDiscoveryEntry[] capInfos = { new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", qos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddress) };
String writeValueAsString = null;
writeValueAsString = objectMapper.writeValueAsString(capInfos);
System.err.println(writeValueAsString);
assertTrue(writeValueAsString.startsWith("[{\"_typeName\":\"joynr.types.GlobalDiscoveryEntry\""));
GlobalDiscoveryEntry[] readValue = objectMapper.readValue(writeValueAsString, GlobalDiscoveryEntry[].class);
assertArrayEquals(capInfos, readValue);
GlobalDiscoveryEntry globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", qos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddress);
writeValueAsString = objectMapper.writeValueAsString(globalDiscoveryEntry);
System.err.println(writeValueAsString);
GlobalDiscoveryEntry readCapInfo = objectMapper.readValue(writeValueAsString, GlobalDiscoveryEntry.class);
assertEquals(globalDiscoveryEntry, readCapInfo);
}
use of joynr.types.Version in project joynr by bmwcarit.
the class SerializationTest method serializeReplyWithCapabilityInfoArray.
@Test
public void serializeReplyWithCapabilityInfoArray() throws JsonGenerationException, JsonMappingException, IOException {
Object response = new GlobalDiscoveryEntry[] { new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", new ProviderQos(), System.currentTimeMillis(), expiryDateMs, publicKeyId, "channelId") };
Reply reply = new Reply(UUID.randomUUID().toString(), response);
String writeValueAsString = objectMapper.writeValueAsString(reply);
Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
GlobalDiscoveryEntry[] convertValue = objectMapper.convertValue(receivedReply.getResponse()[0], GlobalDiscoveryEntry[].class);
Assert.assertArrayEquals((GlobalDiscoveryEntry[]) reply.getResponse()[0], convertValue);
ComplexTestType2[] complexTestType2Array = { new ComplexTestType2(3, 4), new ComplexTestType2(5, 6) };
ArrayList<ComplexTestType2> customListParam2List = new ArrayList<ComplexTestType2>();
customListParam2List.add(new ComplexTestType2(3, 4));
customListParam2List.add(new ComplexTestType2(5, 6));
ComplexTestType2[] convertValue2 = objectMapper.convertValue(customListParam2List, ComplexTestType2[].class);
Assert.assertArrayEquals(complexTestType2Array, convertValue2);
}
Aggregations