{
LOG.debug(logMessagePrefix + ": Primitive types are not supported");
}
return 1;
}
Named named = null;
Class<?> qualifier = null;
for (int i = 0, length = annotations.length; i < length; i++)
{
Annotation a = annotations[i];
if (a instanceof Named)
{
named = (Named)a;
break;
}
else if (a.annotationType().isAnnotationPresent(Qualifier.class))
{
qualifier = a.annotationType();
break;
}
}
if (type.isInterface() && type.equals(Provider.class))
{
if (!(genericType instanceof ParameterizedType))
{
if (LOG.isDebugEnabled())
{
LOG.debug(logMessagePrefix + ": The generic type is not of type ParameterizedType");
}
return 2;
}
ParameterizedType aType = (ParameterizedType)genericType;
Type[] typeVars = aType.getActualTypeArguments();
Class<?> expectedType = (Class<?>)typeVars[0];
final ComponentAdapter<?> adapter;
if (named != null)
{
adapter = holder.getComponentAdapter(named.value(), expectedType);
}
else if (qualifier != null)
{
adapter = holder.getComponentAdapter(qualifier, expectedType);
}
else
{
adapter = holder.getComponentAdapterOfType(expectedType);
}
if (adapter == null)
{
if (LOG.isDebugEnabled())
{
LOG.debug(logMessagePrefix + ": We have no value to set so we skip it");
}
return 3;
}
return new Provider<Object>()
{
public Object get()
{
return adapter.getComponentInstance();
}
};
}
else
{
if (named != null)
{
return holder.getComponentInstance(named.value(), type);
}
else if (qualifier != null)
{
return holder.getComponentInstance(qualifier, type);
}