/** * If bean is passivation capable, it validate all of its dependencies. * @throws org.apache.webbeans.exception.WebBeansConfigurationException if not satisfy passivation dependencies */ public <T> void validatePassivationCapable(OwbBean<T> bean) { if (isPassivationCapable(bean)) { if (EnterpriseBeanMarker.class.isInstance(bean)) { validatePassivationCapableDependencies(bean, bean.getInjectionPoints()); if (BeanInterceptorInfoProvider.class.isInstance(bean)) { validatePassivationCapableInterceptorInfo(bean, BeanInterceptorInfoProvider.class.cast(bean).interceptorInfo()); } return; } if (!(bean instanceof ProducerMethodBean)) { validatePassivationCapableDependencies(bean, bean.getInjectionPoints()); } if (bean.getProducer() instanceof InjectionTargetImpl) { InjectionTargetImpl<T> injectionTarget = (InjectionTargetImpl<T>)bean.getProducer(); BeanInterceptorInfo interceptorInfo = injectionTarget.getInterceptorInfo(); validatePassivationCapableInterceptorInfo(bean, interceptorInfo); } } }
/** * New WebBeans component class. * * @return the new component */ public <T> NewManagedBean<T> createNewComponent(OwbBean<T> bean, Class<T> type) { Asserts.assertNotNull(bean, "bean"); if (!EnumSet.of(WebBeansType.MANAGED, WebBeansType.ENTERPRISE, WebBeansType.PRODUCERMETHOD, WebBeansType.PRODUCERFIELD).contains(bean.getWebBeansType())) { throw new WebBeansConfigurationException("@New annotation on type : " + bean.getBeanClass() + " must defined as a simple or an enterprise web bean"); } AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type); BeanAttributesImpl<T> newBeanAttributes = new BeanAttributesImpl<>(bean.getTypes(), Collections.<Annotation>singleton(new NewLiteral(type))); NewManagedBean<T> newBean = new NewManagedBean<>(bean.getWebBeansContext(), bean.getWebBeansType(), annotatedType, newBeanAttributes, type, bean.getInjectionPoints()); //TODO XXX set producer return newBean; }