Search in sources :

Example 1 with FilterBinding

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]));
}
Also used : ExtractorBinding(com.oracle.coherence.spring.annotation.ExtractorBinding) ArrayList(java.util.ArrayList) SubscriberGroup(com.oracle.coherence.spring.annotation.SubscriberGroup) ValueExtractor(com.tangosol.util.ValueExtractor) FilterBinding(com.oracle.coherence.spring.annotation.FilterBinding) Filter(com.tangosol.util.Filter) Subscriber(com.tangosol.net.topic.Subscriber) MergedAnnotations(org.springframework.core.annotation.MergedAnnotations) DependsOn(org.springframework.context.annotation.DependsOn) Scope(org.springframework.context.annotation.Scope) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

ExtractorBinding (com.oracle.coherence.spring.annotation.ExtractorBinding)1 FilterBinding (com.oracle.coherence.spring.annotation.FilterBinding)1 SubscriberGroup (com.oracle.coherence.spring.annotation.SubscriberGroup)1 Subscriber (com.tangosol.net.topic.Subscriber)1 Filter (com.tangosol.util.Filter)1 ValueExtractor (com.tangosol.util.ValueExtractor)1 ArrayList (java.util.ArrayList)1 Bean (org.springframework.context.annotation.Bean)1 DependsOn (org.springframework.context.annotation.DependsOn)1 Primary (org.springframework.context.annotation.Primary)1 Scope (org.springframework.context.annotation.Scope)1 MergedAnnotations (org.springframework.core.annotation.MergedAnnotations)1