KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Contains information about activated bundles and acts as the main
17  * entry point for logging plugin activity.
18  */

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

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