Beispiel #1
0
 private void validateDecorators(BeanManagerImpl beanManager, AbstractClassBean<?> classBean) {
   if (classBean.getDecorators().size() > 0) {
     boolean passivationCapabilityCheckRequired =
         isPassivationCapabilityCheckRequired(beanManager, classBean);
     for (Decorator<?> decorator : classBean.getDecorators()) {
       if (passivationCapabilityCheckRequired) {
         boolean isSerializable =
             (decorator instanceof WeldDecorator<?>)
                 ? (((WeldDecorator<?>) decorator).getWeldAnnotated().isSerializable())
                 : (decorator instanceof PassivationCapable);
         if (!isSerializable) {
           throw new UnserializableDependencyException(
               PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR, classBean, decorator);
         }
       }
       for (InjectionPoint ij : decorator.getInjectionPoints()) {
         if (!ij.isDelegate()) {
           Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(ij));
           validateInjectionPoint(ij, beanManager);
           if (passivationCapabilityCheckRequired) {
             validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
           }
         }
       }
     }
   }
 }
Beispiel #2
0
  private static InjectionPoint getDelegate(Decorator<?> bean) {
    if (bean instanceof DecoratorBean) return ((DecoratorBean) bean).getDelegateInjectionPoint();

    for (InjectionPoint ip : bean.getInjectionPoints()) {
      if (ip.isDelegate()) return ip;
    }

    throw new IllegalStateException(String.valueOf(bean));
  }