ajax4jmx release alpha-2.0 - April 2nd 2007
With this release I have decided to switch to JSON-RPC instead of GWT-RPC. This release implements the basics required for this switch.
Live Demos
JsonRpcDemo is an example of calling a JMX server using json-rpc via http-get and http-post.
TomcatPerformanceDemo
is the start for an ajax gui for showing the current performance of a
jakarta tomcat server. This first release is a short demonstration of
the concept of json-rpc method orchestration. Next releases will
continue this implementation.
The live demos from release alpha 1.0 are still active.
JSON-RPC
On the server side we are using JSON-RPC-Java.
We are supporting http-get and http-set.
On client side calling json-rpc within GWT is simple:
JsonRpcMethod getDomains= new JsonRpcMethod();
getDomains.setMethod("MBeanServer.getDomains");
getDomains.setCallback(new RequestCallback()
{
public void
onResponseReceived(Request arg0, Response arg1)
{
if
(arg1.getStatusCode() == 200)
{
Window.alert(arg1.getText();
}
}
getDomains.invoke();
The following classes are currently implemented:
- JsonRpcMethod: for calling an rpc-method
- JsonRpcCyclicMethod for cyclic calls to an rpc-method. This is useful for polling.
JMX specific classes:
- JmxMBeansAttributesQuery: helper class for querying mbean attributes
- JsonRpcJmxInvokeMethod: helper method for invoking a method on an mbean.
- JsonRpcCyclicJmxInvokeMethod: cyclic version of JsonRpcJmxInvokeMethod
Query Framework
For recurring queries on the server the query framework avoids
resending the queries to the server and is used for extending query
abilities of the server. This is a general framework which may be used
for querying different sources such as JMX Servers, SQL databases etc..
Queries are registered and stored within the QueryRegistry
. On registration of a query an id is returned. This id is used for executing a query:
JSONNumber id = new JSONNumber(1);
QueryMethod query = new QueryMethod();
query.setId(id);
query.setCallback(....);
query.invoke();
Method Orchestration
Asynchronous calls to the server often lead to cluttered code especially if we have to make calls in a specified order. J-SOFA project has an elegant solution for this. With this in mind I have started experimenting with GWT.
Here a short example:
MethodSequence sequence = new MethodSequence();
sequence.add(
new JsonRpcMethod("A")
);
sequence.add(
new JsonRpcMethod("B")
);
sequence.start();
This example calls method A waits for a response and then calls method
B. We may also add ParameterSetters which will get the response from
method A and will set the arguments for method B.
Further changes
- removed memory leak in the server when invoking charts
- check if cookies are enabled, so we can work with sessions
- black list to avoid misuse.
- tables are now sortable. sorting is done on the server.
Road map
- MBeanMethodPanel: for calling mbean methods
- JsonRpcSimpleJmxBrowser: a jmx browser based on json-rpc
- support jmx security
- support JVM, Jboss, Geronimo and other JMX enabled programs.
ajax4jmx initial release alpha-1.0 - December 20th 2006
Ajax4Jmx is the first open source (correct me if I am wrong) ajax
enabled framework for building customized user interfaces for JMX.
It is implemented with GWT, Google's Widget Toolkit.
Live Demos
SimpleJmxBrowser
is an example of how simple it is to build a jmx browser - using
JmxTablesAndButtons in stack layout Single Click Listener and
MBeanAttributesTable
RZOMX Job Management Console - using JmxTablesAndButtons in vertical layout and Double Click Listener
NOTE:
The connection and server are slow so you may have to be patient.
You have access to all mbeans please do not abuse. Please do not change the settings of tomcat (MXhttpAdapter mbeans)
If you start processes with the job management console please also stop them. These are real processes not just dummy display.
General Purpose Widgets
The following Widgets are general purpose and can be used without JMX:
- Table
- VerticalTable: header to the left, row and columns swapped.
- HorizontalTable: header on top.
- Switching between Horizontal or Vertical tables is API transparent The meanings of row and columns are swapped.
- Multiple selection using CTRL and SHIFT keys
- Row Style rules, defining style of a row for a given value of a
column. Usage: display the row in red color if status field contains
the string "ERROR".
- Single Click Listener
- Double Click Listener
- Editable fields
- Invisible fields
- Add Widget (button) to column header
- TablesAndButtons
- A panel with different layouts into which tables and buttons
can be added. Button Click is executed on all selected rows in the
tables.
- Layouts:
- Horizontal: tables are laid out horizontally at the top. Buttons are layed out horizontally under the tables.
- Vertical: tables are layed out vertically to the left. Buttons are layed out vertically to the right of the tables.
- Stack: tables are layed out in a stack panel, buttons are layed out vertically to the right of the stack.
JMX specific Widgets
The following Widgets are JMX specific and require access to a JMX server.
- JmxTable
- Dynamic table for displaying mbean attribute values.
- For a given list of mbean pattern names
- Display a list of attributes
- Define which attributes are editable
- Define which attributes are invisible
- JmxTablesAndButtons
- Enables Adding buttons corresponding to method of an mbean, eg click on the button will invoke the method on the mbean.
- MBeanAttributesTable
- For a given mbean name
- Dynamic display of all fields of an mbean
- Writable fields are automatically editable.
- Change of a field is transfered to the JMX server
- JmxChart
- For a given mbean name and a numerical attribute
- Display a dynamic time chart of the attribute values or changes of attribute values (delta).
- ServerTime
- Dynamic clock displaying current time of server
- ServerInfo
- Displays the following information from the server:
- Id of JMX server
- Default Domain of JMX server
- IP address of server
- Host name of server
Implementation Details - TODO -
All Widgets implement the GWTComponent
interface. This defines the life cycle contract implemented by the
components. The methods must be called in the following order:
- set properties
- init() Initialize the component. After this call setting or changing of properties is not permitted.
- start() Starts the dynamic component
- stop() Stops the dynamic component. Must be called before the component is destroyed to cleanup on the server
On the server side 2 servlets are required:
- GwtJmxService: Bridge between GWT client and MBean server. In the current version the first server found is used.
- GwtJmxData: Delivers data by direct http call. Currently used for delivering Chart Images.
Quick Start
Download and unzip the file.
Directory structure:
- lib: third party libraries (including GWT 1.3)
- samples: source code of sample applications: currently simple jmx browser
- bat: windows batch files for running the gwt shell and compiler
- bin: class files
- webapps: directory used by embeded tomcat containing the compiled GWT application
If you are using eclipse import the project and the launch files. All
references are relative so it should work without having to set the
paths to the libraries.
The current distribution comes with 2 runnables:
If you would like to try it with your own JMX server: create an instance of org.rzo.ajax4jmx.httpadapter.MxHttpAdapter within your jmx server and call the init() and start() methods. Copy webapps directory or set the catalina.home property.
ToDo
a lot. :))
If you have comments, feature requests, suggestions, please discuss them on the GWT developer forum or on the sourceforge tracker
- Ron