in webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java [156:222]
private void defineDelegate(Set<InjectionPoint> injectionPoints)
{
boolean found = false;
InjectionPoint ipFound = null;
for (InjectionPoint ip : injectionPoints)
{
if (ip.isDelegate())
{
if (!found)
{
found = true;
ipFound = ip;
}
else
{
throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point. " +
"But the decorator bean : " + toString() + " has more than one");
}
}
}
if(ipFound == null)
{
throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point." +
"But the decorator bean : " + toString() + " has none");
}
if(!(ipFound.getMember() instanceof Constructor))
{
AnnotatedElement element = (AnnotatedElement)ipFound.getMember();
if(!element.isAnnotationPresent(Inject.class))
{
String message = "Error in decorator : " + annotatedType + ". The delegate injection point must be an injected field, " +
"initializer method parameter or bean constructor method parameter.";
throw new WebBeansConfigurationException(message);
}
}
delegateType = GenericsUtil.resolveType(ipFound.getType(), annotatedType.getJavaClass(), ipFound.getMember());
delegateQualifiers = ipFound.getQualifiers();
for (Type decType : decoratedTypes)
{
if (!(ClassUtil.getClass(decType)).isAssignableFrom(ClassUtil.getClass(delegateType)))
{
throw new WebBeansConfigurationException("Decorator : " + toString() + " delegate attribute must implement all of the decorator decorated types" +
", but decorator type " + decType + " is not assignable from delegate type of " + delegateType);
}
else
{
if(ClassUtil.isParametrizedType(decType) && ClassUtil.isParametrizedType(delegateType))
{
checkParametrizedType();
}
else if (ClassUtil.isTypeVariable(decType))
{
if (!decType.equals(delegateType))
{
throw new WebBeansConfigurationException("Decorator : " + toString() + " generic delegate attribute must be same with decorated type : " + decType);
}
}
}
}
}