blob: dac17f862d58a4c6d96c9e3d607724e8376f756c [file] [log] [blame]
Manuel L. Santillan295c1992006-09-09 17:48:36 +00001/*
2 * This script demonstrates "getMBeanAttribute"
3 * and "setMBeanAttribute" functions. Instead of using
4 * MXBean proxy or script wrapper object returned by
5 * 'mbean' function, this file uses direct get/set MBean
6 * attribute functions.
7 *
8 * To use this particular script, load this script file in
9 * script console prompt and call verboseGC or verboseClass
10 * functions. These functions based on events such as
11 * heap threshold crossing a given limit. i.e., A timer thread
12 * can keep checking for threshold event and then turn on
13 * verbose:gc or verbose:class based on expected event.
14
15 */
16
17/**
18 * Get or set verbose GC flag.
19 *
20 * @param flag verbose mode flag [optional]
21 *
22 * If flag is not passed verboseGC returns current
23 * flag value.
24 */
25function verboseGC(flag) {
26 if (flag == undefined) {
27 // no argument passed. interpret this as 'get'
28 return getMBeanAttribute("java.lang:type=Memory", "Verbose");
29 } else {
30 return setMBeanAttribute("java.lang:type=Memory", "Verbose", flag);
31 }
32}
33
34/**
35 * Get or set verbose class flag.
36 *
37 * @param flag verbose mode flag [optional]
38 *
39 * If flag is not passed verboseClass returns current
40 * flag value.
41 */
42function verboseClass(flag) {
43 if (flag == undefined) {
44 // no argument passed. interpret this as 'get'
45 return getMBeanAttribute("java.lang:type=ClassLoading", "Verbose");
46 } else {
47 return setMBeanAttribute("java.lang:type=ClassLoading", "Verbose", flag);
48 }
49}