001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: MbeanItem.java 4408 2004-03-19 14:31:54Z sauthieg $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.mbean;
027:
028: import javax.management.ObjectName;
029:
030: import org.objectweb.jonas.webapp.jonasadmin.common.NameItem;
031:
032: /**
033: * @author Michel-Ange ANTON
034: */
035: public class MbeanItem implements NameItem {
036:
037: // --------------------------------------------------------- Constants
038:
039: public static final int FAMILY_UNKNOWN = 0;
040: public static final int FAMILY_OWNER = 1;
041: public static final int FAMILY_J2EE = 2;
042:
043: public static final int SIZE_FAMILIES = 3;
044: public static final String[] ALL_FAMILY_TEXT = { "unknown",
045: "owner", "j2ee" };
046:
047: // --------------------------------------------------------- Properties Variables
048:
049: private int family = FAMILY_UNKNOWN;
050: private String familyText = null;
051: private String objectName = null;
052: private String domain = null;
053: private String name = null;
054:
055: // --------------------------------------------------------- Constructors
056:
057: public MbeanItem() {
058: initialize();
059: }
060:
061: public MbeanItem(ObjectName p_ObjectName) {
062: initialize();
063: setObjectName(p_ObjectName.toString());
064: setDomain(p_ObjectName.getDomain());
065: }
066:
067: // --------------------------------------------------------- Protected Methods
068:
069: protected void initialize() {
070: setFamily(FAMILY_UNKNOWN);
071: }
072:
073: // --------------------------------------------------------- Public Methods
074:
075: /**
076: * Build the good instance of MbeanItem, J2eeMbeanItem or OwnerMbeanItem.
077: *
078: * @param p_ObjectName The MBean to build
079: * @return A instance of MbeanItem, J2eeMbeanItem or OwnerMbeanItem.
080: */
081: public static MbeanItem build(ObjectName p_ObjectName) {
082: MbeanItem oItem = null;
083: if (p_ObjectName.getKeyProperty("j2eeType") != null) {
084: oItem = new J2eeMbeanItem(p_ObjectName);
085: } else if (p_ObjectName.getKeyProperty("type") != null) {
086: oItem = new OwnerMbeanItem(p_ObjectName);
087: } else {
088: oItem = new MbeanItem(p_ObjectName);
089: }
090: return oItem;
091: }
092:
093: // --------------------------------------------------------- Properties Methods
094:
095: public int getFamily() {
096: return family;
097: }
098:
099: public void setFamily(int family) {
100: this .family = family;
101: }
102:
103: public int sizeFamilies() {
104: return SIZE_FAMILIES;
105: }
106:
107: public String getTextFamily() {
108: return ALL_FAMILY_TEXT[family];
109: }
110:
111: public String getObjectName() {
112: return objectName;
113: }
114:
115: public void setObjectName(String objectName) {
116: this .objectName = objectName;
117: }
118:
119: public String getDomain() {
120: return domain;
121: }
122:
123: public void setDomain(String domain) {
124: this .domain = domain;
125: }
126:
127: public String getName() {
128: return name;
129: }
130:
131: public void setName(String name) {
132: this.name = name;
133: }
134: }
|