[gatein-commits] gatein SVN: r4949 - portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/resolver.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 4 22:22:02 EDT 2010
Author: hoang_to
Date: 2010-11-04 22:22:01 -0400 (Thu, 04 Nov 2010)
New Revision: 4949
Modified:
portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java
Log:
GTNPORTAL-1357: A template caching issue with a custom resource resolver
Modified: portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-11-05 01:18:39 UTC (rev 4948)
+++ portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-11-05 02:22:01 UTC (rev 4949)
@@ -26,21 +26,60 @@
import java.util.List;
/**
+ * This abstract class provide an abstract way to retrieve different resources in different contexts (war, jar....) <br/>
+ * For example, to retrieve resource from an portlet, we implement <br/>
+ * {@link org.exoplatform.resolver.PortletResourceResolver} <br/>
+ * <br/>
+ * In gatein, we have caching machanism which use {@link org.exoplatform.resolver.ResourceKey} <br/>
+ * as key to determine cached resource, ResourceKey is generated by ResourceResolver.createResourceKey method <br/>
+ * <br/>
+ * By default, createResourceKey method return difference ResourceKey<br/>
+ * if we call that method on difference ResourceResolver instances (even with the same resource url)<br/>
+ * <br/>
+ * To make our caching machanism work properly,please make sure you use the same ResourceResolver<br/>
+ * or override the createResourceKey method of abstract class ResourceResolver<br/>
+ * and return the same ResourceKey for the same resource url<br/>
+ * <br/>
* Created by The eXo Platform SAS
* Mar 15, 2006
*/
abstract public class ResourceResolver
{
+ /**
+ * Return URL object to resource
+ * @param url - String path (specific to certain context) to resource
+ * @throws Exception
+ */
abstract public URL getResource(String url) throws Exception;
+ /**
+ * Return InputStream object to resource
+ * @param url - String path (specific to certain context) to resource
+ * @throws Exception
+ */
abstract public InputStream getInputStream(String url) throws Exception;
+ /**
+ * Return List of URL object to resource
+ * @param url - String path (specific to certain context) to resource
+ * @throws Exception
+ */
abstract public List<URL> getResources(String url) throws Exception;
+ /**
+ * Return List of InputStream object to resource
+ * @param url - String path (specific to certain context) to resource
+ * @throws Exception
+ */
abstract public List<InputStream> getInputStreams(String url) throws Exception;
@SuppressWarnings("unused")
+ /**
+ * Return web path to resource (/context/pathToResource)
+ * You should overidde this method in case of web context
+ * @param url - String path (specific to certain context) to resource
+ */
public String getWebAccessPath(String url)
{
throw new RuntimeException("This method is not supported");
@@ -54,21 +93,44 @@
throw new RuntimeException("unsupported method");
}
+ /**
+ * Return {@link org.exoplatform.resolver.ResourceKey} object<br/>
+ * <br/>
+ * Default implementation will return difference ResourceKey instance<br/>
+ * if we call that method on difference ResourceResolver instances (even with the same resource url)<br/>
+ * <br/>
+ * If you create new ResourceResolver each time you need access to a resource, please overidde this method<br/>
+ * and return the same ResourceKey for the same url<br/>
+ * @param url - String path (specific to certain context) to resource
+ */
public ResourceKey createResourceKey(String url)
{
return new ResourceKey(hashCode(), url);
}
+ /**
+ * Return resource id
+ * @param url - String path (specific to certain context) to resource
+ */
public String createResourceId(String url)
{
return hashCode() + ":" + url;
}
+ /**
+ * Return if this can resolve resource with specific url
+ * @param url String path to resource
+ */
public boolean isResolvable(String url)
{
return url.startsWith(getResourceScheme());
}
+ /**
+ * Return resource as array of bytes
+ * @param url - String path (specific to certain context) to resource
+ * @throws Exception
+ */
public byte[] getResourceContentAsBytes(String url) throws Exception
{
InputStream is = getInputStream(url);
@@ -83,6 +145,11 @@
return output.toByteArray();
}
+ /**
+ * Return if resource has been modified since specific time
+ * @param url- String path (specific to certain context) to resource
+ * @param lastAccess
+ */
abstract public boolean isModified(String url, long lastAccess);
protected String removeScheme(String url)
More information about the gatein-commits
mailing list