KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sitraka > jprobe > profiler > api > JPPerformanceAPIImpl


1 /*****************************************************************************
2  * Copyright (c) 1999, KL GROUP INC. All Rights Reserved.
3  * http://www.klg.com
4  *
5  * This software is the confidential and proprietary information of KL
6  * Group, Inc. ("Confidential Information"). You shall not disclose such
7  * Confidential Information and shall use it only in accordance with the
8  * terms of the license agreement you entered into with KL Group.
9  *
10  * KL GROUP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
11  * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
12  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
13  * PURPOSE, OR NON-INFRINGEMENT. KL GROUP SHALL NOT BE LIABLE FOR ANY
14  * DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
15  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
16  *****************************************************************************/

17 // RCSID -- $RCSfile: JPPerformanceAPIImpl.java $ $Revision: 1.1.1.2 $ $Date: 2000/10/26 19:56:26 $ $Locker: $ KL Group Inc.
18

19 /**
20  *
21  * @version $Revision: 1.1.1.2 $
22  * @author $Author: ccornu $
23  */

24
25 package com.sitraka.jprobe.profiler.api;
26
27 import com.sitraka.jprobe.api.*;
28
29 /**
30  * JPPerformanceAPIImpl is the concrete implementation of JPPerformanceAPI.
31  * It specifies the methods that can be used to control performance analysis
32  * and taking performance snapshots. An instance of this class is returned
33  * from JPPerformanceAPI.getInstance() when running under JProbe Profiler.
34  */

35
36 class JPPerformanceAPIImpl extends JPPerformanceAPI {
37
38 /**
39  * Initializer for Performance API.
40  * Protected to disallow public instantiation. The singleton design
41  * pattern is used to create a performance API.
42  * @exception UnsatisfiedLinkError If unable to load associated
43  * dll, then exception is raised.
44  */

45
46 protected JPPerformanceAPIImpl() throws UnsatisfiedLinkError JavaDoc {
47     System.loadLibrary("profiler");
48 }
49
50 /**
51  * Pauses the collection of timing data.
52  * By default, data is recorded automatically when the program starts.
53  * @return false if data is not currently being recorded.
54  * @see #isRecording
55  */

56 public boolean pauseRecording() {
57     return PauseRecording();
58 }
59
60
61 /**
62  * Resumes the collection of data.
63  * By default, data is recorded automatically when the program starts.
64  * @return false if data is currently being recorded.
65  * @see #isRecording
66  */

67 public boolean resumeRecording() {
68     return ResumeRecording();
69 }
70
71 /**
72  * Checks whether timing data is currently being recorded.
73  */

74 public boolean isRecording() {
75     return IsRecording();
76 }
77
78
79 /**
80  * Clears all the timing data recorded about the program to this point.
81  * You can use this method, for example, to ignore the data concerning the
82  * startup phase of your program.
83  * @return true if data was cleared
84  */

85 public boolean clear() {
86     return Clear();
87 }
88
89 /**
90  * Saves all the timing data recorded since the program started
91  * (or the last call to clear) in the given filename
92  * ( using ".jpp" as the extension.). If the file exists, a number
93  * is appended to the name.
94  * @param snapshot_name forms the name of the snapshot file, using ".jpp" as the extension.
95  * @return true if successful
96  */

97 public boolean save(String JavaDoc snapshot_name) {
98     return Save(snapshot_name);
99 }
100
101 /**
102  * Checks whether the program is running under Jprobe Profiler.
103  */

104 public boolean isRunning() {
105     return IsRunning();
106 }
107
108 /*
109  * Suspend the VM. If the VM is not running under the interactive control
110  * of the viewer, i.e. if the application was run standalone using jplauncher,
111  * this method will do nothing and return immediately. If running under the
112  * viewer, the application will be paused, allowing you to take snapshots or
113  * inspect performance data.
114  */

115  
116  public void suspend() {
117     Suspend();
118  }
119  
120
121 private native boolean PauseRecording();
122 private native boolean ResumeRecording();
123 private native boolean IsRecording();
124 private native boolean Clear();
125 private native boolean IsRunning();
126 private native boolean Save(String JavaDoc snapshot_name);
127 private native void Suspend();
128
129 }
130
131
Popular Tags