Search in sources :

Example 1 with AbstractMemberProducer

use of org.jboss.weld.injection.producer.AbstractMemberProducer in project core by weld.

the class Validator method validateRIBean.

/**
 * Validate an RIBean. This includes validating whether two beans specialize
 * the same bean
 *
 * @param bean             the bean to validate
 * @param beanManager      the current manager
 * @param specializedBeans the existing specialized beans
 */
protected void validateRIBean(CommonBean<?> bean, BeanManagerImpl beanManager, Collection<CommonBean<?>> specializedBeans) {
    validateGeneralBean(bean, beanManager);
    if (bean instanceof NewBean) {
        return;
    }
    if (bean instanceof DecorableBean) {
        validateDecorators(beanManager, (DecorableBean<?>) bean);
    }
    if ((bean instanceof AbstractClassBean<?>)) {
        AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean;
        // validate CDI-defined interceptors
        if (classBean.hasInterceptors()) {
            validateInterceptors(beanManager, classBean);
        }
    }
    // for each producer bean validate its disposer method
    if (bean instanceof AbstractProducerBean<?, ?, ?>) {
        AbstractProducerBean<?, ?, ?> producerBean = Reflections.<AbstractProducerBean<?, ?, ?>>cast(bean);
        if (producerBean.getProducer() instanceof AbstractMemberProducer<?, ?>) {
            AbstractMemberProducer<?, ?> producer = Reflections.<AbstractMemberProducer<?, ?>>cast(producerBean.getProducer());
            if (producer.getDisposalMethod() != null) {
                for (InjectionPoint ip : producer.getDisposalMethod().getInjectionPoints()) {
                    // pass the producer bean instead of the disposal method bean
                    validateInjectionPointForDefinitionErrors(ip, null, beanManager);
                    validateMetadataInjectionPoint(ip, null, ValidatorLogger.INJECTION_INTO_DISPOSER_METHOD);
                    validateEventMetadataInjectionPoint(ip);
                    validateInjectionPointForDeploymentProblems(ip, null, beanManager);
                }
            }
        }
    }
}
Also used : InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) AbstractClassBean(org.jboss.weld.bean.AbstractClassBean) DecorableBean(org.jboss.weld.bean.DecorableBean) AbstractProducerBean(org.jboss.weld.bean.AbstractProducerBean) NewBean(org.jboss.weld.bean.NewBean) AbstractMemberProducer(org.jboss.weld.injection.producer.AbstractMemberProducer)

Aggregations

InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 AbstractClassBean (org.jboss.weld.bean.AbstractClassBean)1 AbstractProducerBean (org.jboss.weld.bean.AbstractProducerBean)1 DecorableBean (org.jboss.weld.bean.DecorableBean)1 NewBean (org.jboss.weld.bean.NewBean)1 AbstractMemberProducer (org.jboss.weld.injection.producer.AbstractMemberProducer)1