use of javax.enterprise.inject.spi.AnnotatedConstructor in project jersey by jersey.
the class CdiComponentProvider method processAnnotatedType.
@SuppressWarnings("unused")
private void processAnnotatedType(@Observes final // PathParam.class})
ProcessAnnotatedType processAnnotatedType) {
final AnnotatedType<?> annotatedType = processAnnotatedType.getAnnotatedType();
// if one of the JAX-RS annotations is present in the currently seen class, add it to the "whitelist"
if (containsJaxRsConstructorInjection(annotatedType) || containsJaxRsFieldInjection(annotatedType) || containsJaxRsMethodInjection(annotatedType)) {
jaxrsInjectableTypes.add(annotatedType.getBaseType());
}
if (customHk2TypesProvider != null) {
final Type baseType = annotatedType.getBaseType();
if (customHk2TypesProvider.getHk2Types().contains(baseType)) {
processAnnotatedType.veto();
jerseyVetoedTypes.add(baseType);
}
}
if (containsJaxRsParameterizedCtor(annotatedType)) {
processAnnotatedType.setAnnotatedType(new AnnotatedType() {
@Override
public Class getJavaClass() {
return annotatedType.getJavaClass();
}
@Override
public Set<AnnotatedConstructor> getConstructors() {
final Set<AnnotatedConstructor> result = new HashSet<>();
for (final AnnotatedConstructor c : annotatedType.getConstructors()) {
result.add(enrichedConstructor(c));
}
return result;
}
@Override
public Set getMethods() {
return annotatedType.getMethods();
}
@Override
public Set getFields() {
return annotatedType.getFields();
}
@Override
public Type getBaseType() {
return annotatedType.getBaseType();
}
@Override
public Set<Type> getTypeClosure() {
return annotatedType.getTypeClosure();
}
@Override
public <T extends Annotation> T getAnnotation(final Class<T> annotationType) {
return annotatedType.getAnnotation(annotationType);
}
@Override
public Set<Annotation> getAnnotations() {
return annotatedType.getAnnotations();
}
@Override
public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) {
return annotatedType.isAnnotationPresent(annotationType);
}
});
}
}
use of javax.enterprise.inject.spi.AnnotatedConstructor in project deltaspike by apache.
the class AnnotatedTypeBuilderTest method modifyAnnotationsOnConstructorParameter.
@Test
public void modifyAnnotationsOnConstructorParameter() throws NoSuchMethodException {
final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
builder.readFromType(Cat.class, true);
builder.removeFromConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, Default.class);
builder.addToConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, new AnyLiteral());
final AnnotatedType<Cat> catAnnotatedType = builder.create();
Set<AnnotatedConstructor<Cat>> catCtors = catAnnotatedType.getConstructors();
assertThat(catCtors.size(), is(2));
for (AnnotatedConstructor<Cat> ctor : catCtors) {
if (ctor.getParameters().size() == 2) {
List<AnnotatedParameter<Cat>> ctorParams = ctor.getParameters();
assertThat(ctorParams.get(1).getAnnotations().size(), is(1));
assertThat((AnyLiteral) ctorParams.get(1).getAnnotations().toArray()[0], is(new AnyLiteral()));
}
}
}
Aggregations