use of io.joynr.provider.JoynrInterface in project joynr by bmwcarit.
the class DefaultJoynrRuntimeFactory method getInterfaceName.
private String getInterfaceName(Class<?> providerInterfaceClass) {
try {
ProvidedBy providedBy = providerInterfaceClass.getAnnotation(ProvidedBy.class);
JoynrInterface joynrInterface = providedBy.value().getAnnotation(JoynrInterface.class);
return joynrInterface.name();
} catch (SecurityException | IllegalArgumentException e) {
LOG.debug("error getting interface details", e);
return providerInterfaceClass.getSimpleName();
}
}
use of io.joynr.provider.JoynrInterface in project joynr by bmwcarit.
the class AnnotationUtilTest method testInterfaceNameAnnotation.
@Test
public void testInterfaceNameAnnotation() {
JoynrInterface joynrInterfaceAnnotations = AnnotationUtil.getAnnotation(DefaulttestProvider.class, JoynrInterface.class);
assertThat(joynrInterfaceAnnotations.name(), equalTo("tests/test"));
}
use of io.joynr.provider.JoynrInterface in project joynr by bmwcarit.
the class AnnotationUtilTest method testgetAnnotationsRecursive.
@Test
public void testgetAnnotationsRecursive() {
Collection<Annotation> annotations = AnnotationUtil.getAnnotationsRecursive(DefaulttestProvider.class);
Collection<? extends Annotation> joynrInterfaceAnnotations = Collections2.filter(annotations, Predicates.instanceOf(JoynrInterface.class));
assertThat(joynrInterfaceAnnotations, hasSize(1));
Annotation interfaceNameAnnotation = joynrInterfaceAnnotations.iterator().next();
assertThat(interfaceNameAnnotation, instanceOf(JoynrInterface.class));
assertThat(((JoynrInterface) interfaceNameAnnotation).name(), equalTo("tests/test"));
}
use of io.joynr.provider.JoynrInterface in project joynr by bmwcarit.
the class AnnotationUtilTest method testInterfaceClassAnnotation.
@Test
public void testInterfaceClassAnnotation() {
JoynrInterface interfaceClassAnnotation = AnnotationUtil.getAnnotation(DefaulttestProvider.class, JoynrInterface.class);
assertEquals(interfaceClassAnnotation.provides(), testProvider.class);
}
use of io.joynr.provider.JoynrInterface in project joynr by bmwcarit.
the class ParticipantIdKeyUtil method getProviderParticipantIdKey.
public static String getProviderParticipantIdKey(String domain, Class interfaceClass) {
Class annotatedInterface;
if (interfaceClass.getAnnotation(ProvidedBy.class) != null) {
annotatedInterface = ((ProvidedBy) interfaceClass.getAnnotation(ProvidedBy.class)).value();
} else {
annotatedInterface = interfaceClass;
}
JoynrInterface joynrInterface = (JoynrInterface) annotatedInterface.getAnnotation(JoynrInterface.class);
if (joynrInterface == null) {
throw new JoynrIllegalStateException("Class " + annotatedInterface + " not annotated with @JoynrInterface. Can't get interface name.");
}
String interfaceName = joynrInterface.name();
return getProviderParticipantIdKey(domain, interfaceName);
}
Aggregations