@Target(value=ANNOTATION_TYPE) @Retention(value=RUNTIME) @Documented public @interface EntityFiltering
Entity Data Filtering via annotations is supposed to be used to annotate:
In entity filtering, a entity-filtering annotation is first defined using the @EntityFiltering
meta-annotation:
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) @Retention(value = RetentionPolicy.RUNTIME) @EntityFiltering public @interface DetailedView { public static class Factory extends AnnotationLiteral<DetailedView> implements DetailedView { public static DetailedView get() { return new Factory(); } } }
Entity-filtering annotation should provide a factory class/method to create an instance of the annotation. Example of such
factory can be seen in the DetailedView
above. Such instances can be then passed to the client/server runtime to
define/override entity-filtering scopes.
The defined entity-filtering annotation is then used to decorate a entity, it's property accessors or fields (more than one entity may be decorated with the same entity-filtering annotation):
public class MyEntityClass { @DetailedView private String myField; ... }
At last, on the server-side, the entity-filtering annotations are applied to the resource or resource method(s) to which the entity-filtering should be applied:
@Path("/") public class MyResourceClass { @GET @Produces("text/plain") @Path("{id}") @DetailedView public MyEntityClass get(@PathParam("id") String id) { // Return MyEntityClass. } }
At last, on the client-side, the entity-filtering annotations are passed to the runtime via
Entity.entity()
method and the entity-filtering scopes are then derived from the annotations:
ClientBuilder.newClient() .target("resource") .request() .post(Entity.entity(myentity, "application/json", new Annotation[] {MyEntityClass.Factory.get()}));
Copyright © 2007-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.