Java Dynamic Management Kit 3.2 Programming Guide | ||||
---|---|---|---|---|
![]() | ![]() | Chapter 2. Tutorial Example | ![]() |
The simple m-bean provided in SimpleBean.java implements the following design guidelines:
Methods for reading and writing m-bean properties (getters and setters)
Public methods that are called remotely (actions)
Example 2-1 shows the Java class definition of a simple m-bean.
// Copyright (c) 03/12/99, by Sun Microsystems, Inc. // All rights reserved. // "@(#)SimpleBean.java 3.3 99/03/12 SMI" public class SimpleBean { // Getter for the "State" property. public String getState() { return state ; } // Setter for the "State" property. public void setState(String s) { state = s ; nbChanges++ ; } // Getter for the "NbChanges" property. public Integer getNbChanges() { return new Integer(nbChanges) ; } // Action on the "NbChanges" property. public void performReset() { nbChanges = 0 ; } // M-bean properties. protected String state = "initial state" ; protected int nbChanges = 0 ; } |
To compile the m-bean, type this command:
prompt% javac SimpleBean.java |
![]() | ![]() | ![]() |
Tutorial Example | ![]() | Developing an Agent |