1 16 package org.apache.cocoon.samples; 17 18 import java.io.IOException ; 19 import java.io.Serializable ; 20 21 import org.apache.cocoon.ProcessingException; 22 import org.apache.cocoon.caching.validity.EventValidity; 23 import org.apache.cocoon.caching.validity.NamedEvent; 24 import org.apache.cocoon.environment.ObjectModelHelper; 25 import org.apache.cocoon.environment.Request; 26 import org.apache.cocoon.generation.JXTemplateGenerator; 27 import org.apache.excalibur.source.SourceValidity; 28 import org.xml.sax.SAXException ; 29 30 35 public class EventAwareGenerator extends JXTemplateGenerator { 36 37 49 public Serializable getKey() { 50 final Request request = ObjectModelHelper.getRequest(this.objectModel); 51 String key = request.getParameter("pageKey") ; 54 return ((key==null||"".equals(key)) ? "one" : key); 55 } 56 57 68 public SourceValidity getValidity() { 69 final Request request = ObjectModelHelper.getRequest(this.objectModel); 70 String key = request.getParameter("pageKey") ; 71 return new EventValidity( 72 new NamedEvent( 73 (key==null||"".equals(key)) ? "one" : key)); 74 } 75 76 77 80 public void generate() 81 throws IOException , SAXException , ProcessingException { 82 super.generate(); 83 long DELAY_SECS = this.parameters.getParameterAsLong("DELAY_SECS", 2); 85 try { 86 Thread.sleep(DELAY_SECS * 1000L); 87 } catch (InterruptedException ie) { 88 } 90 } 91 } 92 | Popular Tags |