KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > stats > ClassStats


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.osgi.framework.stats;
12
13 import java.util.ArrayList JavaDoc;
14
15 /**
16  * Maintain statistics about a loaded class.
17  */

18 public class ClassStats {
19     private String JavaDoc className; // fully qualified name of this class
20
private ClassloaderStats classloader; // the classloader that loaded this class
21
private int loadOrder = -1;
22
23     private long timestamp; // time at which this class was loaded
24
private long timeLoading; // time to load the class
25
private long timeLoadingOthers = 0; // time spent loading classes which has been triggered by this class
26

27     // parentage of classes loaded
28
private ClassStats loadedBy = null; // a reference to the class that loaded this class
29
private ArrayList JavaDoc loaded = new ArrayList JavaDoc(2); // a reference to the classes that this class loaded
30

31     private boolean duringStartup; // indicate if the class was loaded during platform startup
32

33     //information to retrieve the stacktrace from the file
34
private long traceStart = -1;
35     private long traceEnd = -1;
36
37     public ClassStats(String JavaDoc name, ClassloaderStats classloader) {
38         className = name;
39         timestamp = System.currentTimeMillis();
40         duringStartup = StatsManager.isBooting();
41         this.classloader = classloader;
42     }
43
44     public void setLoadOrder(int order) {
45         loadOrder = order;
46     }
47
48     public void loadingDone() {
49         timeLoading = System.currentTimeMillis() - timestamp;
50     }
51
52     public long getTimeLoading() {
53         return timeLoading;
54     }
55
56     public long getLocalTimeLoading() {
57         return timeLoading - timeLoadingOthers;
58     }
59
60     public void addTimeLoadingOthers(long time) {
61         timeLoadingOthers = timeLoadingOthers + time;
62     }
63
64     public long getTraceStart() {
65         return traceStart;
66     }
67
68     public long getTraceEnd() {
69         return traceEnd;
70     }
71
72     public void setTraceStart(long position) {
73         traceStart = position;
74     }
75
76     public void setTraceEnd(long position) {
77         traceEnd = position;
78     }
79
80     public void loaded(ClassStats child) {
81         loaded.add(child);
82     }
83
84     public void setLoadedBy(ClassStats parent) {
85         loadedBy = parent;
86     }
87
88     public ClassStats getLoadedBy() {
89         return loadedBy;
90     }
91
92     public ArrayList JavaDoc getLoadedClasses() {
93         return loaded;
94     }
95
96     public String JavaDoc getClassName() {
97         return className;
98     }
99
100     public boolean isStartupClass() {
101         return duringStartup;
102     }
103
104     public ClassloaderStats getClassloader() {
105         return classloader;
106     }
107
108     public int getLoadOrder() {
109         return loadOrder;
110     }
111
112     public long getTimestamp() {
113         return timestamp;
114     }
115
116     public void toBaseClass() {
117         duringStartup = true;
118         loadOrder = -2;
119     }
120 }
Popular Tags