01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.flow;
18:
19: import java.text.SimpleDateFormat;
20: import java.util.ArrayList;
21: import java.util.Date;
22: import java.util.Iterator;
23: import java.util.List;
24:
25: /**
26: * Access to continuation data for monitoring applications
27: */
28: public class WebContinuationDataBean {
29:
30: private static final String TYPE_JAVAFLOW = "javaflow";
31: private static final String TYPE_FLOWSCRIPT = "flowscript";
32: private static final String HAS_EXPIRED_NO = "no";
33: private static final String HAS_EXPIRED_YES = "yes";
34:
35: private WebContinuation wc;
36: private SimpleDateFormat formatter = new SimpleDateFormat(
37: "HH:mm:ss");
38: private List _children = new ArrayList();
39:
40: public WebContinuationDataBean(WebContinuation wc) {
41: this .wc = wc;
42: for (Iterator it = wc.getChildren().iterator(); it.hasNext();) {
43: WebContinuationDataBean child = new WebContinuationDataBean(
44: (WebContinuation) it.next());
45: this ._children.add(child);
46: }
47: }
48:
49: public String getId() {
50: return wc.getId();
51: }
52:
53: public String getLastAccessTime() {
54: return formatter.format(new Date(wc.getLastAccessTime()));
55: }
56:
57: public String getInterpreterId() {
58: return wc.getInterpreterId();
59: }
60:
61: public String getTimeToLiveInMinutes() {
62: return Long.toString(wc.getTimeToLive() / 1000 / 60);
63: }
64:
65: public String getTimeToLive() {
66: return Long.toString(wc.getTimeToLive());
67: }
68:
69: public String getExpireTime() {
70: return formatter.format(new Date(wc.getLastAccessTime()
71: + wc.getTimeToLive()));
72: }
73:
74: public String hasExpired() {
75: if ((wc.getLastAccessTime() + wc.getTimeToLive()) < System
76: .currentTimeMillis()) {
77: return HAS_EXPIRED_YES;
78: }
79: return HAS_EXPIRED_NO;
80:
81: }
82:
83: public String getType() {
84: if (wc.getUserObject().getClass().getName().indexOf(
85: "FOM_WebContinuation") > -1) {
86: return TYPE_FLOWSCRIPT;
87: }
88: return TYPE_JAVAFLOW;
89: }
90:
91: public List get_children() {
92: return this._children;
93: }
94:
95: }
|