Search in sources :

Example 1 with ProviderQosFactory

use of io.joynr.jeeintegration.api.ProviderQosFactory in project joynr by bmwcarit.

the class JoynrIntegrationBean method registerProviders.

private void registerProviders(Set<Bean<?>> serviceProviderBeans, JoynrRuntime runtime) {
    Set<ProviderQosFactory> providerQosFactories = getProviderQosFactories();
    for (Bean<?> bean : serviceProviderBeans) {
        Class<?> beanClass = bean.getBeanClass();
        ServiceProvider providerService = beanClass.getAnnotation(ServiceProvider.class);
        Class<?> serviceInterface = serviceProviderDiscovery.getProviderInterfaceFor(providerService.serviceInterface());
        if (LOG.isDebugEnabled()) {
            LOG.debug(format("Registering %s as provider with joynr runtime for service interface %s.", bean, serviceInterface));
        }
        Object provider = Proxy.newProxyInstance(beanClass.getClassLoader(), new Class<?>[] { serviceInterface }, new ProviderWrapper(bean, beanManager, joynrRuntimeFactory.getInjector()));
        ProviderQos providerQos = null;
        for (ProviderQosFactory factory : providerQosFactories) {
            if (factory.providesFor(serviceInterface)) {
                providerQos = factory.create();
                break;
            }
        }
        if (providerQos == null) {
            providerQos = new ProviderQos();
        }
        runtime.registerProvider(getDomainForProvider(beanClass), provider, providerQos);
        registeredProviders.add(provider);
    }
}
Also used : ProviderQosFactory(io.joynr.jeeintegration.api.ProviderQosFactory) ServiceProvider(io.joynr.jeeintegration.api.ServiceProvider) ProviderQos(joynr.types.ProviderQos)

Example 2 with ProviderQosFactory

use of io.joynr.jeeintegration.api.ProviderQosFactory in project joynr by bmwcarit.

the class JoynrIntegrationBean method getProviderQosFactories.

@SuppressWarnings({ "rawtypes", "unchecked", "serial" })
private Set<ProviderQosFactory> getProviderQosFactories() {
    Set<Bean<?>> providerQosFactoryBeans = beanManager.getBeans(ProviderQosFactory.class, new AnnotationLiteral<Any>() {
    });
    Set<ProviderQosFactory> providerQosFactories = new HashSet<>();
    for (Bean providerQosFactoryBean : providerQosFactoryBeans) {
        ProviderQosFactory factory = (ProviderQosFactory) providerQosFactoryBean.create(beanManager.createCreationalContext(providerQosFactoryBean));
        providerQosFactories.add(factory);
    }
    return providerQosFactories;
}
Also used : ProviderQosFactory(io.joynr.jeeintegration.api.ProviderQosFactory) Any(javax.enterprise.inject.Any) Bean(javax.enterprise.inject.spi.Bean) HashSet(java.util.HashSet)

Aggregations

ProviderQosFactory (io.joynr.jeeintegration.api.ProviderQosFactory)2 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 ProviderQos (joynr.types.ProviderQos)1