Author: pete.muir(a)jboss.org
Date: 2010-02-04 17:03:26 -0500 (Thu, 04 Feb 2010)
New Revision: 5748
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
Log:
only validate enabled decorators
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-02-04
21:22:55 UTC (rev 5747)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-02-04
22:03:26 UTC (rev 5748)
@@ -259,7 +259,7 @@
Annotation[] bindings = ij.getQualifiers().toArray(new Annotation[0]);
WeldAnnotated<?, ?> annotatedItem = ResolvableWeldClass.of(ij.getType(),
bindings, beanManager);
Set<?> resolvedBeans =
beanManager.getBeanResolver().resolve(beanManager.getInjectableBeans(ij));
- if (resolvedBeans.isEmpty())
+ if (!isInjectionPointSatisfied(ij, resolvedBeans, beanManager))
{
throw new DeploymentException(INJECTION_POINT_HAS_UNSATISFIED_DEPENDENCIES, ij,
Arrays.toString(bindings));
}
@@ -267,19 +267,23 @@
{
throw new DeploymentException(INJECTION_POINT_HAS_AMBIGUOUS_DEPENDENCIES, ij,
Arrays.toString(bindings) + "; Possible dependencies: " + resolvedBeans);
}
- Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
- if
(beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScope()).isNormal()
&& !Proxies.isTypeProxyable(ij.getType()))
+ // Account for the case this is disabled decorator
+ if (!resolvedBeans.isEmpty())
{
- throw new
UnproxyableResolutionException(INJECTION_POINT_HAS_NON_PROXYABLE_DEPENDENCIES, ij);
+ Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
+ if
(beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScope()).isNormal()
&& !Proxies.isTypeProxyable(ij.getType()))
+ {
+ throw new
UnproxyableResolutionException(INJECTION_POINT_HAS_NON_PROXYABLE_DEPENDENCIES, ij);
+ }
+ if (annotatedItem.isPrimitive() && resolvedBean.isNullable())
+ {
+ throw new
NullableDependencyException(INJECTION_POINT_HAS_NULLABLE_DEPENDENCIES, ij);
+ }
+ if (ij.getBean() != null && Beans.isPassivatingScope(ij.getBean(),
beanManager) && (!ij.isTransient()) &&
!Beans.isPassivationCapableBean(resolvedBean))
+ {
+ validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
+ }
}
- if (annotatedItem.isPrimitive() && resolvedBean.isNullable())
- {
- throw new NullableDependencyException(INJECTION_POINT_HAS_NULLABLE_DEPENDENCIES,
ij);
- }
- if (ij.getBean() != null && Beans.isPassivatingScope(ij.getBean(),
beanManager) && (!ij.isTransient()) &&
!Beans.isPassivationCapableBean(resolvedBean))
- {
- validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
- }
}
public void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?>
resolvedBean, BeanManagerImpl beanManager)
@@ -461,6 +465,25 @@
}
}
+
+ private static boolean isInjectionPointSatisfied(InjectionPoint ij, Set<?>
resolvedBeans, BeanManagerImpl beanManager)
+ {
+ if (ij.getBean() instanceof Decorator<?>)
+ {
+ if
(beanManager.getEnabledDecoratorClasses().contains(ij.getBean().getBeanClass()))
+ {
+ return resolvedBeans.size() > 0;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return resolvedBeans.size() > 0;
+ }
+ }
public void cleanup()
{
Show replies by date