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:
@@ -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>
|
||||
* @Persistent
|
||||
* @Documented
|
||||
* @Retention(RetentionPolicy.RUNTIME)
|
||||
* @Target({ ElementType.TYPE })
|
||||
* public @interface Document {
|
||||
*
|
||||
* @KeySpace
|
||||
* String collection() default "person";
|
||||
* }
|
||||
* static @interface CacheCentricAnnotation {
|
||||
*
|
||||
* @AliasFor(annotation = KeySpace.class, attribute = "value")
|
||||
* String cacheRegion() default "";
|
||||
* }
|
||||
*
|
||||
* @CacheCentricAnnotation(cacheRegion = "customers")
|
||||
* class Customer {
|
||||
* //...
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* Can also be directly used on types to indicate the keyspace.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* @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 "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user