Package org.omnifaces.util.cache
Class CacheFactory
- java.lang.Object
-
- org.omnifaces.util.cache.CacheFactory
-
public final class CacheFactory extends Object
Factory used to obtainCache
instance and to register theCacheProvider
that is used to obtain that.- Since:
- 1.1
- Author:
- Arjan Tijms
-
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_PROVIDER_PARAM_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Cache
getCache(FacesContext context, String scope)
Gets an instance of a Cache using the configured cache provider.static CacheProvider
getCacheProvider(FacesContext context)
Gets the cache provider that has been set, or the default provider if none is present.static CacheProvider
getCacheProvider(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, ServletContext servletContext)
-
-
-
Field Detail
-
CACHE_PROVIDER_PARAM_NAME
public static final String CACHE_PROVIDER_PARAM_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 ingetCache(FacesContext, String)
andgetCacheProvider(FacesContext)
if no explicit provider has been set.- Returns:
- the default cache provider
-
-