I am using LazyMaps as a mechanism to get lookup functionality into
JSTL/JSP pages and also inside servlet filters.  For example, inside a
servlet filter I have a HttpServletRequestWrapper implementation which
includes a method:

public Map getIsUserInRole()

This means I can fool JSTL into doing a dynamic user lookup by using:

${pageContext.request.isUserInRole['admin']}

I ran into an issue that my LazyMap was always caching the result
(this is how it is supposed to work!) but sometimes the back end value
changes.  So I created a modified version of LazyMap, which I called
ClearingLazyMap, that never stores any values into the map and always
does a lookup (using transform).  Therefore the modified "get" method
now looks like:

public Object get(Object key) {
    return factory.transform(key);
}

This seems to work well for me, is it a good idea or am I missing something?

Mark
-- 
"Paradoxically, the more time saving abstractions you are using the
more you actually have to know." - Simon Willison

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to