Class AbstractObjectProvider<T>
java.lang.Object
org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider<T>
- Type Parameters:
T
- representation of entity data filtering requested by provider.
- All Implemented Interfaces:
ObjectGraphTransformer<T>
,ObjectProvider<T>
- Direct Known Subclasses:
JacksonObjectProvider
,ObjectGraphProvider
public abstract class AbstractObjectProvider<T>
extends Object
implements ObjectProvider<T>, ObjectGraphTransformer<T>
Common implementation of
object provider
and object graph transformer
.
Extensions of this class must provide a type of entity-filtering object (via generic type parameter) the requesting provider
(e.g. message body worker) is familiar with and an implementation of
ObjectGraphTransformer.transform(ObjectGraph)
method for this type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Class to be used as a key in cache (EntityContext
-> filtering object) when processing similar requests. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate EntityInspector
private final com.google.common.cache.Cache<AbstractObjectProvider.EntityContext,
T> private EntityGraphProvider
private static final int
private ScopeProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate T
createFilteringObject
(Class<?> entityClass, Set<String> filteringScopes, boolean forWriter) Create entity-filtering object after this object has not been found in the cache.private Annotation[]
getEntityAnnotations
(Annotation[] annotations) Get entity annotations passed to request/response.private T
getFilteringObject
(Class<?> entityClass, boolean forWriter, Annotation... annotations) final T
getFilteringObject
(Type genericType, boolean forWriter, Annotation... annotations) Get reader/writer entity-filtering object for given type.immutableSetOf
(Set<String> set, String item) A helper method for a creation of an immutable set based on a provided set together with a given item.protected String
subgraphIdentifier
(Class<?> parent, String field, Class<?> fieldClass) Creates a string identifier of a sub-graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.glassfish.jersey.message.filtering.spi.ObjectGraphTransformer
transform
-
Field Details
-
PROVIDER_CACHE_SIZE
private static final int PROVIDER_CACHE_SIZE- See Also:
-
filteringObjects
private final com.google.common.cache.Cache<AbstractObjectProvider.EntityContext,T> filteringObjects -
scopeProvider
-
entityInspector
-
graphProvider
-
-
Constructor Details
-
AbstractObjectProvider
public AbstractObjectProvider()
-
-
Method Details
-
getFilteringObject
Description copied from interface:ObjectProvider
Get reader/writer entity-filtering object for given type.- Specified by:
getFilteringObject
in interfaceObjectProvider<T>
- 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.
-
getFilteringObject
-
getEntityAnnotations
Get entity annotations passed to request/response. This method filters annotations that are proxy instances (proxy annotations are taken from resource method and passed in this list).- Parameters:
annotations
- annotations obtained from provider.- Returns:
- annoations passed to request/response.
-
createFilteringObject
private T createFilteringObject(Class<?> entityClass, Set<String> filteringScopes, boolean forWriter) Create entity-filtering object after this object has not been found in the cache.- Parameters:
entityClass
- entity class the entity-filtering object should be created for.filteringScopes
- entity-filtering scopes to create the entity-filtering object for.forWriter
- flag determining whether the class should be examined for reader or writer.- Returns:
- entity-filtering object.
-
immutableSetOf
A helper method for a creation of an immutable set based on a provided set together with a given item.- Parameters:
set
- The set to create the immutable set from.item
- The item to add to the set before it's made immutable.- Returns:
- The immutable set from given set and item.
-
subgraphIdentifier
Creates a string identifier of a sub-graph.- Parameters:
parent
- The parent class.field
- The field name.fieldClass
- The class of the field.- Returns:
- The string identifier of the sub-graph.
-