Author: michiel
Date: 2010-03-19 13:02:50 +0100 (Fri, 19 Mar 2010)
New Revision: 41536

Added:
   speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/
   
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Always.java
   
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Expires.java
Modified:
   speeltuin/mihxil/portal/trunk/src/main/config/builders/core/blocks.xml
   speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/PageCloner.java
Log:
Going to need something to administrate how such a block can be cached. 
Adopting the formalism of oscache.

Modified: speeltuin/mihxil/portal/trunk/src/main/config/builders/core/blocks.xml
===================================================================
--- speeltuin/mihxil/portal/trunk/src/main/config/builders/core/blocks.xml      
2010-03-19 10:52:26 UTC (rev 41535)
+++ speeltuin/mihxil/portal/trunk/src/main/config/builders/core/blocks.xml      
2010-03-19 12:02:50 UTC (rev 41536)
@@ -72,6 +72,25 @@
       </gui>
       <datatype base="windowstate" 
xmlns="http://www.mmbase.org/xmlns/datatypes"; />
     </field>
+    <field name="refreshpolicy">
+      <gui>
+        <guiname xml:lang="nl">Cacherefreshpolicy</guiname>
+        <guiname xml:lang="en">Cache refresh policy</guiname>
+      </gui>
+      <datatype base="string" xmlns="http://www.mmbase.org/xmlns/datatypes";>
+        <enumeration>
+          <entry value="org.mmbase.portal.refresh.Always" display="always" />
+          <entry value="org.mmbase.portal.refresh.Expires" display="expires" />
+        </enumeration>
+      </datatype>
+    </field>
+    <field name="refreshpolicyparam">
+      <gui>
+        <guiname xml:lang="nl">Cacherefreshpolicy</guiname>
+        <guiname xml:lang="en">Cache refresh policy</guiname>
+      </gui>
+      <datatype base="string" xmlns="http://www.mmbase.org/xmlns/datatypes"; />
+    </field>
 
 
   </fieldlist>

Modified: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/PageCloner.java
===================================================================
--- 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/PageCloner.java   
    2010-03-19 10:52:26 UTC (rev 41535)
+++ 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/PageCloner.java   
    2010-03-19 12:02:50 UTC (rev 41536)
@@ -1,3 +1,12 @@
+/*
+
+This software is OSI Certified Open Source Software.
+OSI Certified is a certification mark of the Open Source Initiative.
+
+The license (Mozilla version 1.0) can be read at the MMBase site.
+See http://www.MMBase.org/license
+
+*/
 package org.mmbase.portal;
 
 import org.mmbase.util.functions.*;
@@ -6,7 +15,9 @@
 import java.util.*;
 
 /**
+ * Clones an object, which all it's relations, and also adapts online and 
offline.
  * @author Michiel Meeuwissen
+ * @version $Id$
  */
 
 public class PageCloner extends NodeFunction {


Property changes on: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/PageCloner.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Always.java
===================================================================
--- 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Always.java
                           (rev 0)
+++ 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Always.java
   2010-03-19 12:02:50 UTC (rev 41536)
@@ -0,0 +1,28 @@
+/*
+
+This software is OSI Certified Open Source Software.
+OSI Certified is a certification mark of the Open Source Initiative.
+
+The license (Mozilla version 1.0) can be read at the MMBase site.
+See http://www.MMBase.org/license
+
+*/
+package org.mmbase.portal.refresh;
+
+import java.util.*;
+import com.opensymphony.oscache.web.*;
+import com.opensymphony.oscache.base.*;
+
+/**
+ * @author Michiel Meeuwissen
+ * @version $Id$
+ */
+public class Always implements WebEntryRefreshPolicy {
+
+    public void init(String key, String param) {
+
+    }
+    public boolean needsRefresh(CacheEntry e) {
+        return true;
+    }
+}
\ No newline at end of file


Property changes on: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Always.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Expires.java
===================================================================
--- 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Expires.java
                          (rev 0)
+++ 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Expires.java
  2010-03-19 12:02:50 UTC (rev 41536)
@@ -0,0 +1,31 @@
+/*
+
+This software is OSI Certified Open Source Software.
+OSI Certified is a certification mark of the Open Source Initiative.
+
+The license (Mozilla version 1.0) can be read at the MMBase site.
+See http://www.MMBase.org/license
+
+*/
+package org.mmbase.portal.refresh;
+
+import java.util.*;
+import com.opensymphony.oscache.web.*;
+import com.opensymphony.oscache.base.*;
+
+/**
+ * @author Michiel Meeuwissen
+ * @version $Id$
+ */
+public class Expires implements WebEntryRefreshPolicy {
+
+    int expires = 600;
+
+    public void init(String key, String param) {
+        expires = Integer.parseInt(param);
+    }
+    public boolean needsRefresh(CacheEntry e) {
+        long now = System.currentTimeMillis();
+        return now > e.getLastUpdate() + expires * 1000;
+    }
+}
\ No newline at end of file


Property changes on: 
speeltuin/mihxil/portal/trunk/src/main/java/org/mmbase/portal/refresh/Expires.java
___________________________________________________________________
Name: svn:keywords
   + Id

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to