Class CachingLicenseProvider
java.lang.Object
com.aquima.interactions.foundation.lic.CachingLicenseProvider
- All Implemented Interfaces:
ILicenseProvider
This class may be used to cache license keys from a delegate (slow) license provider.
- Since:
- 8.1
- Author:
- Jon van Leuven
-
Constructor Summary
ConstructorsConstructorDescriptionCachingLicenseProvider
(ILicenseProvider delegate) Create a caching license key that delegate all method calls only once. -
Method Summary
Modifier and TypeMethodDescriptionstatic CachingLicenseProvider
createAndCache
(ILicenseProvider delegate) This method can be used to create a caching license provider and initialize the cached values.This method will call the delegate getLicenseKey method only once and caches its result.boolean
This method will call the delegate hasLicenseKey method only once and caches its result.boolean
Use this method to reset the cached license key.
-
Constructor Details
-
CachingLicenseProvider
Create a caching license key that delegate all method calls only once.- Parameters:
delegate
- The delegating license provider, may not be null.
-
-
Method Details
-
createAndCache
This method can be used to create a caching license provider and initialize the cached values.- Parameters:
delegate
- The license provider to cache, may be null.- Returns:
- The caching license provider, may be null when null is passed as argument.
- Throws:
AppException
- Is thrown when license key retrieval fails.
-
resetCache
public boolean resetCache()Use this method to reset the cached license key.- Returns:
- True when the license provider cache has been reset, false when there is nothing cached.
-
getLicenseKey
This method will call the delegate getLicenseKey method only once and caches its result.- Specified by:
getLicenseKey
in interfaceILicenseProvider
- Returns:
- The license key, never null
- Throws:
AppException
- When the license content could not be returned.
-
hasLicenseKey
public boolean hasLicenseKey()This method will call the delegate hasLicenseKey method only once and caches its result.- Specified by:
hasLicenseKey
in interfaceILicenseProvider
- Returns:
- true when there is a license and false otherwise.
-