Class CacheServiceLoader


  • public final class CacheServiceLoader
    extends Object
    Initialised when the store is initialised. Looks at a system property to determine the cache service to load. Then initialises it, after which any component may use CacheServiceLoader.getService() to get the service that can retrieve the appropriate cache.
    • Method Detail

      • initialise

        public static void initialise​(String serviceName,
                                      String cacheClass,
                                      Properties properties)
        Creates a cache service identified by the given service name, using the supplied class name and properties to initialise the service.

        Adds a shutdown hook which gracefully closes the cache service if JVM is stopped. This shouldn't be relied upon in a servlet context, instead use ServletLifecycleListener.

        Parameters:
        serviceName - name to identify the cache service to initialise
        cacheClass - class name of the cache service provider to use
        properties - properties to pass to the cache service provider
        Throws:
        IllegalArgumentException - if an invalid cache class is specified
      • initialise

        public static void initialise​(String cacheClass)
        Creates a default cache service using the supplied class name to initialise the service. No properties are passed to the cache service, this is primarily a convenience method. See initialise(String, String, Properties) for further details.
        Parameters:
        cacheClass - class name of the cache service provider to use
        Throws:
        IllegalArgumentException - if an invalid cache class is specified
      • getDefaultService

        public static ICacheService getDefaultService()
        Get the default cache service object.
        Returns:
        the default cache service
      • getService

        public static ICacheService getService​(String serviceName)
        Get the cache service identified by the supplied name.
        Parameters:
        serviceName - name identifying the cache service
        Returns:
        the cache service
      • isDefaultEnabled

        public static boolean isDefaultEnabled()
        Returns:
        true if the default cache service is enabled
      • isEnabled

        public static boolean isEnabled​(String serviceName)
        Parameters:
        serviceName - name identifying a cache service
        Returns:
        true if a cache service with that name exists (and is therefore enabled)
      • initialise

        @Deprecated
        public static void initialise​(Properties properties)
        Deprecated.
        Instead use initialise(String, String, Properties), or optionally initialise(String) when writing tests.
        Looks at a system property and initialises an appropriate cache service. Adds a shutdown hook which gracefully closes the cache service if JVM is stopped. This should not be relied upon in a servlet context - use the ServletLifecycleListener located in the REST module instead.
        Parameters:
        properties - the cache service properties
        Throws:
        IllegalArgumentException - if an invalid cache class is specified in the system property
      • shutdown

        public static void shutdown()
        Gracefully shutdown and reset the cache service.