You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by pa...@apache.org on 2001/10/07 14:29:15 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets AbstractPortlet.java WebPagePortlet.java
paulsp 01/10/07 05:29:15
Modified: src/java/org/apache/jetspeed/services/portletcache
Cacheable.java JetspeedPortletCacheService.java
src/java/org/apache/jetspeed/portal/portlets
AbstractPortlet.java WebPagePortlet.java
Log:
Sets the expiration of the cached object to match the expiration of the portlet content.
This is implemented on the WebPagePortlet using the expiration time in the HTTP response
header, not the <META HTTP-EQUIV..> tag. Objects that have not set an expiration in the
Cacheable interface, which is the pre-patch behavior, will continue to expire using the
turbine default behavior.CVS: ----------------------------------------------------------------------
Revision Changes Path
1.4 +14 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/Cacheable.java
Index: Cacheable.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/Cacheable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Cacheable.java 2001/06/04 17:30:37 1.3
+++ Cacheable.java 2001/10/07 12:29:15 1.4
@@ -64,7 +64,7 @@
*
* @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
* @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
- * @version $Id: Cacheable.java,v 1.3 2001/06/04 17:30:37 raphael Exp $
+ * @version $Id: Cacheable.java,v 1.4 2001/10/07 12:29:15 paulsp Exp $
*/
public interface Cacheable
{
@@ -103,5 +103,18 @@
*/
public void setHandle( String handle );
+ /**
+ * Return the expiration time in milliseconds.
+ @return Expiration time in milliseconds since epoch, or null if the
+ * expiration was not set
+ */
+ public Long getExpirationMillis();
+
+ /**
+ * Set the expiration time in milliseconds.
+ @param setExpirationMillis Expiration in milliseconds since epoch
+ */
+ public void setExpirationMillis( long expirationMillis);
+
}
1.5 +13 -3 jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/JetspeedPortletCacheService.java
Index: JetspeedPortletCacheService.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/JetspeedPortletCacheService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JetspeedPortletCacheService.java 2001/03/07 06:48:50 1.4
+++ JetspeedPortletCacheService.java 2001/10/07 12:29:15 1.5
@@ -67,7 +67,7 @@
*
* @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
* @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
- * @version $Id: JetspeedPortletCacheService.java,v 1.4 2001/03/07 06:48:50 taylor Exp $
+ * @version $Id: JetspeedPortletCacheService.java,v 1.5 2001/10/07 12:29:15 paulsp Exp $
*/
public class JetspeedPortletCacheService
extends TurbineBaseService
@@ -108,8 +108,18 @@
}
if ( item.isCacheable() ) {
- GlobalCache.addObject( handle, new CachedObject( item ) );
- }
+ Long expirationMillis = item.getExpirationMillis();
+ if (expirationMillis != null) {
+ // Only cache objects that have not expired.
+ if (System.currentTimeMillis() < expirationMillis.longValue()) {
+ GlobalCache.addObject( handle, new CachedObject( item, expirationMillis.longValue() - System.currentTimeMillis()) );
+ }
+ } else {
+ // Oject will be cached Turbine "cachedobject.defaultage"
+ GlobalCache.addObject( handle, new CachedObject( item ) );
+ }
+ }
+
}
1.46 +22 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
Index: AbstractPortlet.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- AbstractPortlet.java 2001/09/10 22:41:00 1.45
+++ AbstractPortlet.java 2001/10/07 12:29:15 1.46
@@ -92,7 +92,7 @@
@author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
@author <A HREF="mailto:raphael@apache.org">Rapha�l Luta</A>
-@version $Id: AbstractPortlet.java,v 1.45 2001/09/10 22:41:00 sgala Exp $
+@version $Id: AbstractPortlet.java,v 1.46 2001/10/07 12:29:15 paulsp Exp $
*/
public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
{
@@ -111,6 +111,12 @@
private String handle = "";
/**
+ Expiration time of object in milliseconds since the standard base time
+ known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
+ */
+ private Long expirationMillis = null;
+
+ /**
Holds instances of ConcreteElements (Portlet output/content)
based on its current CapabilityMap.
*/
@@ -201,6 +207,21 @@
*/
public final void setHandle( String handle ) {
this.handle = handle;
+ }
+
+ /**
+ @see Cacheable#getExpirationMillis
+ */
+ public Long getExpirationMillis() {
+ return this.expirationMillis;
+ }
+
+
+ /**
+ @see Cacheable#setExpirationMillis
+ */
+ public void setExpirationMillis( long expirationMillis) {
+ this.expirationMillis = new Long(expirationMillis);
}
/** Builds a new cache handle for this cacheable class with the specified
1.3 +12 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/WebPagePortlet.java
Index: WebPagePortlet.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/WebPagePortlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebPagePortlet.java 2001/03/07 06:47:17 1.2
+++ WebPagePortlet.java 2001/10/07 12:29:15 1.3
@@ -128,12 +128,18 @@
/**
* took this from FileServerPortlet as it was private
+ *
+ * FIXME: Currently only the expiration the HTTP Reponse header is honored.
+ * Expiration information in <meta> tags are not honored
*/
private String getURL(String url) throws IOException {
int CAPACITY = 1024;
+ URL pageUrl = new URL(url);
+ URLConnection pageConn = pageUrl.openConnection();
+ long pageExpiration = pageConn.getExpiration();
- InputStream is = new URL( url ).openStream();
+ InputStream is = pageUrl.openStream();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
//now process the InputStream...
@@ -147,6 +153,11 @@
is.close();
+ // Only set the page expiration it the page has not expired
+ if (pageExpiration > System.currentTimeMillis()) {
+ Log.debug( "WebPagePortlet caching URL: " + url + " Expiration: " + pageExpiration);
+ setExpirationMillis(pageExpiration);
+ }
return buffer.toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org