}
final String localePrefix = getLocalePrefixForLocateResource(facesContext);
String contentType = facesContext.getExternalContext().getMimeType(resourceName);
final List<String> contracts = facesContext.getResourceLibraryContracts();
String contractPreferred = getContractNameForLocateResource(facesContext);
ResourceValue resourceValue = null;
// Check cache:
//
// Contracts are on top of everything, because it is a concept that defines
// resources in a application scope concept. It means all resources in
// /resources or /META-INF/resources can be overriden using a contract. Note
// it also means resources under /META-INF/flows can also be overriden using
// a contract.
if (contractPreferred != null)
{
resourceValue = getResourceLoaderCache().getViewResource(
resourceName, contentType, localePrefix, contractPreferred);
}
if (resourceValue == null && !contracts.isEmpty())
{
// Try to get resource but try with a contract name
for (String contract : contracts)
{
resourceValue = getResourceLoaderCache().getViewResource(
resourceName, contentType, localePrefix, contract);
if (resourceValue != null)
{
break;
}
}
}
if (resourceValue == null)
{
// Try to get resource without contract name
resourceValue = getResourceLoaderCache().getViewResource(
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)