You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/05/19 02:17:50 UTC
svn commit: r1124475 - in /myfaces/shared/trunk: ./
core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
Author: lu4242
Date: Thu May 19 00:17:50 2011
New Revision: 1124475
URL: http://svn.apache.org/viewvc?rev=1124475&view=rev
Log:
merge revisions 1085636-1098584
Modified:
myfaces/shared/trunk/ (props changed)
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
Propchange: myfaces/shared/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May 19 00:17:50 2011
@@ -1 +1,2 @@
+/myfaces/shared/trunk:1085636-1098584
/myfaces/shared/trunk_3.0.x:805066-833809,881094-924402,940133-941950
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java?rev=1124475&r1=1124474&r2=1124475&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java Thu May 19 00:17:50 2011
@@ -18,19 +18,18 @@
*/
package org.apache.myfaces.shared.resource;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
+import org.apache.myfaces.shared.util.WebConfigParamUtils;
+
+import javax.faces.application.ProjectStage;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.faces.application.ProjectStage;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
-import org.apache.myfaces.shared.util.WebConfigParamUtils;
-
public class ResourceHandlerCache
{
private static final Logger log = Logger
@@ -48,7 +47,7 @@ public class ResourceHandlerCache
private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
public ResourceValue getResource(String resourceName, String libraryName,
- String contentType)
+ String contentType, String localePrefix)
{
if (!isResourceCachingEnabled() || _resourceCacheMap == null)
return null;
@@ -57,24 +56,22 @@ public class ResourceHandlerCache
log.log(Level.FINE, "Attemping to get resource from cache for "
+ resourceName);
- ResourceKey key = new ResourceKey(resourceName, libraryName,
- contentType);
+ ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix);
return _resourceCacheMap.get(key);
}
- public boolean containsResource(String resourceName, String libraryName,
- String contentType)
+ public boolean containsResource(String resourceName, String libraryName, String contentType, String localePrefix)
{
if (!isResourceCachingEnabled() || _resourceCacheMap == null)
return false;
- ResourceKey key = new ResourceKey(resourceName, libraryName,
- contentType);
+
+ ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix);
return _resourceCacheMap.containsKey(key);
}
public void putResource(String resourceName, String libraryName,
- String contentType, ResourceMeta resource, ResourceLoader loader)
+ String contentType, String localePrefix, ResourceMeta resource, ResourceLoader loader)
{
if (!isResourceCachingEnabled())
return;
@@ -93,7 +90,7 @@ public class ResourceHandlerCache
}
_resourceCacheMap.put(new ResourceKey(resourceName, libraryName,
- contentType), new ResourceValue(resource, loader));
+ contentType, localePrefix), new ResourceValue(resource, loader));
}
private boolean isResourceCachingEnabled()
@@ -140,64 +137,62 @@ public class ResourceHandlerCache
private String resourceName;
private String libraryName;
private String contentType;
+ private String localePrefix;
public ResourceKey(String resourceName, String libraryName,
- String contentType)
+ String contentType, String localePrefix)
{
this.resourceName = resourceName;
this.libraryName = libraryName;
this.contentType = contentType;
+ this.localePrefix = localePrefix;
}
@Override
- public int hashCode()
+ public boolean equals(Object o)
{
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((contentType == null) ? 0 : contentType.hashCode());
- result = prime * result
- + ((libraryName == null) ? 0 : libraryName.hashCode());
- result = prime * result
- + ((resourceName == null) ? 0 : resourceName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResourceKey other = (ResourceKey) obj;
- if (contentType == null)
+ if (this == o)
{
- if (other.contentType != null)
- return false;
+ return true;
}
- else if (!contentType.equals(other.contentType))
+ if (o == null || getClass() != o.getClass())
+ {
return false;
- if (libraryName == null)
+ }
+
+ ResourceKey that = (ResourceKey) o;
+
+ if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null)
{
- if (other.libraryName != null)
- return false;
+ return false;
}
- else if (!libraryName.equals(other.libraryName))
+ if (libraryName != null ? !libraryName.equals(that.libraryName) : that.libraryName != null)
+ {
return false;
- if (resourceName == null)
+ }
+ if (localePrefix != null ? !localePrefix.equals(that.localePrefix) : that.localePrefix != null)
{
- if (other.resourceName != null)
- return false;
+ return false;
}
- else if (!resourceName.equals(other.resourceName))
+ if (resourceName != null ? !resourceName.equals(that.resourceName) : that.resourceName != null)
+ {
return false;
+ }
+
return true;
}
+
+ @Override
+ public int hashCode()
+ {
+ int result = resourceName != null ? resourceName.hashCode() : 0;
+ result = 31 * result + (libraryName != null ? libraryName.hashCode() : 0);
+ result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
+ result = 31 * result + (localePrefix != null ? localePrefix.hashCode() : 0);
+ return result;
+ }
}
-
+
public static class ResourceValue
{
private ResourceMeta resourceMeta;