org.omnifaces.component.output.cache
Class CacheFactory

java.lang.Object
  extended by org.omnifaces.component.output.cache.CacheFactory

public final class CacheFactory
extends java.lang.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 Summary
static java.lang.String CACHE_PROVIDER_PARAM_NAME
           
 
Method Summary
static Cache getCache(javax.faces.context.FacesContext context, java.lang.String scope)
          Gets an instance of a Cache using the configured cache provider.
static CacheProvider getCacheProvider(javax.faces.context.FacesContext context)
          Gets the cache provider that has been set, or the default provider if none is present.
static CacheProvider getCacheProvider(javax.servlet.ServletContext servletContext)
          Gets the cache provider as it has been set in the ServletContext.
static CacheProvider getDefaultCacheProvider()
          Returns an instance of the default cache provider.
static void setCacheProvider(CacheProvider cacheProvider, javax.servlet.ServletContext servletContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_PROVIDER_PARAM_NAME

public static final java.lang.String CACHE_PROVIDER_PARAM_NAME
See Also:
Constant Field Values
Method Detail

getCache

public static Cache getCache(javax.faces.context.FacesContext context,
                             java.lang.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(javax.servlet.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,
                                    javax.servlet.ServletContext servletContext)

getCacheProvider

public static CacheProvider getCacheProvider(javax.faces.context.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