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:org.arrow.service.engine.config.BusinessConditionBeanPostProcessor.java
/** * {@inheritDoc}/* ww w. j a va 2 s .com*/ */ @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (!(bean instanceof BusinessCondition)) { return bean; } if (AnnotationUtils.findAnnotation(bean.getClass(), EventTrigger.class) == null) { return bean; } ProxyFactory factory = new ProxyFactory(bean); factory.addAdvice(new BusinessConditionMethodInterceptor(beanName)); return factory.getProxy(); }
From source file:dk.clanie.actor.ActorAnnotationBeanPostProcessor.java
public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof AopInfrastructureBean) { // Ignore AOP infrastructure such as scoped proxies. return bean; }// w ww . ja v a2 s. c o m Class<?> targetClass = AopUtils.getTargetClass(bean); Actor annotation = AnnotationUtils.findAnnotation(targetClass, Actor.class); if (annotation != null) { // if (AopUtils.canApply(this.asyncAnnotationAdvisor, targetClass)) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(1); executor.setDaemon(true); String threadNamePrefix = beanName + ","; executor.setThreadNamePrefix(threadNamePrefix); executor.initialize(); ActorAnnotationAdvisor actorAnnotationAdvisor = new ActorAnnotationAdvisor(executor); if (bean instanceof Advised) { ((Advised) bean).addAdvisor(0, actorAnnotationAdvisor); return bean; } else { ProxyFactory proxyFactory = new ProxyFactory(bean); // Copy our properties (proxyTargetClass etc) inherited from ProxyConfig. proxyFactory.copyFrom(this); proxyFactory.addAdvisor(actorAnnotationAdvisor); return proxyFactory.getProxy(this.beanClassLoader); } } else { // No async proxy needed. return bean; } }
From source file:org.jasig.portlet.courses.dao.xml.Jaxb2CourseSummaryHttpMessageConverter.java
@Override public boolean canWrite(Class<?> clazz, MediaType mediaType) { return AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && isSupported(mediaType); }
From source file:org.kmnet.com.fw.web.token.transaction.TransactionTokenInfoStore.java
/** * Returns a new <code>TransactionTokenInfo<code> based on the annotation information received from handlerMethod <br> * <p>//from w w w.ja va 2 s. co m * Method Annotation given priority over Class Annotation * @param handlerMethod * @return TransactionTokenInfo */ TransactionTokenInfo createTransactionTokenInfo(final HandlerMethod handlerMethod) { TransactionTokenCheck methodAnnotation = handlerMethod.getMethodAnnotation(TransactionTokenCheck.class); TransactionTokenCheck classAnnotation = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), TransactionTokenCheck.class); if (methodAnnotation == null) { return new TransactionTokenInfo(null, TransactionTokenType.NONE); } String tokenName = createTokenName(classAnnotation, methodAnnotation); return new TransactionTokenInfo(tokenName, methodAnnotation.type()); }
From source file:org.springframework.data.web.JsonProjectingMethodInterceptorFactory.java
/** * Returns whether the given type contains a method with a {@link org.springframework.data.web.JsonPath} annotation. * /* w w w. j av a 2s . c o m*/ * @param type must not be {@literal null}. * @return */ private static boolean hasJsonPathAnnotation(Class<?> type) { for (Method method : type.getMethods()) { if (AnnotationUtils.findAnnotation(method, org.springframework.data.web.JsonPath.class) != null) { return true; } } return false; }
From source file:com.github.carlomicieli.nerdmovies.MockWebApplicationContextLoader.java
private void extractConfiguration(Class<?> clazz) { configuration = AnnotationUtils.findAnnotation(clazz, MockWebApplication.class); if (configuration == null) throw new IllegalArgumentException( "Test class " + clazz.getName() + " must be annotated @MockWebApplication."); }
From source file:springfox.bean.validators.plugins.Validators.java
private static <T extends Annotation> Optional<T> findAnnotation( Optional<? extends AnnotatedElement> annotatedElement, Class<T> annotationType) { if (annotatedElement.isPresent()) { return Optional.fromNullable(AnnotationUtils.findAnnotation(annotatedElement.get(), annotationType)); } else {/*from ww w .j a v a 2 s .com*/ return Optional.absent(); } }
From source file:de.olivergierke.ninjector.FieldInjectionRejectingBeanPostProcessor.java
@Override public Object postProcessBeforeInstantiation(final Class<?> beanClass, final String beanName) throws BeansException { ReflectionUtils.doWithFields(beanClass, new FieldCallback() { @Override/*from w w w. ja v a 2 s . c o m*/ public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { for (Class<? extends Annotation> annotationType : INJECTION_ANNOTATIONS) { if (AnnotationUtils.findAnnotation(field, annotationType) != null) { throw new BeanCreationNotAllowedException(beanName, String.format(ERROR, annotationType.getSimpleName(), field.getName(), beanClass.getSimpleName())); } } } }); return null; }