Class ServerCachingFilter
java.lang.Object
de.businesscode.bcdui.web.cacheControl.AbstractCacheFilter
de.businesscode.bcdui.web.cacheControl.ServerCachingFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
Implements server side caching.
This Filter caches the server response to the given store.
Only the url's from the init-param will be cached.
The store will be get from the JNDI and must be declare by user.
The name of the expected store object is BCD-UI/ServerCacheControl
This filter support all expires from ClientCachingFilter excepts CacheRequestDirective.
For further information please consult your BCD-UI documentation
Only the url's from the init-param will be cached.
The store will be get from the JNDI and must be declare by user.
The name of the expected store object is BCD-UI/ServerCacheControl
This filter support all expires from ClientCachingFilter excepts CacheRequestDirective.
For further information please consult your BCD-UI documentation
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.servlet.http.HttpServletResponsedeployCachingResponse(jakarta.servlet.http.HttpServletResponse response, String key) voiddestroy()voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) protected booleandoResponseFromCache(String requestUrl) default return value is TRUE, hence caching responsesvoidflushCachedResponse(String key, OutputStream os) flushes previously saved response to the streamprotected StringgenerateRequestKey(jakarta.servlet.http.HttpServletRequest httpRequest) generates request URL which will be used to map request to cache, implementation can decide whether only the url part or parameters forms the keyprotected Stringstatic ServerCachingFiltergetInstance(jakarta.servlet.ServletRequest request) Returns an instance bound to given request.protected IServerCachePersistgetUrls()voidinit(jakarta.servlet.FilterConfig fc) protected voidsetFilterName(String filterName) protected org.apache.commons.io.output.TeeOutputStreamprotected PrintWriterwrap(String key, PrintWriter writer) Methods inherited from class de.businesscode.bcdui.web.cacheControl.AbstractCacheFilter
getDefinedExpires, getExpiresValue
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
ServerCachingFilter
public ServerCachingFilter()
-
-
Method Details
-
getInstance
Returns an instance bound to given request. May return null if request is not cached. To enable caching for request - please set up such rule in your web descriptor.- Parameters:
request-- Returns:
- NULL or the instance for given request
-
destroy
public void destroy()- See Also:
-
Filter.destroy()
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Throws:
IOExceptionjakarta.servlet.ServletException- See Also:
-
Filter.doFilter(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, jakarta.servlet.FilterChain)
-
generateRequestKey
protected String generateRequestKey(jakarta.servlet.http.HttpServletRequest httpRequest) throws MalformedURLException generates request URL which will be used to map request to cache, implementation can decide whether only the url part or parameters forms the key- Parameters:
httpRequest-- Returns:
- URL describing current request
- Throws:
MalformedURLException
-
doResponseFromCache
default return value is TRUE, hence caching responses- Parameters:
requestUrl-- Returns:
- TRUE if caching facility should be bypassed, the response is not cached
-
getUrls
- Returns:
- the urls
-
init
public void init(jakarta.servlet.FilterConfig fc) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Filter- Overrides:
initin classAbstractCacheFilter- Throws:
jakarta.servlet.ServletException- See Also:
-
Filter.init(jakarta.servlet.FilterConfig)
-
wrap
protected org.apache.commons.io.output.TeeOutputStream wrap(String key, jakarta.servlet.ServletOutputStream outputStream) throws Exception - Parameters:
key-outputStream-- Returns:
- ServletOutputStream which supports teeing to another stream
- Throws:
IOExceptionException
-
getServerCacheControl
- Returns:
- the serverCacheControl
-
wrap
- Parameters:
key-writer-- Returns:
- Throws:
IOExceptionException
-
flushCachedResponse
flushes previously saved response to the stream- Parameters:
key-os-- Throws:
IOExceptionException
-
getFilterName
- Returns:
- the filterName
-
setFilterName
- Parameters:
filterName- the filterName to set
-
deployCachingResponse
protected jakarta.servlet.http.HttpServletResponse deployCachingResponse(jakarta.servlet.http.HttpServletResponse response, String key) - Parameters:
response-key-- Returns:
-