J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | What is this demo about? |
| 2 | |
| 3 | This is "script shell" plugin for jconsole - the monitoring and management |
| 4 | client tool shipped with JRE. This plugin adds "Script Shell" tab to jconsole. |
| 5 | This serves as a demo for jconsole plugin API (com.sun.tools.jconsole) as well |
| 6 | as a demo for scripting API (javax.script) for the Java platform. |
| 7 | |
| 8 | Script console is an interactive read-eval-print interface that can be used |
| 9 | used to execute advanced monitoring and management queries. By default, |
| 10 | JavaScript is used as the scripting language. The scripting language can be |
| 11 | changed using the system property com.sun.demo.jconsole.console.language. To |
| 12 | use other scripting languages, you need to specify the corresponding engine |
| 13 | jar file in pluginpath along with this plugin's jar file. |
| 14 | |
| 15 | The following 3 global variables are exposed to the script engine: |
| 16 | |
| 17 | window javax.swing.JPanel |
| 18 | engine javax.script.ScriptEngine |
| 19 | plugin com.sun.tools.jconsole.JConsolePlugin |
| 20 | |
| 21 | If you use JavaScript, there are many useful global functions defined in |
| 22 | ./src/resources/jconsole.js. This is built into the script plugin jar file. |
| 23 | In addition, you can add other global functions and global variables by |
| 24 | defining those in ~/jconsole.js (or jconsole.<ext> where <ext> is the file |
| 25 | extension for your scripting language of choice under your home directory). |
| 26 | |
| 27 | How do I compile script console plugin? |
| 28 | |
| 29 | You can use the Java based build tool "ant" (http://ant.apache.org) to build |
| 30 | this plugin. To build using ant, please use the following command in the |
| 31 | current directory: |
| 32 | |
| 33 | ant |
| 34 | |
| 35 | How do I use script console plugin? |
| 36 | |
| 37 | To start jconsole with this plugin, please use the following command |
| 38 | |
| 39 | jconsole -pluginpath jconsole-plugin.jar |
| 40 | |
| 41 | How do I load my own script files in script console? |
| 42 | |
| 43 | If you use JavaScript (the default), then there is a global function called |
| 44 | "load" to load any script file from your file system. In script console |
| 45 | prompt, enter the following: |
| 46 | |
| 47 | load(<script-file-path>); |
| 48 | |
| 49 | where <script-file-path> is the path of your script file to load. If you don't |
| 50 | specify the file path, then the load function shows file dialog box to choose |
| 51 | the script file to load. |
| 52 | |
| 53 | How do I get help on script global functions? |
| 54 | |
| 55 | If you use JavaScript (the default), then there is a global function called |
| 56 | "help" that prints one-line help messages on global functions. In script |
| 57 | console prompt, enter the following: |
| 58 | |
| 59 | help(); |
| 60 | |
| 61 | Where are the sample JavaScript files? |
| 62 | |
| 63 | ./src/scripts directory contains JavaScript files that can be loaded into |
| 64 | script console. |