use of javax.enterprise.inject.spi.AnnotatedMember in project wildfly by wildfly.
the class WeldResourceInjectionServices method resolveResource.
@Override
public Object resolveResource(InjectionPoint injectionPoint) {
final Member member = injectionPoint.getMember();
AnnotatedMember<?> annotatedMember;
if (injectionPoint.getAnnotated() instanceof AnnotatedField) {
annotatedMember = (AnnotatedField<?>) injectionPoint.getAnnotated();
} else {
annotatedMember = ((AnnotatedParameter<?>) injectionPoint.getAnnotated()).getDeclaringCallable();
}
if (!annotatedMember.isAnnotationPresent(Resource.class)) {
throw WeldLogger.ROOT_LOGGER.annotationNotFound(Resource.class, member);
}
if (member instanceof Method && ((Method) member).getParameterTypes().length != 1) {
throw WeldLogger.ROOT_LOGGER.injectionPointNotAJavabean((Method) member);
}
String name = getResourceName(injectionPoint);
for (ResourceInjectionResolver resolver : resourceResolvers) {
Object result = resolver.resolve(name);
if (result != null) {
return result;
}
}
try {
return context.lookup(name);
} catch (NamingException e) {
throw WeldLogger.ROOT_LOGGER.couldNotFindResource(name, injectionPoint.getMember().toString(), e);
}
}
use of javax.enterprise.inject.spi.AnnotatedMember in project deltaspike by apache.
the class DefaultMockFilter method isMockedImplementationSupported.
@Override
public boolean isMockedImplementationSupported(BeanManager beanManager, Annotated annotated) {
if (!isMockSupportEnabled(annotated)) {
return false;
}
Class origin = null;
if (annotated instanceof AnnotatedType) {
origin = ((AnnotatedType) annotated).getJavaClass();
Set<Annotation> annotations = new HashSet<Annotation>();
annotations.addAll(annotated.getAnnotations());
for (AnnotatedMethod annotatedMethod : (Set<javax.enterprise.inject.spi.AnnotatedMethod>) ((AnnotatedType) annotated).getMethods()) {
annotations.addAll(annotatedMethod.getAnnotations());
}
if (isEjbOrAnnotatedTypeWithInterceptorAnnotation(beanManager, annotations, origin.getName())) {
return false;
}
} else if (annotated instanceof AnnotatedMember) {
Member member = ((AnnotatedMember) annotated).getJavaMember();
origin = member.getDeclaringClass();
if (isEjbOrAnnotatedTypeWithInterceptorAnnotation(beanManager, annotated.getAnnotations(), member.toString())) {
return false;
}
}
if (origin != null && origin.getPackage() == null) {
LOG.warning("Please don't use the default-package for " + origin.getName());
return true;
}
return origin != null && !isInternalPackage(origin.getPackage().getName());
}
Aggregations