Interface ObjectProvider<T>

Type Parameters:
T - representation of entity data filtering requested by provider.
All Known Implementing Classes:
AbstractObjectProvider, JacksonObjectProvider, ObjectGraphProvider

@Contract public interface ObjectProvider<T>
Entry point of Entity Data Filtering feature for providers working with custom entities and media types (reading/writing). Exposed methods are supposed to provide an entity-filtering object of defined type (generic parameter type &lt;T&gt;) for given types/classes that is requested by underlying provider (e.g. message body worker).

Methods are also accepting a list of entity annotations which entity-filtering scopes and then particular entity-filtering object are determined from. Entity annotations can be passed to the runtime via:

  • Entity.entity(Object, javax.ws.rs.core.MediaType, java.lang.annotation.Annotation[]) on the client, or
  • Response.ResponseBuilder.entity(Object, java.lang.annotation.Annotation[]) on the server

Custom implementations should, during processing, look up for available entity processors to examine given entity classes and scope providers to determine the current entity-filtering scope. Entity class and entity-filtering scopes determine the object graph passed to object graph transformer and hence the resulting entity-filtering object.

Implementations should be registered into client/server runtime via jersey binder (for more information and common implementation see AbstractObjectProvider):

 bindAsContract(MyObjectProvider.class)
       // FilteringGraphTransformer.
       .to(new TypeLiteral<ObjectGraphTransformer<MyFilteringObject>>() {})
       // Scope.
       .in(Singleton.class);
 
The custom provider can be then injected as one these injection point types:
  • MyObjectProvider
  • javax.inject.Provider&lt;ObjectProvider&lt;MyFilteringObject&gt;&gt;

By default a ObjectGraph provider is available in the runtime. This object provider can be injected (via @Inject) into the following types:

  • ObjectProvider
  • javax.inject.Provider&lt;ObjectProvider&lt;Object&gt;&gt;
  • javax.inject.Provider&lt;ObjectProvider&lt;ObjectGraph&gt;&gt;

Note: For most of the cases it is sufficient that users implement object graph transformer by extending AbstractObjectProvider class.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    getFilteringObject(Type genericType, boolean forWriter, Annotation... annotations)
    Get reader/writer entity-filtering object for given type.
  • Method Details

    • getFilteringObject

      T getFilteringObject(Type genericType, boolean forWriter, Annotation... annotations)
      Get reader/writer entity-filtering object for given type.
      Parameters:
      genericType - type for which the object is requested.
      forWriter - flag to determine whether to create object for reading/writing purposes.
      annotations - entity annotations to determine the runtime scope.
      Returns:
      entity-filtering object.