use of com.oracle.coherence.spring.annotation.CoherenceTopicListener in project coherence-spring by coherence-community.
the class CoherenceTopicListenerPostProcessor method processBean.
private void processBean(final String beanName, final Class<?> targetType) {
if (!this.nonAnnotatedClasses.contains(targetType) && AnnotationUtils.isCandidateClass(targetType, CoherenceTopicListener.class) && !isSpringContainerClass(targetType)) {
Map<Method, CoherenceTopicListener> annotatedMethods = null;
try {
final MethodIntrospector.MetadataLookup<CoherenceTopicListener> metadataLookup = (method) -> AnnotationUtils.getAnnotation(method, CoherenceTopicListener.class);
annotatedMethods = MethodIntrospector.selectMethods(targetType, metadataLookup);
} catch (Throwable ex) {
// An unresolvable type in a method signature, probably from a lazy bean - let's ignore it.
if (logger.isDebugEnabled()) {
logger.debug("Could not resolve methods for bean with name '" + beanName + "'", ex);
}
}
CoherenceTopicListener classAnnotation = AnnotationUtils.getAnnotation(targetType, CoherenceTopicListener.class);
if (classAnnotation != null) {
Map<Method, CoherenceTopicListener> notAnnotatedMethods = MethodIntrospector.selectMethods(targetType, (MethodIntrospector.MetadataLookup<CoherenceTopicListener>) (method) -> {
if (!method.isAnnotationPresent(CoherenceTopicListener.class) && method.getParameterCount() == 1) {
return classAnnotation;
}
return null;
});
annotatedMethods.putAll(notAnnotatedMethods);
}
if (CollectionUtils.isEmpty(annotatedMethods)) {
this.nonAnnotatedClasses.add(targetType);
if (logger.isTraceEnabled()) {
logger.trace("No @CoherenceTopicListener annotations found on bean class: " + targetType.getName());
}
} else {
for (Method method : annotatedMethods.keySet()) {
if (method.getParameterCount() != 1) {
throw new IllegalArgumentException("The @CoherenceTopicListener annotated method " + method.getName() + " must have a single argument.");
}
this.addTopicListenerCandidate(beanName, method);
}
if (logger.isDebugEnabled()) {
logger.debug(annotatedMethods.size() + " @CoherenceTopicListener methods processed on bean '" + beanName + "': " + annotatedMethods);
}
}
}
}
Aggregations