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.HttpServletResponse
deployCachingResponse
(jakarta.servlet.http.HttpServletResponse response, String key) void
destroy()
void
doFilter
(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) protected boolean
doResponseFromCache
(String requestUrl) default return value is TRUE, hence caching responsesvoid
flushCachedResponse
(String key, OutputStream os) flushes previously saved response to the streamprotected String
generateRequestKey
(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 String
static ServerCachingFilter
getInstance
(jakarta.servlet.ServletRequest request) Returns an instance bound to given request.protected IServerCachePersist
getUrls()
void
init
(jakarta.servlet.FilterConfig fc) protected void
setFilterName
(String filterName) protected org.apache.commons.io.output.TeeOutputStream
protected PrintWriter
wrap
(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:
IOException
jakarta.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:
init
in interfacejakarta.servlet.Filter
- Overrides:
init
in 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:
IOException
Exception
-
getServerCacheControl
- Returns:
- the serverCacheControl
-
wrap
- Parameters:
key
-writer
-- Returns:
- Throws:
IOException
Exception
-
flushCachedResponse
flushes previously saved response to the stream- Parameters:
key
-os
-- Throws:
IOException
Exception
-
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:
-