Esempio n. 1
0
 /**
  * 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
  */
 private void validateRIBean(
     RIBean<?> bean, BeanManagerImpl beanManager, Collection<RIBean<?>> specializedBeans) {
   validateBean(bean, beanManager);
   if (!(bean instanceof NewManagedBean<?>) && !(bean instanceof NewSessionBean<?>)) {
     RIBean<?> abstractBean = bean;
     if (abstractBean.isSpecializing()) {
       if (specializedBeans.contains(abstractBean.getSpecializedBean())) {
         throw new InconsistentSpecializationException(BEAN_SPECIALIZED_TOO_MANY_TIMES, bean);
       }
       specializedBeans.add(abstractBean.getSpecializedBean());
     }
     if ((bean instanceof AbstractClassBean<?>)) {
       AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean;
       if (classBean.hasDecorators()) {
         validateDecorators(beanManager, classBean);
       }
       // validate CDI-defined interceptors
       if (classBean.hasInterceptors()) {
         validateInterceptors(beanManager, classBean);
       }
     }
     // for each producer method validate its disposer method
     if (bean instanceof ProducerMethod<?, ?>
         && ((ProducerMethod<?, ?>) bean).getDisposalMethod() != null) {
       DisposalMethod<?, ?> disposalMethod = ((ProducerMethod<?, ?>) bean).getDisposalMethod();
       for (InjectionPoint ip : disposalMethod.getInjectionPoints()) {
         // pass the producer bean instead of the disposal method bean
         validateInjectionPoint(ip, bean, beanManager);
       }
     }
   }
 }
 public void addDisposesMethod(DisposalMethod<?, ?> bean) {
   allDisposalBeans.add(bean);
   addNewBeansFromInjectionPoints(bean.getInjectionPoints());
 }