use of org.jboss.weld.exceptions.IllegalArgumentException in project core by weld.
the class BeanConfiguratorExtension method afterBeanDiscovery.
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) {
event.addBean().scope(Dependent.class).addType(String.class).addQualifier(Juicy.Literal.INSTANCE).produceWith((i) -> {
InjectionPoint ip = i.select(InjectionPoint.class).get();
assertNotNull(ip);
assertNotNull(ip.getBean());
return ip.getBean().getBeanClass().getName();
});
event.addBean().scope(ApplicationScoped.class).addType(Map.class).addQualifier(Juicy.Literal.INSTANCE).produceWith((i) -> {
try {
i.select(InjectionPoint.class).get();
fail("Cannot inject injection point metadata into non-dependent bean");
} catch (IllegalArgumentException expected) {
}
return new HashMap<>();
});
}
use of org.jboss.weld.exceptions.IllegalArgumentException in project core by weld.
the class AbstractProducerFactory method createProducer.
@Override
public <T> Producer<T> createProducer(Bean<T> bean) {
if (getDeclaringBean() == null && !getAnnotatedMember().isStatic()) {
throw BeanManagerLogger.LOG.nullDeclaringBean(getAnnotatedMember());
}
AnnotatedTypeValidator.validateAnnotatedMember(getAnnotatedMember());
try {
Producer<T> producer = createProducer(getDeclaringBean(), bean, null);
getManager().getServices().get(InjectionTargetService.class).validateProducer(producer);
return producer;
} catch (Throwable e) {
throw new IllegalArgumentException(e);
}
}
Aggregations