Package org.postgresql.util
Enum ClassLoaderStrategy
- All Implemented Interfaces:
Serializable,Comparable<ClassLoaderStrategy>,java.lang.constant.Constable
Order in which the driver searches classloaders when loading a class named by a connection
property. The driver's own classloader can see only what is on its classpath, so in a non-flat
class path (for example an application server or an OSGi container) a user-supplied class may be
visible only through the
thread context classloader.
The class is NOT public API, so it is subject to change.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionTry the thread context classloader first, then fall back to the driver's classloader.Use the driver's classloader only.Try the driver's classloader first, then fall back to the thread context classloader. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionclassLoaders(ClassLoader driverClassLoader, ClassLoader contextClassLoader) Returns the non-null classloaders to try, in priority order.static ClassLoaderStrategyof(Properties info) Resolves the strategy from thePGProperty.CLASS_LOADER_STRATEGYconnection property.static ClassLoaderStrategyReturns the enum constant of this type with the specified name.static ClassLoaderStrategy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
DRIVER
Use the driver's classloader only. This was the behaviour before the strategy became configurable and is the safest choice when the thread context classloader is undefined. -
DRIVER_FIRST
Try the driver's classloader first, then fall back to the thread context classloader. The fallback heals environments where the class is reachable only through the context classloader, while keeping the driver's classloader authoritative. -
CONTEXT_FIRST
Try the thread context classloader first, then fall back to the driver's classloader. Use this in containers that manage class loading and expect their context classloader to win, even when the driver's classloader could resolve a class of the same name.
-
-
Field Details
-
value
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
of
Resolves the strategy from thePGProperty.CLASS_LOADER_STRATEGYconnection property.- Parameters:
info- connection properties- Returns:
- the configured strategy, or
DRIVER_FIRSTwhen the property is absent - Throws:
PSQLException- if the property holds an unknown value
-
classLoaders
public List<ClassLoader> classLoaders(ClassLoader driverClassLoader, ClassLoader contextClassLoader) Returns the non-null classloaders to try, in priority order. A null input (for instance a null context classloader) is dropped, so the list contains only classloaders the caller can use.- Parameters:
driverClassLoader- the driver's own classloadercontextClassLoader- the thread context classloader- Returns:
- an ordered list of non-null classloaders to try
-