if ((resolvers = isConfiguredWebBeans(specializedClass,true)) != null)
{
if(resolvers.isEmpty())
{
throw new InconsistentSpecializationException("Specialized bean for class : " + specializedClass + " is not enabled in the deployment.");
}
if(resolvers.size() > 1)
{
throw new InconsistentSpecializationException("More than one specialized bean for class : " + specializedClass + " is enabled in the deployment.");
}
specialized = resolvers.iterator().next();
Class<?> superClass = specializedClass.getSuperclass();
resolvers = isConfiguredWebBeans(superClass,false);
for(Bean<?> candidates : resolvers)
{
AbstractComponent<?> candidate = (AbstractComponent<?>)candidates;
if(!(candidate instanceof NewComponentImpl))
{
if(candidate.getReturnType().equals(superClass))
{
superBean = candidates;
break;
}
}
}
if (superBean != null)
{
int res = DeploymentTypeManager.getInstance().comparePrecedences(specialized.getDeploymentType(), superBean.getDeploymentType());
if (res <= 0)
{
throw new InconsistentSpecializationException("@Specializes exception. Class : " + specializedClass.getName() + " must have higher deployment type precedence from the class : " + superClass.getName());
}
AbstractComponent<?> comp = (AbstractComponent<?>)specialized;
if(superBean.getName() != null)
{
if(comp.getName() != null)
{
throw new DefinitionException("@Specialized Class : " + specializedClass.getName() + " may not explicitly declare a bean name");
}
comp.setName(superBean.getName());
}
specialized.getBindings().addAll(superBean.getBindings());
}
else
{
throw new InconsistentSpecializationException("WebBean component class : " + specializedClass.getName() + " is not enabled for specialized by the " + specializedClass + " class");
}
}
}