KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > klg > jprobe > profiler > api > JPHeapAPIImpl


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: JPHeapAPIImpl.java $ $Revision: 1.5 $ $Date: 1999/07/18 18:15:08 $ $Locker: $ KL Group Inc.
18

19 /**
20  *
21  * @version $Revision: 1.5 $
22  * @author $Author: paulj $
23  */

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

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

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

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

68 public boolean resumeRecording() {
69     return ResumeRecording();
70 }
71
72
73 /**
74  * Checks whether stack traces are currently being recorded.
75  */

76 public boolean isRecording() {
77     return IsRecording();
78 }
79
80 /**
81  * Clears all the stack traces collected for objects allocated in
82  * the program to this point. You can use this method,
83  * for example, to ignore the objects allocated during startup phase of
84  * your program.
85  * @return true if data was cleared
86  */

87 public boolean clear() {
88     return Clear();
89 }
90
91
92 /**
93  * Saves heap snapshot at current point in program execution.
94  * @param snapshot_name forms the name of the snapshot file,
95  * using ".jph" as the extension.
96  * If the file exists, a number is appended to the name.
97  * @return true if successful
98  */

99 public boolean save(String JavaDoc snapshot_name) {
100     return Save(snapshot_name);
101 }
102
103 /**
104  * Checks whether the program is running under a JProbe product.
105  * @return true if currently running.
106  */

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

118
119 public void suspend() {
120     Suspend();
121  }
122
123 /**
124  * Set a checkpoint at the currrent time during program execution.
125  * @return always true
126  */

127 public boolean setCheckpoint() {
128     return SetCheckpoint();
129 }
130
131 /**
132  * Clears a checkpoint if one has been set.
133  * @return always true
134  */

135 public boolean clearCheckpoint() {
136     return ClearCheckpoint();
137 }
138
139 private native boolean PauseRecording();
140 private native boolean ResumeRecording();
141 private native boolean IsRecording();
142 private native boolean Clear();
143 private native boolean IsRunning();
144 private native boolean Save(String JavaDoc snapshot_name);
145 private native void Suspend();
146 private native boolean SetCheckpoint();
147 private native boolean ClearCheckpoint();
148
149
150 }
151
Popular Tags