List of usage examples for org.springframework.core.annotation AnnotationUtils findAnnotation
@Nullable public static <A extends Annotation> A findAnnotation(Class<?> clazz, @Nullable Class<A> annotationType)
From source file:com.hp.autonomy.frontend.find.core.web.GlobalExceptionHandler.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody/*from ww w. ja v a 2s .c om*/ public <E extends Exception> ErrorResponse handler(final E exception) throws E { // boilerplate - see http://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc if (AnnotationUtils.findAnnotation(exception.getClass(), ResponseStatus.class) != null) { throw exception; } final ErrorResponse errorResponse = new ErrorResponse(exception.getMessage()); log.error("Unhandled exception with uuid {}", errorResponse.getUuid()); log.error("Stack trace", exception); return errorResponse; }
From source file:edu.umn.msi.tropix.common.jobqueue.service.impl.JobProcessorQueueContextImpl.java
protected void submitJob(final JobProcessor<T> jobProcessor) { final Ticket ticket = jobProcessorQueue.submitJob(jobProcessor, AnnotationUtils.findAnnotation(getClass(), JobType.class).value()); ticketSupplier.set(ticket);/*from w ww. j ava 2s. co m*/ }
From source file:com.cloudera.csd.validation.references.components.ReflectionHelper.java
/** * Finds the annotation of the provided class by searching * the entire class hierarchy.//from w ww . ja v a 2 s .c o m * * @param clazz the class. * @param annotationType the annotation class. * @param <A> the annotation type. * @return the annotation if it exists. Null otherwise. */ @Nullable public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType) { return AnnotationUtils.findAnnotation(clazz, annotationType); }
From source file:ru.anr.base.facade.web.api.GlobalAPIExceptionHandler.java
/** * Processing a global exception//from ww w. ja v a2s. co m * * @param rq * Original Http request * @param ex * An exception * @return String response * @throws Exception * If rethrown */ @ExceptionHandler(value = { Exception.class, RuntimeException.class }) @ResponseBody public String process(HttpServletRequest rq, Exception ex) throws Exception { logger.debug("API exception: {}", rq.getContextPath(), ex); if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null) { throw ex; // Pre-defined exception handler exists } APICommand cmd = apis.error(ex); return cmd.getRawModel(); }
From source file:org.shredzone.cilla.core.event.EventServiceImpl.java
/** * Sets up the {@link EventService}. It scans for all beans annotated with * {@link EventListener}, and registers the events and handler methods. *///from w w w . ja v a 2s . co m @PostConstruct protected void setup() { applicationContext.getBeansWithAnnotation(EventListener.class).values().forEach(bean -> { for (Method method : bean.getClass().getMethods()) { OnEvent evAnno = AnnotationUtils.findAnnotation(method, OnEvent.class); if (evAnno != null) { processEventMethod(evAnno, bean, method); } } }); }
From source file:org.netxilia.spi.impl.formula.function.FunctionRegistry.java
private boolean isFunctionSet(Object bean) { return AnnotationUtils.findAnnotation(bean.getClass(), Functions.class) != null; }
From source file:springfox.documentation.schema.property.bean.Accessors.java
private static Optional<JsonSetter> setterAnnotation(Method method) { return Optional.fromNullable(AnnotationUtils.findAnnotation(method, JsonSetter.class)); }
From source file:springfox.documentation.builders.MockRequestHandler.java
@Override public boolean isAnnotatedWith(Class<? extends Annotation> annotation) { return null != AnnotationUtils.findAnnotation(handlerMethod.getMethod(), annotation); }
From source file:org.netxilia.jaxrs.js.SpringBeanProcessor.java
private boolean isRestRootResource(Object bean) { return AnnotationUtils.findAnnotation(bean.getClass(), Path.class) != null; }
From source file:jails.http.converter.xml.Jaxb2RootElementHttpMessageConverter.java
@Override public boolean canWrite(Class<?> clazz, MediaType mediaType) { return AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && canWrite(mediaType); }