* @throws Exception
*/
public void scanForResources (WebAppContext context, Resource target, ConcurrentHashMap<Resource,Resource> cache)
throws Exception
{
Resource resourcesDir = null;
if (cache != null && cache.containsKey(target))
{
resourcesDir = cache.get(target);
if (resourcesDir == EmptyResource.INSTANCE)
{
if (LOG.isDebugEnabled()) LOG.debug(target+" cached as containing no META-INF/resources");
return;
}
else
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources found in cache ");
}
else
{
//not using caches or not in the cache so check for the resources dir
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources checked");
if (target.isDirectory())
{
//TODO think how to handle an unpacked jar file (eg for osgi)
resourcesDir = target.addPath("/META-INF/resources");
}
else
{
//Resource represents a packed jar
URI uri = target.getURI();
resourcesDir = Resource.newResource("jar:"+uri+"!/META-INF/resources");
}
if (!resourcesDir.exists() || !resourcesDir.isDirectory())
resourcesDir = EmptyResource.INSTANCE;
if (cache != null)
{
Resource old = cache.putIfAbsent(target, resourcesDir);
if (old != null)
resourcesDir = old;
else
if (LOG.isDebugEnabled()) LOG.debug(target+" META-INF/resources cache updated");
}