use of javax.enterprise.inject.spi.ProcessInjectionTarget in project jersey by jersey.
the class CdiComponentProvider method processInjectionTarget.
@SuppressWarnings("unused")
private void processInjectionTarget(@Observes final ProcessInjectionTarget event) {
final InjectionTarget it = event.getInjectionTarget();
final Class<?> componentClass = event.getAnnotatedType().getJavaClass();
final Set<InjectionPoint> cdiInjectionPoints = filterHk2InjectionPointsOut(it.getInjectionPoints());
for (final InjectionPoint injectionPoint : cdiInjectionPoints) {
final Member member = injectionPoint.getMember();
if (member instanceof Field) {
addInjecteeToSkip(componentClass, fieldsToSkip, (Field) member);
} else if (member instanceof Method) {
addInjecteeToSkip(componentClass, methodsToSkip, (Method) member);
}
}
InjectionManagerInjectedCdiTarget target = null;
if (isJerseyOrDependencyType(componentClass)) {
target = new InjectionManagerInjectedCdiTarget(it) {
@Override
public Set<InjectionPoint> getInjectionPoints() {
// CDI will not treat these classes as CDI beans (as they are not).
return Collections.emptySet();
}
};
} else if (isJaxRsComponentType(componentClass) || jaxrsInjectableTypes.contains(event.getAnnotatedType().getBaseType())) {
target = new InjectionManagerInjectedCdiTarget(it) {
@Override
public Set<InjectionPoint> getInjectionPoints() {
// Inject CDI beans into JAX-RS resources/providers/application.
return cdiInjectionPoints;
}
};
}
if (target != null) {
notify(target);
//noinspection unchecked
event.setInjectionTarget(target);
}
}
Aggregations