Search in sources :

Example 1 with OutboundSocketBindingRequest

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);
        }
    }
}
Also used : OutboundSocketBindingRequest(org.wildfly.swarm.internal.OutboundSocketBindingRequest) CreationalContext(javax.enterprise.context.spi.CreationalContext) Customizer(org.wildfly.swarm.spi.api.Customizer) CommonBean(org.wildfly.swarm.spi.api.cdi.CommonBean) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

CreationalContext (javax.enterprise.context.spi.CreationalContext)1 Bean (javax.enterprise.inject.spi.Bean)1 OutboundSocketBindingRequest (org.wildfly.swarm.internal.OutboundSocketBindingRequest)1 Customizer (org.wildfly.swarm.spi.api.Customizer)1 CommonBean (org.wildfly.swarm.spi.api.cdi.CommonBean)1