List of usage examples for org.springframework.core.annotation AnnotationUtils getValue
@Nullable public static Object getValue(@Nullable Annotation annotation, @Nullable String attributeName)
From source file:com.frank.search.solr.repository.query.SolrQueryMethod.java
@SuppressWarnings("unchecked") private List<String> getAnnotationValuesAsStringList(Annotation annotation, String attribute) { String[] values = (String[]) AnnotationUtils.getValue(annotation, attribute); if (values.length > 1 || (values.length == 1 && StringUtils.hasText(values[0]))) { return CollectionUtils.arrayToList(values); }/*ww w . j av a 2 s . c om*/ return Collections.emptyList(); }
From source file:com.frank.search.solr.repository.query.SolrQueryMethod.java
@SuppressWarnings("unchecked") private <T> List<T> getAnnotationValuesList(Annotation annotation, String attribute, Class<T> clazz) { T[] values = (T[]) AnnotationUtils.getValue(annotation, attribute); return CollectionUtils.arrayToList(values); }
From source file:ch.rasc.wampspring.method.WampAnnotationMethodMessageHandler.java
private <A extends Annotation> void detectHandlerMethods(String beanName, Class<?> userType, final Class<A> annotationType) { Set<Method> methods = HandlerMethodSelector.selectMethods(userType, new MethodFilter() { @Override/* ww w . j a v a 2 s . c o m*/ public boolean matches(Method method) { return AnnotationUtils.findAnnotation(method, annotationType) != null; } }); for (Method method : methods) { A annotation = AnnotationUtils.findAnnotation(method, annotationType); String[] replyTo = (String[]) AnnotationUtils.getValue(annotation, "replyTo"); Boolean excludeSender = (Boolean) AnnotationUtils.getValue(annotation, "excludeSender"); Boolean broadcast = (Boolean) AnnotationUtils.getValue(annotation, "broadcast"); boolean authenticationRequiredClass = AnnotationUtils.findAnnotation(userType, WampAuthenticated.class) != null; boolean[] authenticationRequiredMethod = (boolean[]) AnnotationUtils.getValue(annotation, "authenticated"); boolean authenticationRequired = false; if (authenticationRequiredMethod != null && authenticationRequiredMethod.length == 1) { authenticationRequired = authenticationRequiredMethod[0]; } else if (authenticationRequiredClass || this.authenticationRequiredGlobal) { authenticationRequired = true; } WampHandlerMethod newHandlerMethod = new WampHandlerMethod(beanName, this.applicationContext, method, replyTo, broadcast, excludeSender, authenticationRequired); String[] destinations = (String[]) AnnotationUtils.getValue(annotation); if (destinations.length == 0) { // by default use beanName.methodName as destination destinations = new String[] { beanName + "." + method.getName() }; } WampMessageMappingInfo mapping = null; if (annotationType.equals(WampCallListener.class)) { mapping = new WampMessageMappingInfo(WampMessageTypeMessageCondition.CALL, new DestinationPatternsMessageCondition(destinations, this.pathMatcher)); } else if (annotationType.equals(WampPublishListener.class)) { mapping = new WampMessageMappingInfo(WampMessageTypeMessageCondition.PUBLISH, new DestinationPatternsMessageCondition(destinations, this.pathMatcher)); } else if (annotationType.equals(WampSubscribeListener.class)) { mapping = new WampMessageMappingInfo(WampMessageTypeMessageCondition.SUBSCRIBE, new DestinationPatternsMessageCondition(destinations, this.pathMatcher)); } else if (annotationType.equals(WampUnsubscribeListener.class)) { mapping = new WampMessageMappingInfo(WampMessageTypeMessageCondition.UNSUBSCRIBE, new DestinationPatternsMessageCondition(destinations, this.pathMatcher)); } registerHandlerMethod(newHandlerMethod, mapping); } }
From source file:org.springframework.integration.config.annotation.AbstractMethodAnnotationPostProcessor.java
protected void checkMessageHandlerAttributes(String handlerBeanName, List<Annotation> annotations) { for (String attribute : this.messageHandlerAttributes) { for (Annotation annotation : annotations) { Object value = AnnotationUtils.getValue(annotation, attribute); if (MessagingAnnotationUtils.hasValue(value)) { throw new BeanDefinitionValidationException("The MessageHandler [" + handlerBeanName + "] can not" + " be populated because of ambiguity with annotation attributes " + this.messageHandlerAttributes + " which are not allowed when an integration annotation " + "is used with a @Bean definition for a MessageHandler." + "\nThe attribute causing the ambiguity is: [" + attribute + "]." + "\nUse the appropriate setter on the MessageHandler directly when configuring an " + "endpoint this way."); }/* w w w . ja v a2s . c om*/ } } }
From source file:org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.java
private boolean shouldCreateEndpoint(Annotation annotation) { Object inputChannel = AnnotationUtils.getValue(annotation, "inputChannel"); return (inputChannel != null && inputChannel instanceof String && StringUtils.hasText((String) inputChannel)); }
From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java
public void callOnStateChanged(String stateMachineId, StateContext<S, E> stateContext) { List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>(); String cacheKey = OnStateChanged.class.getName() + stateMachineId; List<CacheEntry> list = getCacheEntries(cacheKey); if (list == null) { return;//from w ww .j av a 2 s .com } for (CacheEntry entry : list) { if (annotationHandlerSourceTargetMatch( (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"), (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation, stateContext.getSource(), stateContext.getTarget())) { handlersList.add(entry.handler); } } getStateMachineHandlerResults(handlersList, stateContext); }
From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java
public void callOnStateEntry(String stateMachineId, StateContext<S, E> stateContext) { List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>(); String cacheKey = OnStateEntry.class.getName() + stateMachineId; List<CacheEntry> list = getCacheEntries(cacheKey); if (list == null) { return;// w ww. j av a 2s . c om } for (CacheEntry entry : list) { if (annotationHandlerSourceTargetMatch( (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"), (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation, stateContext.getSource(), stateContext.getTarget())) { handlersList.add(entry.handler); } } getStateMachineHandlerResults(handlersList, stateContext); }
From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java
public void callOnStateExit(String stateMachineId, StateContext<S, E> stateContext) { List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>(); String cacheKey = OnStateExit.class.getName() + stateMachineId; List<CacheEntry> list = getCacheEntries(cacheKey); if (list == null) { return;/*from w w w.j a v a 2 s .c o m*/ } for (CacheEntry entry : list) { if (annotationHandlerSourceTargetMatch( (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"), (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation, stateContext.getSource(), stateContext.getTarget())) { handlersList.add(entry.handler); } } getStateMachineHandlerResults(handlersList, stateContext); }
From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java
public void callOnTransitionStart(String stateMachineId, StateContext<S, E> stateContext) { List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>(); String cacheKey = OnTransitionStart.class.getName() + stateMachineId; List<CacheEntry> list = getCacheEntries(cacheKey); if (list == null) { return;/*from w ww . j a v a 2 s . c om*/ } for (CacheEntry entry : list) { if (annotationHandlerSourceTargetMatch( (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"), (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation, stateContext.getTransition().getSource(), stateContext.getTransition().getTarget())) { handlersList.add(entry.handler); } } getStateMachineHandlerResults(handlersList, stateContext); }
From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java
public void callOnTransition(String stateMachineId, StateContext<S, E> stateContext) { List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>(); String cacheKey = OnTransition.class.getName() + stateMachineId; List<CacheEntry> list = getCacheEntries(cacheKey); if (list == null) { return;/*from ww w. j a v a 2 s . c om*/ } for (CacheEntry entry : list) { if (annotationHandlerSourceTargetMatch( (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"), (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation, stateContext.getTransition().getSource(), stateContext.getTransition().getTarget())) { handlersList.add(entry.handler); } } getStateMachineHandlerResults(handlersList, stateContext); }