java.lang.Object
com.aoapps.servlet.ServletContextCache
ServletContext methods can be somewhat slow, this offers a cache that refreshes
the recently used values in the background. Importantly, it caches misses as well.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ServletContextCache
getCache
(ServletContext servletContext) Deprecated.static ServletContextCache
getInstance
(ServletContext servletContext) Gets or creates the cache for the provided servlet context.long
getLastModified
(String path) Gets a modified time from either a file or URL.static long
getLastModified
(ServletContext servletContext, String path) getRealPath
(String path) static String
getRealPath
(ServletContext servletContext, String path) getResource
(String path) Gets the possibly cached URL.static URL
getResource
(ServletContext servletContext, String path)
-
Method Details
-
getInstance
Gets or creates the cache for the provided servlet context. -
getCache
Deprecated.Please usegetInstance(javax.servlet.ServletContext)
. -
getResource
Gets the possibly cached URL. This URL is not copied and caller should not fiddle with its state. Thank you Java for this not being immutable.- Throws:
MalformedURLException
- See Also:
-
getResource
public static URL getResource(ServletContext servletContext, String path) throws MalformedURLException - Throws:
MalformedURLException
- See Also:
-
getRealPath
- See Also:
-
getRealPath
- See Also:
-
getLastModified
Gets a modified time from either a file or URL.- Returns:
- The modified time or
0L
when not known - See Also:
-
getLastModified
- See Also:
-
getInstance(javax.servlet.ServletContext)
.