Top Fields Constructors Methods
org.hibernate.validator.internal.engine.resolver

public Class TraversableResolvers

extends Object
Class Inheritance
Imports
java.lang.invoke.MethodHandles, java.lang.reflect.Method, java.security.AccessController, .PrivilegedAction, jakarta.validation.TraversableResolver, .ValidationException, org.hibernate.validator.internal.IgnoreForbiddenApisErrors, org.hibernate.validator.internal.util.ReflectionHelper, org.hibernate.validator.internal.util.logging.Log, .LoggerFactory, org.hibernate.validator.internal.util.privilegedactions.GetMethod, .LoadClass, .NewInstance

Field Summary

Modifier and TypeField and Description
private static final String
JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME

Class to instantiate in case JPA 2 is on the classpath.

private static final Log
private static final String
PERSISTENCE_CLASS_NAME

Class to load to check whether JPA is on the classpath.

private static final String
PERSISTENCE_UTIL_METHOD

Method to check whether the found Persistence class is of the version 2

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TraversableResolver
getDefault()

Initializes and returns the default TraversableResolver depending on the environment.

private static TraversableResolver
private static <T> T
run(PrivilegedAction<T> action)

Runs the given privileged action, using a privileged block if required.

public static TraversableResolver

Returns:

The resolver for the duration of a validation call.
wrapWithCachingForSingleValidation
(TraversableResolver traversableResolver, boolean traversableResolverResultCacheEnabled)

Potentially wrap the TraversableResolver into a caching one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAMEback to summary
private static final String JPA_AWARE_TRAVERSABLE_RESOLVER_CLASS_NAME

Class to instantiate in case JPA 2 is on the classpath.

LOGback to summary
private static final Log LOG
PERSISTENCE_CLASS_NAMEback to summary
private static final String PERSISTENCE_CLASS_NAME

Class to load to check whether JPA is on the classpath.

PERSISTENCE_UTIL_METHODback to summary
private static final String PERSISTENCE_UTIL_METHOD

Method to check whether the found Persistence class is of the version 2

Constructor Detail

TraversableResolversback to summary
private TraversableResolvers()

Method Detail

getDefaultback to summary
public static TraversableResolver getDefault()

Initializes and returns the default 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.

getTraverseAllTraversableResolverback to summary
private static TraversableResolver getTraverseAllTraversableResolver()
runback to summary
private static <T> T run(PrivilegedAction<T> action)

Runs the given privileged action, using a privileged block if required.

Note

This must never be changed into a publicly available method to avoid execution of arbitrary privileged actions within HV's protection domain.

Annotations
@IgnoreForbiddenApisErrors
reason:SecurityManager is deprecated in JDK17
wrapWithCachingForSingleValidationback to summary
public static TraversableResolver wrapWithCachingForSingleValidation(TraversableResolver traversableResolver, boolean traversableResolverResultCacheEnabled)

Potentially wrap the 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.

Returns:TraversableResolver

The resolver for the duration of a validation call.