use of org.wildfly.swarm.internal.OutboundSocketBindingRequest in project wildfly-swarm by wildfly-swarm.
the class OutboundSocketBindingExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
try (AutoCloseable handle = Performance.time("OutboundSocketBindingExtension.afterBeanDiscovery")) {
for (OutboundSocketBindingRequest each : this.bindings) {
Supplier<Customizer> customizerSupplier = () -> (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.outboundSocketBinding(each.outboundSocketBinding()));
};
CommonBean<Customizer> customizerBean = CommonBeanBuilder.newBuilder(Customizer.class).beanClass(OutboundSocketBindingExtension.class).scope(Singleton.class).addQualifier(Pre.Literal.INSTANCE).addQualifier(AnyLiteral.INSTANCE).createSupplier(customizerSupplier).addType(Customizer.class).addType(Object.class).build();
abd.addBean(customizerBean);
}
}
}
Aggregations