KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > mbean > MbeanItem


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: MbeanItem.java,v 1.3 2004/03/19 14:31:47 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.mbean;
27
28 import javax.management.ObjectName JavaDoc;
29
30 import org.objectweb.jonas.webapp.jonasadmin.common.NameItem;
31
32 /**
33  * @author Michel-Ange ANTON
34  */

35 public class MbeanItem implements NameItem {
36
37 // --------------------------------------------------------- Constants
38

39     public static final int FAMILY_UNKNOWN = 0;
40     public static final int FAMILY_OWNER = 1;
41     public static final int FAMILY_J2EE = 2;
42
43     public static final int SIZE_FAMILIES = 3;
44     public static final String JavaDoc[] ALL_FAMILY_TEXT = {
45         "unknown", "owner", "j2ee"};
46
47 // --------------------------------------------------------- Properties Variables
48

49     private int family = FAMILY_UNKNOWN;
50     private String JavaDoc familyText = null;
51     private String JavaDoc objectName = null;
52     private String JavaDoc domain = null;
53     private String JavaDoc name = null;
54
55 // --------------------------------------------------------- Constructors
56

57     public MbeanItem() {
58         initialize();
59     }
60
61     public MbeanItem(ObjectName JavaDoc p_ObjectName) {
62         initialize();
63         setObjectName(p_ObjectName.toString());
64         setDomain(p_ObjectName.getDomain());
65     }
66
67 // --------------------------------------------------------- Protected Methods
68

69     protected void initialize() {
70         setFamily(FAMILY_UNKNOWN);
71     }
72
73 // --------------------------------------------------------- Public Methods
74

75     /**
76      * Build the good instance of MbeanItem, J2eeMbeanItem or OwnerMbeanItem.
77      *
78      * @param p_ObjectName The MBean to build
79      * @return A instance of MbeanItem, J2eeMbeanItem or OwnerMbeanItem.
80      */

81     public static MbeanItem build(ObjectName JavaDoc p_ObjectName) {
82         MbeanItem oItem = null;
83         if (p_ObjectName.getKeyProperty("j2eeType") != null) {
84             oItem = new J2eeMbeanItem(p_ObjectName);
85         }
86         else if (p_ObjectName.getKeyProperty("type") != null) {
87             oItem = new OwnerMbeanItem(p_ObjectName);
88         }
89         else {
90             oItem = new MbeanItem(p_ObjectName);
91         }
92         return oItem;
93     }
94
95 // --------------------------------------------------------- Properties Methods
96

97     public int getFamily() {
98         return family;
99     }
100
101     public void setFamily(int family) {
102         this.family = family;
103     }
104
105     public int sizeFamilies() {
106         return SIZE_FAMILIES;
107     }
108
109     public String JavaDoc getTextFamily() {
110         return ALL_FAMILY_TEXT[family];
111     }
112
113     public String JavaDoc getObjectName() {
114         return objectName;
115     }
116
117     public void setObjectName(String JavaDoc objectName) {
118         this.objectName = objectName;
119     }
120
121     public String JavaDoc getDomain() {
122         return domain;
123     }
124
125     public void setDomain(String JavaDoc domain) {
126         this.domain = domain;
127     }
128
129     public String JavaDoc getName() {
130         return name;
131     }
132
133     public void setName(String JavaDoc name) {
134         this.name = name;
135     }
136 }
Popular Tags