use of org.jboss.weld.bean.DecorableBean 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);
}
}
}
}
}
use of org.jboss.weld.bean.DecorableBean in project core by weld.
the class Validator method reallyValidatePseudoScopedBean.
/**
* checks if a bean has been seen before in the dependencyPath. If not, it
* resolves the InjectionPoints and adds the resolved beans to the set of
* beans to be validated
*/
private static void reallyValidatePseudoScopedBean(Bean<?> bean, BeanManagerImpl beanManager, Set<Object> dependencyPath, Set<Bean<?>> validatedBeans) {
// see if we have already seen this bean in the dependency path
if (dependencyPath.contains(bean)) {
// create a list that shows the path to the bean
List<Object> realDependencyPath = new ArrayList<Object>(dependencyPath);
realDependencyPath.add(bean);
throw ValidatorLogger.LOG.pseudoScopedBeanHasCircularReferences(WeldCollections.toMultiRowString(realDependencyPath));
}
if (validatedBeans.contains(bean)) {
return;
}
dependencyPath.add(bean);
for (InjectionPoint injectionPoint : bean.getInjectionPoints()) {
if (!injectionPoint.isDelegate()) {
dependencyPath.add(injectionPoint);
validatePseudoScopedInjectionPoint(injectionPoint, beanManager, dependencyPath, validatedBeans);
dependencyPath.remove(injectionPoint);
}
}
if (bean instanceof DecorableBean<?>) {
final List<Decorator<?>> decorators = Reflections.<DecorableBean<?>>cast(bean).getDecorators();
if (!decorators.isEmpty()) {
for (final Decorator<?> decorator : decorators) {
reallyValidatePseudoScopedBean(decorator, beanManager, dependencyPath, validatedBeans);
}
}
}
if (bean instanceof AbstractProducerBean<?, ?, ?> && !(bean instanceof EEResourceProducerField<?, ?>)) {
AbstractProducerBean<?, ?, ?> producer = (AbstractProducerBean<?, ?, ?>) bean;
if (!beanManager.isNormalScope(producer.getDeclaringBean().getScope()) && !producer.getAnnotated().isStatic()) {
reallyValidatePseudoScopedBean(producer.getDeclaringBean(), beanManager, dependencyPath, validatedBeans);
}
}
validatedBeans.add(bean);
dependencyPath.remove(bean);
}
Aggregations