/** * Register a config producer bean for each {@link ConfigProperty} injection. * * @param abd event from CDI container * @param bm bean manager */ public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) { // each injection point will have its own bean qualifiers.forEach(q -> abd.addBean(new ConfigPropertyProducer(q.qualifier, q.type, bm))); // we also must support injection of Config itself abd.addBean() .addType(Config.class) .createWith(creationalContext -> ((MpConfig) configResolver.getConfig()).helidonConfig()); abd.addBean() .addType(org.eclipse.microprofile.config.Config.class) .createWith(creationalContext -> { return new SerializableConfig(); }); }
private void configureBogey(BeanManager bm, BeanConfigurator<Bogey> bogey){ bogey.beanClass(Bogey.class); bogey.addType(Bogey.class); bogey.addQualifier(Undead.UndeadLiteral.INSTANCE); bogey.produceWith(obj -> new Bogey()); }
/** * Register a config producer bean for each {@link ConfigProperty} injection. * * @param abd event from CDI container * @param bm bean manager */ public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) { // each injection point will have its own bean qualifiers.forEach(q -> abd.addBean(new ConfigPropertyProducer(q.qualifier, q.type, bm))); // we also must support injection of Config itself abd.addBean() .addType(Config.class) .createWith(creationalContext -> ((MpConfig) configResolver.getConfig()).helidonConfig()); abd.addBean() .addType(org.eclipse.microprofile.config.Config.class) .createWith(creationalContext -> { return new SerializableConfig(); }); }
void observeABD(@Observes AfterBeanDiscovery abd, BeanManager beanManager) { abd.addBean() .addType(Account.class) .addQualifier(Custom.CustomLiteral.INSTANCE) .<Account>createWith((cc) -> { InterceptionFactory<Account> factory = beanManager.createInterceptionFactory(cc, Account.class); factory.configure().add(FeeBinding.FeeLiteral.INSTANCE); return factory.createInterceptedInstance(new Account()); }); } }
public void registerWeldSEContexts(@Observes AfterBeanDiscovery event, BeanManager manager) { if (ignoreEvent(event)) { return; } final String contextId = BeanManagerProxy.unwrap(manager).getContextId(); this.threadContext = new ThreadContext(contextId); event.addContext(threadContext); // Register WeldContainer as a singleton event.addBean().addType(WeldContainer.class).addQualifier(Default.Literal.INSTANCE).scope(Singleton.class) .produceWith((i) -> WeldContainer.instance(contextId)); }
public void registerWeldSEContexts(@Observes AfterBeanDiscovery event, BeanManager manager) { if (ignoreEvent(event)) { return; } final String contextId = BeanManagerProxy.unwrap(manager).getContextId(); this.threadContext = new ThreadContext(contextId); event.addContext(threadContext); // Register WeldContainer as a singleton event.addBean().addType(WeldContainer.class).addQualifier(Default.Literal.INSTANCE).scope(Singleton.class) .produceWith((i) -> WeldContainer.instance(contextId)); }
public void registerWeldSEContexts(@Observes AfterBeanDiscovery event, BeanManager manager) { if (ignoreEvent(event)) { return; } final String contextId = BeanManagerProxy.unwrap(manager).getContextId(); this.threadContext = new ThreadContext(contextId); event.addContext(threadContext); // Register WeldContainer as a singleton event.addBean().addType(WeldContainer.class).addQualifier(Default.Literal.INSTANCE).scope(Singleton.class) .produceWith((i) -> WeldContainer.instance(contextId)); }