use of org.wildfly.swarm.container.Interface in project wildfly-swarm by wildfly-swarm.
the class InterfaceExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
List<SimpleKey> configuredInterfaces = this.configView.simpleSubkeys(ROOT);
for (SimpleKey interfaceName : configuredInterfaces) {
Set<Bean<?>> ifaces = beanManager.getBeans(Interface.class, AnyLiteral.INSTANCE);
if (ifaces.stream().noneMatch(e -> e.getQualifiers().stream().anyMatch(anno -> anno instanceof Named && ((Named) anno).value().equals(interfaceName + "-interface")))) {
Interface iface = new Interface(interfaceName.name(), "0.0.0.0");
applyConfiguration(iface);
CommonBean<Interface> interfaceBean = CommonBeanBuilder.newBuilder(Interface.class).beanClass(InterfaceExtension.class).scope(ApplicationScoped.class).addQualifier(AnyLiteral.INSTANCE).addQualifier(new NamedLiteral(interfaceName.name() + "-interface")).createSupplier(() -> iface).addType(Interface.class).addType(Object.class).build();
abd.addBean(interfaceBean);
}
}
}
Aggregations