KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > internal > stats > BundleStats


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

11 package org.eclipse.core.runtime.internal.stats;
12
13 import java.util.ArrayList JavaDoc;
14
15 /**
16  * Contains information about activated bundles and acts as the main
17  * entry point for logging bundle activity.
18  */

19
20 public class BundleStats {
21     public String JavaDoc symbolicName;
22     public long id;
23     public int activationOrder;
24     private long timestamp; //timeStamp at which this bundle has been activated
25
private boolean duringStartup; // indicate if the bundle has been activated during startup
26
private long startupTime; // the time took by the bundle to startup
27
private long startupMethodTime; // the time took to run the startup method
28

29     // Indicate the position of the activation trace in the file
30
private long traceStart = -1;
31     private long traceEnd = -1;
32
33     //To keep bundle parentage
34
private ArrayList JavaDoc bundlesActivated = new ArrayList JavaDoc(3); // TODO create lazily
35
private BundleStats activatedBy = null;
36
37     public BundleStats(String JavaDoc name, long id) {
38         this.symbolicName = name;
39         this.id = id;
40     }
41
42     public long getTimestamp() {
43         return timestamp;
44     }
45
46     public int getActivationOrder() {
47         return activationOrder;
48     }
49
50     protected void activated(BundleStats info) {
51         bundlesActivated.add(info);
52     }
53
54     public BundleStats getActivatedBy() {
55         return activatedBy;
56     }
57
58     public long getId() {
59         return id;
60     }
61
62     public String JavaDoc getSymbolicName() {
63         return symbolicName;
64     }
65
66     public long getStartupTime() {
67         return startupTime;
68     }
69
70     public long getStartupMethodTime() {
71         return startupMethodTime;
72     }
73
74     public boolean isStartupBundle() {
75         return duringStartup;
76     }
77
78     public int getClassLoadCount() {
79         if (!StatsManager.MONITOR_CLASSES)
80             return 0;
81         ClassloaderStats loader = ClassloaderStats.getLoader(symbolicName);
82         return loader == null ? 0 : loader.getClassLoadCount();
83     }
84
85     public long getClassLoadTime() {
86         if (!StatsManager.MONITOR_CLASSES)
87             return 0;
88         ClassloaderStats loader = ClassloaderStats.getLoader(symbolicName);
89         return loader == null ? 0 : loader.getClassLoadTime();
90     }
91
92     public ArrayList JavaDoc getBundlesActivated() {
93         return bundlesActivated;
94     }
95
96     public long getTraceStart() {
97         return traceStart;
98     }
99
100     public long getTraceEnd() {
101         return traceEnd;
102     }
103
104     protected void setTimestamp(long value) {
105         timestamp = value;
106     }
107
108     protected void setActivationOrder(int value) {
109         activationOrder = value;
110     }
111
112     protected void setTraceStart(long time) {
113         traceStart = time;
114     }
115
116     protected void setDuringStartup(boolean value) {
117         duringStartup = value;
118     }
119
120     protected void endActivation() {
121         startupTime = System.currentTimeMillis() - timestamp;
122     }
123
124     protected void setTraceEnd(long position) {
125         traceEnd = position;
126     }
127
128     protected void setActivatedBy(BundleStats value) {
129         activatedBy = value;
130     }
131 }
132
Popular Tags