Class CachingLicenseProvider

java.lang.Object
com.aquima.interactions.foundation.lic.CachingLicenseProvider
All Implemented Interfaces:
ILicenseProvider

public class CachingLicenseProvider extends Object implements ILicenseProvider

This class may be used to cache license keys from a delegate (slow) license provider.

Since:
8.1
Author:
Jon van Leuven
  • Constructor Details

    • CachingLicenseProvider

      public CachingLicenseProvider(ILicenseProvider delegate)
      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

      public static CachingLicenseProvider createAndCache(ILicenseProvider delegate)
      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

      public LicenseKey getLicenseKey()
      This method will call the delegate getLicenseKey method only once and caches its result.
      Specified by:
      getLicenseKey in interface ILicenseProvider
      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 interface ILicenseProvider
      Returns:
      true when there is a license and false otherwise.