use of io.joynr.jeeintegration.api.ServiceProvider 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);
}
}
use of io.joynr.jeeintegration.api.ServiceProvider 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;
}
Aggregations