public class TraversableResolvers extends Object
Modifier and Type | Method and Description |
---|---|
static TraversableResolver |
getDefault()
Initializes and returns the default
TraversableResolver depending on the environment. |
static TraversableResolver |
wrapWithCachingForSingleValidation(TraversableResolver traversableResolver,
boolean traversableResolverResultCacheEnabled)
Potentially wrap the
TraversableResolver into a caching one. |
public static TraversableResolver getDefault()
TraversableResolver
depending on the environment.
If JPA 2 is present in the classpath, a JPATraversableResolver
instance is returned.
Otherwise, it returns an instance of the default TraverseAllTraversableResolver
.
public static TraversableResolver wrapWithCachingForSingleValidation(TraversableResolver traversableResolver, boolean traversableResolverResultCacheEnabled)
TraversableResolver
into a caching one.
If traversableResolver
is TraverseAllTraversableResolver.INSTANCE
, we don't wrap it and it is
returned directly. Same if the caching is explicitly disabled.
If traversableResolver
is an instance of our JPATraversableResolver
, we wrap it with a caching
wrapper specially tailored for the requirements of the spec. It is a very common case as it is used as soon as we
have a JPA implementation in the classpath so optimizing this case is worth it.
In all the other cases, we wrap the resolver for caching.
Note that, in the TraversableResolver
is wrapped, a new instance is returned each time and it should be
used only for the duration of a validation call.
Copyright © 2021 JBoss by Red Hat. All rights reserved.