T
- representation of entity data filtering requested by provider.@Contract public interface ObjectProvider<T>
<T>
) 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, orResponse.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
HK2 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<ObjectProvider<MyFilteringObject>>
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<ObjectProvider<Object>>
javax.inject.Provider<ObjectProvider<ObjectGraph>>
Note: For most of the cases it is sufficient that users implement object graph transformer
by
extending AbstractObjectProvider
class.
AbstractObjectProvider
,
ObjectGraphTransformer
Modifier and Type | Method and Description |
---|---|
T |
getFilteringObject(Type genericType,
boolean forWriter,
Annotation... annotations)
Get reader/writer entity-filtering object for given type.
|
T getFilteringObject(Type genericType, boolean forWriter, Annotation... annotations)
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.Copyright © 2007-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.