resourceValue = getResourceLoaderCache().getResource(resourceName, libraryName, contentType, localePrefix);
}
if(resourceValue != null)
{
resource = new ResourceImpl(resourceValue.getResourceMeta(), resourceValue.getResourceLoader(),
getResourceHandlerSupport(), contentType,
resourceValue.getCachedInfo() != null ? resourceValue.getCachedInfo().getURL() : null,
resourceValue.getCachedInfo() != null ? resourceValue.getCachedInfo().getRequestPath() : null);
}
else
{
boolean resolved = false;
// Try preferred contract first
if (contractPreferred != null)
{
for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
{
ResourceMeta resourceMeta = deriveResourceMeta(loader, resourceName, libraryName,
localePrefix, contractPreferred);
if (resourceMeta != null)
{
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(resourceName, libraryName, contentType,
localePrefix, contractPreferred, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
resolved = true;
break;
}
}
}
if (!resolved && !contracts.isEmpty())
{
for (ContractResourceLoader loader :
getResourceHandlerSupport().getContractResourceLoaders())
{
for (String contract : contracts)
{
ResourceMeta resourceMeta = deriveResourceMeta(
loader, resourceName, libraryName,
localePrefix, contract);
if (resourceMeta != null)
{
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(
resourceName, libraryName, contentType,
localePrefix, contract, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
resolved = true;
break;
}
}
}
}
if (!resolved)
{
for (ResourceLoader loader : getResourceHandlerSupport().getResourceLoaders())
{
ResourceMeta resourceMeta = deriveResourceMeta(
loader, resourceName, libraryName, localePrefix);
if (resourceMeta != null)
{
resource = new ResourceImpl(
resourceMeta, loader, getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(resourceName, libraryName, contentType,
localePrefix, null, resourceMeta, loader,