res = (String) resMap.get(null);//Try with no-language resource.
if (res == null)
res = (String) resMap.get(getLocaleManager().getDefaultLang());//Try with default lang
res = getBaseDir() + "/" + res;
RequestContext reqCtx = RequestContext.getCurrentContext();
if (reqCtx != null) {
//Resources are best retrieved through URL (the fastest way)
log.debug("Resource relative name = " + res);
String categoryMapping = getMappingDir();
log.debug("Category where the resource belongs to is mapped to uri " + categoryMapping);
String url = categoryMapping + "/" + res;
log.debug("Returning UrlResource to " + url);
return UrlResource.getInstance(resourceName, reqCtx.getRequest().getRequestObject().getContextPath(), url);
} else {
//Create a FileResource...
try {
checkDeployment();
return FileResource.getInstance(resourceName, new File(Application.lookup().getBaseAppDirectory() + getMappingDir() + "/" + res));