All Downloads are FREE. Search and download functionalities are using the official Maven repository.

athenz.shade.zts.org.glassfish.jersey.message.filtering.EntityFiltering Maven / Gradle / Ivy

There is a newer version: 1.11.59
Show newest version
/*
 * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package athenz.shade.zts.athenz.shade.zts.org.glassfish.jersey.message.filtering;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Meta-annotation used to create entity filtering annotations for entity (model) classes and resource methods and resources.
 * 

* Entity Data Filtering via annotations is supposed to be used to annotate: *

    *
  • entity classes (supported on both, server and client sides), and
  • *
  • resource methods / resource classes (server side)
  • *
*

*

* In entity filtering, a entity-filtering annotation is first defined using the {@code @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 {@code 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 * {@link athenz.shade.zts.athenz.shade.zts.javax.ws.rs.client.Entity#entity(Object, athenz.shade.zts.athenz.shade.zts.javax.ws.rs.core.MediaType, java.lang.annotation.Annotation[]) 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()}));
 * 
*

* * @author Michal Gajdos */ @Target(ElementType.ANNOTATION_TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface EntityFiltering { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy