use of org.wildfly.swarm.internal.SocketBindingRequest in project wildfly-swarm by wildfly-swarm.
the class SocketBindingExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
try (AutoCloseable handle = Performance.time("SocketBindingExtension.afterBeanDiscovery")) {
for (SocketBindingRequest each : this.bindings) {
Supplier<Customizer> supplier = () -> (Customizer) () -> {
Set<Bean<?>> groups = beanManager.getBeans(SocketBindingGroup.class, AnyLiteral.INSTANCE);
groups.stream().map((Bean<?> e) -> {
CreationalContext<?> ctx = beanManager.createCreationalContext(e);
return (SocketBindingGroup) beanManager.getReference(e, SocketBindingGroup.class, ctx);
}).filter(group -> group.name().equals(each.socketBindingGroup())).findFirst().ifPresent((group) -> group.socketBinding(each.socketBinding()));
};
CommonBean<Customizer> customizerBean = CommonBeanBuilder.newBuilder(Customizer.class).beanClass(SocketBindingExtension.class).scope(Singleton.class).addQualifier(Pre.Literal.INSTANCE).addQualifier(AnyLiteral.INSTANCE).createSupplier(supplier).addType(Customizer.class).addType(Object.class).build();
abd.addBean(customizerBean);
}
}
}
Aggregations