use of com.oracle.coherence.spring.annotation.MapEventTransformerFactory in project coherence-spring by coherence-community.
the class MapEventTransformerService method getMapEventTransformer.
/**
* Create a {@link MapEventTransformer} for the specified injection point.
* @param injectionPoint the injection point to inject a {@link MapEventTransformer} into
* @return a {@link MapEventTransformer} for the specified injection point
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
MapEventTransformer getMapEventTransformer(InjectionPoint injectionPoint) {
final List<Annotation> bindings = CoherenceAnnotationUtils.getAnnotationsMarkedWithMarkerAnnotation(injectionPoint, MapEventTransformerBinding.class);
for (Annotation annotation : bindings) {
final Class<? extends Annotation> annotationType = annotation.annotationType();
final MapEventTransformerFactory factory = CoherenceAnnotationUtils.getSingleBeanWithAnnotation(this.applicationContext, annotationType);
return factory.create(annotation);
}
throw new IllegalStateException("Unsatisfied dependency - no MapEventTransformerFactory bean found for bindings " + bindings);
}
use of com.oracle.coherence.spring.annotation.MapEventTransformerFactory in project coherence-spring by coherence-community.
the class MapEventTransformerService method resolve.
/**
* Resolve a {@link MapEventTransformer} from the
* specified qualifier annotations.
* @param annotations the qualifier annotations to use to create the transformer
* @param <K> the type of the keys of the entry to be transformed
* @param <V> the type of the values of the entry to be transformed
* @param <U> the type of the transformed values
* @return a {@link MapEventTransformer} from the specified qualifier annotations
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public <K, V, U> MapEventTransformer<K, V, U> resolve(Set<Annotation> annotations) {
Optional<Annotation> optionalTransformer = annotations.stream().filter((annotation) -> annotation.annotationType().isAnnotationPresent(MapEventTransformerBinding.class)).findFirst();
Optional<Annotation> optionalExtractor = annotations.stream().filter((annotation) -> annotation.annotationType().isAnnotationPresent(ExtractorBinding.class)).findFirst();
if (optionalTransformer.isPresent()) {
final Annotation annotation = optionalTransformer.get();
final Class<? extends Annotation> annotationType = annotation.annotationType();
final MapEventTransformerFactory factory = CoherenceAnnotationUtils.getSingleBeanWithAnnotation(this.applicationContext, annotationType);
return factory.create(annotation);
} else if (optionalExtractor.isPresent()) {
// there is one or more ExtractorBinding annotations
ValueExtractor<Object, Object> extractor = this.extractorFactory.resolve(annotations);
return new ExtractorEventTransformer(extractor);
}
// there are no transformer or extractor annotations.
return null;
}
Aggregations