use of com.oracle.coherence.spring.annotation.FilterBinding in project coherence-spring by coherence-community.
the class NamedTopicConfiguration method getSubscriber.
@SuppressWarnings("unchecked")
@Bean(destroyMethod = "release")
@DependsOn(CoherenceSpringConfiguration.COHERENCE_SERVER_BEAN_NAME)
@Primary
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
<V> Subscriber<V> getSubscriber(InjectionPoint injectionPoint) {
List<Subscriber.Option> options = new ArrayList<>();
final MergedAnnotations mergedAnnotations = MergedAnnotations.from(injectionPoint.getAnnotatedElement());
final MergedAnnotation<SubscriberGroup> mergedSubscribedGroupAnnotation = mergedAnnotations.get(SubscriberGroup.class);
if (mergedSubscribedGroupAnnotation.isPresent()) {
String subscribedGroupName = mergedSubscribedGroupAnnotation.synthesize().value();
if (StringUtils.hasLength(subscribedGroupName)) {
options.add(Subscriber.Name.of(subscribedGroupName));
}
}
final MergedAnnotation<FilterBinding> mergedFilterBindingAnnotation = mergedAnnotations.get(FilterBinding.class);
if (mergedFilterBindingAnnotation.isPresent()) {
Filter filter = this.filterService.getFilter(injectionPoint);
options.add(Subscriber.Filtered.by(filter));
}
final MergedAnnotation<ExtractorBinding> mergedExtractorBindingAnnotation = mergedAnnotations.get(ExtractorBinding.class);
if (mergedExtractorBindingAnnotation.isPresent()) {
ValueExtractor extractor = this.extractorService.getExtractor(injectionPoint);
options.add(Subscriber.Convert.using(extractor));
}
NamedTopic<V> topic = getTopicInternal(injectionPoint);
return options.isEmpty() ? topic.createSubscriber() : topic.createSubscriber(options.toArray(new Subscriber.Option[0]));
}
Aggregations