01: package com.sun.portal.rproxy.monitoring.statistics;
02:
03: import com.sun.portal.monitoring.statistics.StatisticImpl;
04: import com.sun.portal.util.ThreadMonitorContext;
05: import com.sun.portal.util.TaskWrapper;
06: import com.sun.portal.netlet.econnection.GWRunnable;
07:
08: import javax.management.ObjectName;
09:
10: /**
11: * author: Noble Paul
12: * Date: Mar 4, 2005, 11:28:21 AM
13: */
14: public class ThreadActivityStatisticImpl extends StatisticImpl {
15:
16: private ThreadMonitorContext threadContext;
17:
18: private String destination;
19:
20: private static final String DEFAULT_DESTINATION = "NO DESTINATION";
21:
22: public void setDestination(String destination) {
23: this .destination = destination;
24: }
25:
26: public String getThreadName() {
27: return threadContext.getThread().getName();
28: }
29:
30: public ThreadActivityStatisticImpl(
31: ThreadMonitorContext threadContext) {
32: this .threadContext = threadContext;
33: }
34:
35: public void setThreadMonitorContext(
36: ThreadMonitorContext threadContext) {
37: this .threadContext = threadContext;
38:
39: }
40:
41: public String getTaskType() {
42: if (threadContext.getTask() == null)
43: return "NO TASK";
44: Runnable r = TaskWrapper.unwrap(threadContext.getTask());
45: if (r instanceof GWRunnable) {
46: GWRunnable gwRunnable = (GWRunnable) r;
47: return gwRunnable.getType();
48: } else {
49: return "UNKNOWN TASK";
50: }
51:
52: }
53:
54: public long getTaskStartTime() {
55: return threadContext.getTaskStartTime();
56: }
57:
58: public String getDestination() {
59: return destination == null ? DEFAULT_DESTINATION : destination;
60: }
61:
62: ObjectName objectName;
63:
64: public ObjectName getObjectName() {
65: return objectName;
66: }
67:
68: public void setObjectName(ObjectName objectName) {
69: this .objectName = objectName;
70: }
71:
72: public void reset() {
73: super .reset();
74: }
75:
76: public long getLastSampleTime() {
77: return System.currentTimeMillis();
78: }
79: }
|