resourceName, contentType, localePrefix);
}
if(resourceValue != null)
{
resource = new ResourceImpl(resourceValue.getResourceMeta(), resourceValue.getResourceLoader(),
getResourceHandlerSupport(), contentType,
resourceValue.getCachedInfo() != null ? resourceValue.getCachedInfo().getURL() : null, null);
}
else
{
boolean resolved = false;
if (contractPreferred != null)
{
for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
{
ResourceMeta resourceMeta = deriveViewResourceMeta(
facesContext, loader, resourceName, localePrefix, contractPreferred);
if (resourceMeta != null)
{
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putViewResource(
resourceName, contentType, localePrefix, contractPreferred, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), null));
resolved = true;
break;
}
}
}
if (!resolved && !contracts.isEmpty())
{
for (ContractResourceLoader loader :
getResourceHandlerSupport().getContractResourceLoaders())
{
for (String contract : contracts)
{
ResourceMeta resourceMeta = deriveViewResourceMeta(
facesContext, loader, resourceName, localePrefix, contract);
if (resourceMeta != null)
{
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putViewResource(
resourceName, contentType, localePrefix, contract, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), null));
resolved = true;
break;
}
}
}
}
if (!resolved)
{
// "... Considering the web app root ..."
// "... Considering faces flows (at the locations specified in the spec prose document section
// Faces Flows in the Using JSF in Web Applications chapter) ..."
for (ResourceLoader loader : getResourceHandlerSupport().getViewResourceLoaders())
{
ResourceMeta resourceMeta = deriveViewResourceMeta(
facesContext, loader, resourceName, localePrefix);
if (resourceMeta != null)
{
resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putViewResource(
resourceName, contentType, localePrefix, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), null));