public void registerBeansAfterBeanDiscovery(@Observes AfterBeanDiscovery event) { if (vertx == null) { // Do no register beans - no Vertx instance available during bootstrap return; } // Allow to inject Vertx used to deploy the WeldVerticle event.addBean().types(getBeanTypes(vertx.getClass(), Vertx.class)).addQualifiers(Any.Literal.INSTANCE, Default.Literal.INSTANCE) .scope(ApplicationScoped.class).createWith(c -> vertx); // Allow to inject Context of the WeldVerticle event.addBean().types(getBeanTypes(context.getClass(), Context.class)).addQualifiers(Any.Literal.INSTANCE, Default.Literal.INSTANCE) .scope(ApplicationScoped.class).createWith(c -> context); }
event.addBean() .addTransitiveTypeClosure(type) .addQualifiers(new ConfigurationCoordinates.Literal(), ConfigurationValue.Literal.of("")) .scope(Dependent.class)
private void configureZombie(BeanManager bm, BeanConfigurator<Zombie> zombie) { // init with read() method, then set values zombie.read(bm.createAnnotatedType(Zombie.class)); zombie.beanClass(Zombie.class); zombie.addQualifiers(Undead.UndeadLiteral.INSTANCE, Dangerous.DangerousLiteral.INSTANCE); zombie.addStereotype(Monster.class); zombie.scope(RequestScoped.class); InjectionPoint zombieWeaponIP = null; InjectionPoint zombieDesireIP = null; for (AnnotatedField<? super Zombie> field : bm.createAnnotatedType(Zombie.class).getFields()) { if (field.getJavaMember().getType().equals(DesireToHurtHumans.class)) { zombieDesireIP = bm.createInjectionPoint(field); } if (field.getJavaMember().getType().equals(Weapon.class)) { zombieWeaponIP = bm.createInjectionPoint(field); } } // add multiple injection points zombie.addInjectionPoints(zombieWeaponIP, zombieDesireIP); // set Function as a supplier zombie.produceWith(MonsterController.zombieProducingFunction); // set BiConsumer to destroyWith zombie.destroyWith(MonsterController.zombieConsumer); // make passivation capable zombie.id("zombie"); }