001: /* JFox, the OpenSource J2EE Application Server
002: *
003: * Copyright (C) 2002 huihoo.org
004: * Distributable under GNU LGPL license
005: * See the GNU Lesser General Public License for more details.
006: */
007:
008: package example.jmx.modelmbean;
009:
010: /**
011: *
012: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
013: */
014:
015: public class TestBeanFriend implements java.io.Serializable {
016:
017: /*
018: * -----------------------------------------------------
019: * CONSTRUCTORS
020: * -----------------------------------------------------
021: */
022:
023: public TestBeanFriend() {
024: echo("\n\tTestBeanFriend Constructor invoked: State " + state
025: + " nbChanges: " + nbChanges + " nbResets: " + nbResets);
026: }
027:
028: /*
029: * -----------------------------------------------------
030: * OTHER PUBLIC METHODS
031: * -----------------------------------------------------
032: */
033:
034: /**
035: * Getter: get the "State" attribute of the "TestBeanFriend" managed resource.
036: */
037: public String getState() {
038: echo("\n\tTestBeanFriend: getStatus invoked:" + state);
039: return state;
040: }
041:
042: /**
043: * Setter: set the "State" attribute of the "TestBeanFriend" managed resourc.
044: */
045: public void setState(String s) {
046: state = s;
047: nbChanges++;
048: echo("\n\tTestBeanFriend: setState invoked: to " + state
049: + " nbChanges: " + nbChanges);
050: }
051:
052: /**
053: * Getter: get the "NbChanges" attribute of the "TestBeanFriend" managed resource.
054: */
055: public Integer getNbChanges() {
056: echo("\n\tTestBeanFriend:getNbChanges invoked: " + nbChanges);
057: return new Integer(nbChanges);
058: }
059:
060: /**
061: * Operation: reset to their initial values the "State" and "NbChanges"
062: * attributes of the "TestBeanFriend" managed resource.
063: */
064: public void reset() {
065: echo("\n\tTestBeanFriend: reset invoked ");
066: state = "reset initial state";
067: nbChanges = 0;
068: nbResets++;
069: }
070:
071: /**
072: * Return the "NbResets" property.
073: * This method is not a Getter in the JMX sense because
074: * it is not returned by the getMBeanInfo() method.
075: */
076: public Integer getNbResets() {
077: echo("\n\tTestBeanFriend: getNbResets invoked " + nbResets);
078: return new Integer(nbResets);
079: }
080:
081: /*
082: * -----------------------------------------------------
083: * PRIVATE METHODS
084: * -----------------------------------------------------
085: */
086:
087: private void echo(String outstr) {
088: System.out.println(outstr);
089: }
090:
091: /**
092:
093: /*
094: * -----------------------------------------------------
095: * PRIVATE VARIABLES
096: * -----------------------------------------------------
097: */
098:
099: private String state = "initial state";
100: private int nbChanges = 0;
101: private int nbResets = 0;
102:
103: }
|