1 16 package org.apache.cocoon.components.flow; 17 18 import java.text.SimpleDateFormat ; 19 import java.util.ArrayList ; 20 import java.util.Date ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 24 27 public class WebContinuationDataBean { 28 29 private static final String TYPE_JAVAFLOW = "javaflow"; 30 private static final String TYPE_FLOWSCRIPT = "flowscript"; 31 private static final String HAS_EXPIRED_NO = "no"; 32 private static final String HAS_EXPIRED_YES = "yes"; 33 34 private WebContinuation wc; 35 private SimpleDateFormat formatter = new SimpleDateFormat ("HH:mm:ss"); 36 private List _children = new ArrayList (); 37 38 public WebContinuationDataBean(WebContinuation wc) { 39 this.wc = wc; 40 for (Iterator it = wc.getChildren().iterator(); it.hasNext();) { 41 WebContinuationDataBean child = new WebContinuationDataBean( 42 (WebContinuation) it.next()); 43 this._children.add(child); 44 } 45 } 46 47 public String getId() { 48 return wc.getId(); 49 } 50 51 public String getLastAccessTime() { 52 return formatter.format(new Date (wc.getLastAccessTime())); 53 } 54 55 public String getInterpreterId() { 56 return wc.getInterpreterId(); 57 } 58 59 public String getTimeToLiveInMinutes() { 60 return Long.toString(wc.getTimeToLive() / 1000 / 60); 61 } 62 63 public String getTimeToLive() { 64 return Long.toString(wc.getTimeToLive()); 65 } 66 67 public String getExpireTime() { 68 return formatter.format(new Date (wc.getLastAccessTime() 69 + wc.getTimeToLive())); 70 } 71 72 public String hasExpired() { 73 if ((wc.getLastAccessTime() + wc.getTimeToLive()) < System 74 .currentTimeMillis()) { 75 return HAS_EXPIRED_YES; 76 } 77 return HAS_EXPIRED_NO; 78 79 } 80 81 public String getType() { 82 if (wc.getUserObject().getClass().getName().indexOf( 83 "FOM_WebContinuation") > 0) { 84 return TYPE_FLOWSCRIPT; 85 } 86 return TYPE_JAVAFLOW; 87 } 88 89 public List get_children() { 90 return this._children; 91 } 92 93 } 94 | Popular Tags |