protected void initDelegate()
{
Set<InjectionPoint> injectionPoints = getInjectionPoints();
boolean found = false;
InjectionPoint ipFound = null;
for(InjectionPoint ip : injectionPoints)
{
if(ip.getAnnotated().isAnnotationPresent(Delegate.class))
{
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");
}
String message = new String("Error in decorator : "+ toString() + ". The delegate injection point must be an injected field, " +
"initializer method parameter or bean constructor method parameter. ");
if(!(ipFound.getMember() instanceof Constructor))
{
AnnotatedElement element = (AnnotatedElement)ipFound.getMember();
if(!element.isAnnotationPresent(Inject.class))
{
throw new WebBeansConfigurationException(message);
}
}