Class VersionedReference<T>
- java.lang.Object
-
- com.identityworksllc.iiq.common.VersionedReference<T>
-
- Type Parameters:
T- the type of the value held in this reference
- All Implemented Interfaces:
Supplier<T>
public class VersionedReference<T> extends Object implements Supplier<T>
A container for a single value that is associated with the plugin cache version.If the plugin cache is updated, the version increments, and the provided
Supplierwill be invoked to get a new value on the next call toget().This allows consistent references to plugin-provided classes, even if the plugin is updated and a new version of the class is hot-deployed.
Your
Suppliercode should always assume that the plugin cache has been refreshed since the last invocation and never cache plugin objects.The object type T, of course, cannot be the actual implementation in the plugin classloader, as that class will have become invalid when the plugin cache was reset. The type T should be either a JDK class or a custom interface implemented at the webapp layer.
-
-
Constructor Summary
Constructors Constructor Description VersionedReference(Supplier<? extends T> supplier)Creates a new VersionedThreadLocal with the given supplier.
-
-
-
Constructor Detail
-
VersionedReference
public VersionedReference(Supplier<? extends T> supplier)
Creates a new VersionedThreadLocal with the given supplier.The initial value will not be calculated until the first call to
get().- Parameters:
supplier- the initial value supplier
-
-