use of io.fabric8.cdi.bean.ServiceUrlCollectionBean in project fabric8 by fabric8io.
the class Fabric8Extension method afterDiscovery.
public void afterDiscovery(@Observes final AfterBeanDiscovery event, BeanManager beanManager) {
KubernetesHolder.useBeanManager(beanManager);
// Only add the bean if no other bean is found.
if (beanManager.getBeans(KubernetesClient.class).isEmpty()) {
event.addBean(new KubernetesClientBean());
}
// We need to process factories in reverse order so that we make feasible forwarding for service id etc.
List<FactoryMethodContext> reverseFactories = new ArrayList<>(FactoryMethodContext.sort(factories));
Collections.reverse(reverseFactories);
for (final FactoryMethodContext factoryMethodContext : reverseFactories) {
ServiceBean.doWith(factoryMethodContext.getReturnType(), new ServiceBean.Callback() {
@Override
public ServiceBean apply(ServiceBean bean) {
String serviceId = bean.getServiceName();
String serviceProtocol = or(bean.getServiceProtocol(), getFactoryMethodProtocol(factoryMethodContext.getFactoryMethod().getJavaMember()));
String servicePort = or(bean.getServicePort(), getFactoryMethodPort(factoryMethodContext.getFactoryMethod().getJavaMember()));
String servicePath = or(bean.getServicePath(), getFactoryMethodPath(factoryMethodContext.getFactoryMethod().getJavaMember()));
Boolean serviceExternal = bean.getServiceExternal();
Boolean serviceEndpoint = bean.getServiceEndpoint();
// Ensure that there is a factory String -> sourceType before adding producer.
if (!String.class.equals(factoryMethodContext.getSourceType())) {
ServiceBean.getBean(serviceId, serviceProtocol, servicePort, servicePath, null, serviceEndpoint, serviceExternal, factoryMethodContext.getSourceType());
}
return bean.withProducer(new FactoryMethodProducer(factoryMethodContext.getBean(), factoryMethodContext.getFactoryMethod(), serviceId, serviceProtocol, servicePort, servicePath));
}
});
}
for (ServiceUrlBean bean : ServiceUrlBean.getBeans()) {
event.addBean(bean);
}
for (ServiceUrlCollectionBean bean : ServiceUrlCollectionBean.getBeans()) {
event.addBean(bean);
}
for (ServiceBean bean : ServiceBean.getBeans()) {
if (bean.getProducer() != null) {
event.addBean(bean);
}
}
for (ConfigurationBean b : ConfigurationBean.getBeans()) {
event.addBean(b);
}
}
Aggregations