Caching Resource Loader

Background

There are a number of resources in uPortal that are loaded from the file system and then parsed. Historically each component would load and parse the file and hold on to a reference. While functional this is problematic for allowing deployers to modify files in a running system and see the changes.

Overview

CachingResourceLoader uses the spring Resource class to get an InputStream for loading. The caller provides a callback implementation to read the InputStream and return a parsed Object. For example if loading an XSL file the callback could return a Templates object to be cached. On subsequent calls the Resource's lastModified time is read and compared to the load time of the cached resource, if it has changed the cached resource is re-loaded.

Usage