MbeanItem.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: MbeanItem.java,v 1.3 2004/03/19 14:31:47 sauthieg Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.mbean;
00027 
00028 import javax.management.ObjectName;
00029 
00030 import org.objectweb.jonas.webapp.jonasadmin.common.NameItem;
00031 
00035 public class MbeanItem implements NameItem {
00036 
00037 // --------------------------------------------------------- Constants
00038 
00039     public static final int FAMILY_UNKNOWN = 0;
00040     public static final int FAMILY_OWNER = 1;
00041     public static final int FAMILY_J2EE = 2;
00042 
00043     public static final int SIZE_FAMILIES = 3;
00044     public static final String[] ALL_FAMILY_TEXT = {
00045         "unknown", "owner", "j2ee"};
00046 
00047 // --------------------------------------------------------- Properties Variables
00048 
00049     private int family = FAMILY_UNKNOWN;
00050     private String familyText = null;
00051     private String objectName = null;
00052     private String domain = null;
00053     private String name = null;
00054 
00055 // --------------------------------------------------------- Constructors
00056 
00057     public MbeanItem() {
00058         initialize();
00059     }
00060 
00061     public MbeanItem(ObjectName p_ObjectName) {
00062         initialize();
00063         setObjectName(p_ObjectName.toString());
00064         setDomain(p_ObjectName.getDomain());
00065     }
00066 
00067 // --------------------------------------------------------- Protected Methods
00068 
00069     protected void initialize() {
00070         setFamily(FAMILY_UNKNOWN);
00071     }
00072 
00073 // --------------------------------------------------------- Public Methods
00074 
00081     public static MbeanItem build(ObjectName p_ObjectName) {
00082         MbeanItem oItem = null;
00083         if (p_ObjectName.getKeyProperty("j2eeType") != null) {
00084             oItem = new J2eeMbeanItem(p_ObjectName);
00085         }
00086         else if (p_ObjectName.getKeyProperty("type") != null) {
00087             oItem = new OwnerMbeanItem(p_ObjectName);
00088         }
00089         else {
00090             oItem = new MbeanItem(p_ObjectName);
00091         }
00092         return oItem;
00093     }
00094 
00095 // --------------------------------------------------------- Properties Methods
00096 
00097     public int getFamily() {
00098         return family;
00099     }
00100 
00101     public void setFamily(int family) {
00102         this.family = family;
00103     }
00104 
00105     public int sizeFamilies() {
00106         return SIZE_FAMILIES;
00107     }
00108 
00109     public String getTextFamily() {
00110         return ALL_FAMILY_TEXT[family];
00111     }
00112 
00113     public String getObjectName() {
00114         return objectName;
00115     }
00116 
00117     public void setObjectName(String objectName) {
00118         this.objectName = objectName;
00119     }
00120 
00121     public String getDomain() {
00122         return domain;
00123     }
00124 
00125     public void setDomain(String domain) {
00126         this.domain = domain;
00127     }
00128 
00129     public String getName() {
00130         return name;
00131     }
00132 
00133     public void setName(String name) {
00134         this.name = name;
00135     }
00136 }

Generated on Tue Feb 15 15:05:28 2005 for JOnAS by  doxygen 1.3.9.1