Search in sources :

Example 1 with ProvidedBy

use of io.joynr.ProvidedBy 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 ProvidedBy

use of io.joynr.ProvidedBy 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)

Example 3 with ProvidedBy

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

the class ServiceProviderDiscovery method findServiceProviderBeans.

@SuppressWarnings("serial")
public Set<Bean<?>> findServiceProviderBeans() {
    Set<Bean<?>> result = new HashSet<>();
    for (Bean<?> bean : beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {
    })) {
        ServiceProvider serviceProvider = bean.getBeanClass().getAnnotation(ServiceProvider.class);
        if (serviceProvider != null) {
            ProvidedBy providedBy = getProvidedByAnnotation(serviceProvider.serviceInterface());
            verifyProvidedBy(providedBy, serviceProvider.serviceInterface(), bean);
            result.add(bean);
            if (LOG.isTraceEnabled()) {
                LOG.trace(format("Bean %s is a service provider. Adding to result.", bean));
            }
        } else if (LOG.isTraceEnabled()) {
            LOG.trace(format("Ignoring bean: %s", bean));
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug(format("Found the following service provider beans:%n%s", result));
    }
    return result;
}
Also used : ProvidedBy(io.joynr.ProvidedBy) ServiceProvider(io.joynr.jeeintegration.api.ServiceProvider) Any(javax.enterprise.inject.Any) Bean(javax.enterprise.inject.spi.Bean) HashSet(java.util.HashSet)

Aggregations

ProvidedBy (io.joynr.ProvidedBy)3 JoynrInterface (io.joynr.provider.JoynrInterface)2 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)1 ServiceProvider (io.joynr.jeeintegration.api.ServiceProvider)1 HashSet (java.util.HashSet)1 Any (javax.enterprise.inject.Any)1 Bean (javax.enterprise.inject.spi.Bean)1