KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > flow > WebContinuationDataBean


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.flow;
17
18 import java.text.SimpleDateFormat JavaDoc;
19 import java.util.ArrayList JavaDoc;
20 import java.util.Date JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * Access to continuation data for monitoring applications
26  */

27 public class WebContinuationDataBean {
28
29     private static final String JavaDoc TYPE_JAVAFLOW = "javaflow";
30     private static final String JavaDoc TYPE_FLOWSCRIPT = "flowscript";
31     private static final String JavaDoc HAS_EXPIRED_NO = "no";
32     private static final String JavaDoc HAS_EXPIRED_YES = "yes";
33
34     private WebContinuation wc;
35     private SimpleDateFormat JavaDoc formatter = new SimpleDateFormat JavaDoc("HH:mm:ss");
36     private List JavaDoc _children = new ArrayList JavaDoc();
37
38     public WebContinuationDataBean(WebContinuation wc) {
39         this.wc = wc;
40         for (Iterator JavaDoc 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 JavaDoc getId() {
48         return wc.getId();
49     }
50
51     public String JavaDoc getLastAccessTime() {
52         return formatter.format(new Date JavaDoc(wc.getLastAccessTime()));
53     }
54
55     public String JavaDoc getInterpreterId() {
56         return wc.getInterpreterId();
57     }
58
59     public String JavaDoc getTimeToLiveInMinutes() {
60         return Long.toString(wc.getTimeToLive() / 1000 / 60);
61     }
62
63     public String JavaDoc getTimeToLive() {
64         return Long.toString(wc.getTimeToLive());
65     }
66
67     public String JavaDoc getExpireTime() {
68         return formatter.format(new Date JavaDoc(wc.getLastAccessTime()
69                 + wc.getTimeToLive()));
70     }
71
72     public String JavaDoc 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 JavaDoc 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 JavaDoc get_children() {
90         return this._children;
91     }
92
93 }
94
Popular Tags