KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > console > plugins > helpers > jmx > MBeanData


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.console.plugins.helpers.jmx;
23
24 import javax.management.MBeanInfo JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26
27 /** An mbean ObjectNamd and MBeanInfo pair
28  *
29  * @author Scott.Stark@jboss.org
30  * @version $Revision: 37459 $
31  */

32 public class MBeanData
33    implements Comparable JavaDoc
34 {
35    private ObjectName JavaDoc objectName;
36    private MBeanInfo JavaDoc metaData;
37
38    /** Creates a new instance of MBeanInfo */
39    public MBeanData(ObjectName JavaDoc objectName, MBeanInfo JavaDoc metaData)
40    {
41       this.objectName = objectName;
42       this.metaData = metaData;
43    }
44
45    /** Getter for property objectName.
46     * @return Value of property objectName.
47     */

48    public ObjectName JavaDoc getObjectName()
49    {
50       return objectName;
51    }
52    
53    /** Setter for property objectName.
54     * @param objectName New value of property objectName.
55     */

56    public void setObjectName(ObjectName JavaDoc objectName)
57    {
58       this.objectName = objectName;
59    }
60
61    /** Getter for property metaData.
62     * @return Value of property metaData.
63     */

64    public MBeanInfo JavaDoc getMetaData()
65    {
66       return metaData;
67    }
68    
69    /** Setter for property metaData.
70     * @param metaData New value of property metaData.
71     */

72    public void setMetaData(MBeanInfo JavaDoc metaData)
73    {
74       this.metaData = metaData;
75    }
76
77    /**
78     * @return The ObjectName.toString()
79     */

80    public String JavaDoc getName()
81    {
82       return objectName.toString();
83    }
84    /**
85     * @return The canonical key properties string
86     */

87    public String JavaDoc getNameProperties()
88    {
89       return objectName.getCanonicalKeyPropertyListString();
90    }
91    /**
92     * @return The MBeanInfo.getClassName() value
93     */

94    public String JavaDoc getClassName()
95    {
96       return metaData.getClassName();
97    }
98
99    /** Compares MBeanData based on the ObjectName domain name and canonical
100     * key properties
101     *
102     * @param o MBeanData to compare against
103     * @return < 0 if this is less than o, > 0 if this is greater than o,
104     * 0 if equal.
105     */

106    public int compareTo(Object JavaDoc o)
107    {
108       MBeanData md = (MBeanData) o;
109       String JavaDoc d1 = objectName.getDomain();
110       String JavaDoc d2 = md.objectName.getDomain();
111       int compare = d1.compareTo(d2);
112       if( compare == 0 )
113       {
114          String JavaDoc p1 = objectName.getCanonicalKeyPropertyListString();
115          String JavaDoc p2 = md.objectName.getCanonicalKeyPropertyListString();
116          compare = p1.compareTo(p2);
117       }
118       return compare;
119    }
120
121    public boolean equals(Object JavaDoc o)
122    {
123       if (o == null || (o instanceof MBeanData) == false)
124          return false;
125       if (this == o)
126          return true;
127       return (this.compareTo(o) == 0);
128    }
129 }
130
Popular Tags