Class CacheFactory

java.lang.Object
org.omnifaces.util.cache.CacheFactory

public final class CacheFactory extends Object
Factory used to obtain Cache instance and to register the CacheProvider that is used to obtain that.
Since:
1.1
Author:
Arjan Tijms
  • Field Details

  • Method Details

    • getCache

      public static Cache getCache(FacesContext context, String scope)
      Gets an instance of a Cache using the configured cache provider.
      Parameters:
      context - faces context used for retrieving the cache provider and for resolving the given scope.
      scope - scope for which the cache should be obtained. Supported scopes are dependent on the specific caching provider, but generally at least "session" and "application" should be supported.
      Returns:
      a cache provider specific Cache instance
    • getCacheProvider

      public static CacheProvider getCacheProvider(ServletContext servletContext)
      Gets the cache provider as it has been set in the ServletContext. Does NOT return the default cache provider if none is present.
      Parameters:
      servletContext - the servlet context where the cache provider is retrieved from
      Returns:
      the previously set provider if one is set, null otherwise
    • setCacheProvider

      public static void setCacheProvider(CacheProvider cacheProvider, ServletContext servletContext)
    • getCacheProvider

      public static CacheProvider getCacheProvider(FacesContext context)
      Gets the cache provider that has been set, or the default provider if none is present.
      Parameters:
      context - the faces context where the cache provider is retrieved from
      Returns:
      the previously set provider if one is set, otherwise the default provider
    • getDefaultCacheProvider

      public static CacheProvider getDefaultCacheProvider()
      Returns an instance of the default cache provider. This is the provider that is used in getCache(FacesContext, String) and getCacheProvider(FacesContext) if no explicit provider has been set.
      Returns:
      the default cache provider