/** * Returns true if the annotation is present on the type or it is present on one of the type annotations. * * @param annotationClass the annotation type * @param type the type * @return true if present */ public static <A extends Annotation> boolean isPresent(Class<A> annotationClass, Class<?> type) { return findAnnotation(annotationClass, type) != null; }
protected void processService(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { A annotation = AnnotationHelper.findAnnotation(annotationType, implClass); if (annotation == null) { return;
private void writeAnnotations(ClassWriter cw, Class<?> delegateClass) { Provider provider = AnnotationHelper.findAnnotation(Provider.class, delegateClass); if (provider != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Provider.class), true); av.visitEnd(); Priority priority = AnnotationHelper.findAnnotation(Priority.class, delegateClass); if (priority != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Priority.class), true); Produces produces = AnnotationHelper.findAnnotation(Produces.class, delegateClass); if (produces != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Produces.class), true); Consumes consumes = AnnotationHelper.findAnnotation(Consumes.class, delegateClass); if (consumes != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Consumes.class), true);
private void writeAnnotations(ClassWriter cw, Class<?> delegateClass) { Provider provider = AnnotationHelper.findAnnotation(Provider.class, delegateClass); if (provider != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Provider.class), true); av.visitEnd(); Priority priority = AnnotationHelper.findAnnotation(Priority.class, delegateClass); if (priority != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Priority.class), true); Produces produces = AnnotationHelper.findAnnotation(Produces.class, delegateClass); if (produces != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Produces.class), true); Consumes consumes = AnnotationHelper.findAnnotation(Consumes.class, delegateClass); if (consumes != null) { AnnotationVisitor av = cw.visitAnnotation(getSignature(Consumes.class), true);
private Resource createResource(F3ResourceHandler handler) { Class<?> interfaze = handler.getInterface(); Resource template = Resource.from(interfaze); if (template == null) { throw new Fabric3Exception("Interface is not a JAX-RS resource: " + interfaze.getName()); } // introspect consumes and produces annotations on the JAX-RS type as well as in meta-annotations Consumes consumes = AnnotationHelper.findAnnotation(Consumes.class, interfaze); String[] consumeTypes = consumes != null ? consumes.value() : EMPTY_ARRAY; Produces produces = AnnotationHelper.findAnnotation(Produces.class, interfaze); String[] produceTypes = produces != null ? produces.value() : EMPTY_ARRAY; Resource.Builder resourceBuilder = Resource.builder(template.getPath()); for (ResourceMethod resourceMethod : template.getAllMethods()) { createMethod(resourceBuilder, resourceMethod, handler, consumeTypes, produceTypes); } for (Resource childTemplate : template.getChildResources()) { Resource.Builder childResourceBuilder = Resource.builder(childTemplate.getPath()); for (ResourceMethod resourceMethod : childTemplate.getAllMethods()) { createMethod(childResourceBuilder, resourceMethod, handler, consumeTypes, produceTypes); } resourceBuilder.addChildResource(childResourceBuilder.build()); } return resourceBuilder.build(); }
private Resource createResource(F3ResourceHandler handler) { Class<?> interfaze = handler.getInterface(); Resource template = Resource.from(interfaze); if (template == null) { throw new Fabric3Exception("Interface is not a JAX-RS resource: " + interfaze.getName()); } // introspect consumes and produces annotations on the JAX-RS type as well as in meta-annotations Consumes consumes = AnnotationHelper.findAnnotation(Consumes.class, interfaze); String[] consumeTypes = consumes != null ? consumes.value() : EMPTY_ARRAY; Produces produces = AnnotationHelper.findAnnotation(Produces.class, interfaze); String[] produceTypes = produces != null ? produces.value() : EMPTY_ARRAY; Resource.Builder resourceBuilder = Resource.builder(template.getPath()); for (ResourceMethod resourceMethod : template.getAllMethods()) { createMethod(resourceBuilder, resourceMethod, handler, consumeTypes, produceTypes); } for (Resource childTemplate : template.getChildResources()) { Resource.Builder childResourceBuilder = Resource.builder(childTemplate.getPath()); for (ResourceMethod resourceMethod : childTemplate.getAllMethods()) { createMethod(childResourceBuilder, resourceMethod, handler, consumeTypes, produceTypes); } resourceBuilder.addChildResource(childResourceBuilder.build()); } return resourceBuilder.build(); }