Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 2. Tutorial Example [ Next ]

Developing an M-Bean

The simple m-bean provided in SimpleBean.java implements the following design guidelines:

Example 2-1 shows the Java class definition of a simple m-bean.

Example 2-1. 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


[ Previous ][ Home ][ Next ]
Tutorial Example[ Up ]Developing an Agent