Search in sources :

Example 1 with JoynrInterface

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();
    }
}
Also used : ProvidedBy(io.joynr.ProvidedBy) JoynrInterface(io.joynr.provider.JoynrInterface)

Example 2 with JoynrInterface

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"));
}
Also used : JoynrInterface(io.joynr.provider.JoynrInterface) Test(org.junit.Test)

Example 3 with JoynrInterface

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"));
}
Also used : JoynrInterface(io.joynr.provider.JoynrInterface) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 4 with JoynrInterface

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);
}
Also used : JoynrInterface(io.joynr.provider.JoynrInterface) Test(org.junit.Test)

Example 5 with JoynrInterface

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);
}
Also used : ProvidedBy(io.joynr.ProvidedBy) JoynrInterface(io.joynr.provider.JoynrInterface) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException)

Aggregations

JoynrInterface (io.joynr.provider.JoynrInterface)5 Test (org.junit.Test)3 ProvidedBy (io.joynr.ProvidedBy)2 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)1 Annotation (java.lang.annotation.Annotation)1