The TMX4J Control Program is a simple, RMI-based, command-line
utility for accessing a JMX Agent via an RMI Connector Server. The RMI Connector
Server is an MBean that must be registered in the JMX Agent you want to access.
Because they are RMI-based both the RMI Connector Server and TMX4J require that
an instance of rmiregistry
be running somewhere in the network.
Before running the tmx4jcp, you need to verify that you have adequate permissions in your java.policy file. Check that your jre/lib/security/java.policy file has the java.net.SocketPermission permission entry set to at least "listen, connect, resolve". In addition, your RMI Agent needs to have adequate persmission set in its Security manager - see the StartRmiDaemon.bat for an example.
The syntax of the command is:
tmx4jcp --<command> <args>
where <command> <args> is one of:
query <object name>
create <class name> <object name>
show <object name>
invoke <object name> <method> [parameters]
update <object name> <attribute> <parameter>
unregister <object name>
help
parameters are specified as <value>:<type>
The tmx4jcp command defines a system property, tmx4j.connection, whose value
is the RMI binding string for the RMI Connector Server's MBeanServerConnection.
The tmx4jcp
script uses the value of the TMX4J_CONNECTION
environment variable to set this property. If TMX4J_CONNECTION
is not set in the environment the script uses a default value. The default value
is: //localhost/MBeanServerConnection
Skeleton and Stub files
The MBeanServerConnection makes use of the stub file MBeanServerConnectionImpl_Stub.class, which is located in the jmxext.jar. No skeleton file has been provided, as from JDK 1.2 this is no longer necessary.
These examples assume that a JMX Agent with an
RMIConnectorServer
MBean registered and started exists on
the network, the user's TMX4J_CONNECTION
environment
variable is set appropriately, and that the .class files for the
PersonMBean
are in the user's classpath.
tmx4jcp --create samples.rmitest.Person "people:gender=male,name=bob"
A new PersonMBean
will be created in the people
domain.
tmx4jcp --query "people:*"
Lists the members of the people
domain:
people:gender=male,name=bob
tmx4jcp --show "people:gender=male,name=bob"
Displays MBeanInfo
metadata describing "bob":
Object Name people:gender=male,name=bob Constructors samples.rmitest.Person(byte parameter0, int parameter1, int parameter2) samples.rmitest.Person() Operations void eat(java.lang.String parameter0, java.lang.String parameter1) void sleep(int parameter0) int work(int parameter0) Attributes -rw int Weight 165 -rw byte Age 21 -r- int Height 6 Notifications none
tmx4jcp --invoke "people:gender=male,name=bob" "work" "8:int"
Invokes the PersonMBean work
method on "bob" with a
value of 8 for parameter0
which has type
int
. The result, the total number of hours "bob" has
worked, is displayed as a result.
Note, all non-primitive types must be fully specified, e.g., a
String
parameter with a value of "Lunch" would be
specified as "Lunch:java.lang.String"
.
tmx4jcp --update "people:gender=male,name=bob" "Weight" "180:int"
Assigns the int
value 180 to "bob's"
Weight
attribute.
tmx4jcp --unregister "people:gender=male,name=bob"
Removes "bob" from the MBeanServer's registry.