DATAKV-213 - Update usage example for composed annotations using KeySpace.

We now mention an example using AliasFor that is used via AnnotatedElementUtils.findMergedAnnotation(…) to retrieve the keyspace value.
This commit is contained in:
Mark Paluch
2018-04-03 15:32:38 +02:00
parent 18bacda202
commit 955075c74b

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,38 +27,46 @@ import org.springframework.data.annotation.Persistent;
/**
* Marker interface for methods with {@link Persistent} annotations indicating the presence of a dedicated keyspace the
* entity should reside in. If present the value will be picked up for resolving the keyspace.
*
*
* <pre>
* <code>
* &#64;Persistent
* &#64;Documented
* &#64;Retention(RetentionPolicy.RUNTIME)
* &#64;Target({ ElementType.TYPE })
* public &#64;interface Document {
*
* &#64;KeySpace
* String collection() default "person";
* }
* static @interface CacheCentricAnnotation {
*
* &#64;AliasFor(annotation = KeySpace.class, attribute = "value")
* String cacheRegion() default "";
* }
*
* &#64;CacheCentricAnnotation(cacheRegion = "customers")
* class Customer {
* //...
* }
* </code>
* </pre>
*
*
* Can also be directly used on types to indicate the keyspace.
*
*
* <pre>
* <code>
* &#64;KeySpace("persons")
* public class Foo {
*
* }
*
* }
* </code>
* </pre>
*
*
* @author Christoph Strobl
* @author Mark Paluch
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(value = { METHOD, TYPE })
public @interface KeySpace {
/**
* @return dedicated keyspace the entity should reside in.
*/
String value() default "";
}