KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jmx > adaptor > model > 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.jmx.adaptor.model;
23
24 import javax.management.MBeanInfo JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26
27 /** An mbean ObjectName and MBeanInfo pair that is orderable by ObjectName.
28  *
29  * @author Scott.Stark@jboss.org
30  * @version $Revision: 37459 $
31  */

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

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

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

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

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

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

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

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

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