in cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ReferenceModel.java [105:152]
private ReferenceModel(
Type injectionPointType,
Class<?> declaringClass,
Annotated annotated) {
_annotated = annotated;
_injectionPointType = injectionPointType;
_declaringClass = declaringClass;
_reference = _annotated.getAnnotation(Reference.class);
_referenceType = getReferenceType();
_referenceTarget = getReferenceTarget();
_prototype = getQualifiers().stream().filter(
ann -> ann.annotationType().equals(PrototypeRequired.class)
).findFirst().isPresent();
calculateServiceType(_injectionPointType);
_referenceType.ifPresent(c -> {
if ((_serviceType != null) && !_serviceType.isAssignableFrom(c)) {
throw new IllegalArgumentException(
"The service type specified in @Reference (" + c +
") is not compatible with the type calculated from the injection point: " +
_serviceType + " on " + _annotated);
}
_serviceType = c;
});
Type rawType = _injectionPointType;
if (rawType instanceof ParameterizedType) {
ParameterizedType pt = cast(_injectionPointType);
rawType = pt.getRawType();
}
_beanClass = cast(rawType);
_name = calculateName(_serviceType, _annotated);
if (_annotated.isAnnotationPresent(Reluctant.class)) {
_greedy = false;
}
_targetFilter = buildFilter();
}