FileDocCategorySizeDatePackage
MonitorListCommand.javaAPI DocGlassfish v2 API5053Fri May 04 22:33:44 BST 2007com.sun.enterprise.admin.monitor

MonitorListCommand

public class MonitorListCommand extends MonitorCommand
List command for monitoring.

Fields Summary
private static final int
LIST_TYPE
Constant to denote - List types of available MBeans
private static final int
LIST_INSTANCE
Constant to denote - List available MBean names.
private static final int
LIST_TYPE_AND_INSTANCE
Constant to denote - List available MBean types and names.
Constructors Summary
MonitorListCommand(ObjectName mbeanName)
Create a MonitorListCommand to list available MBean types and names. This command will produce a list of all child MBeans in the form type.name.

param
mbeanName object name of the MBean


                                        
      
        this.objectName = mbeanName;
        this.actionCode = LIST_TYPE_AND_INSTANCE;
    
MonitorListCommand(ObjectName mbeanName, MonitoredObjectType type)
Create a MonitorListCommand to list available MBean names. This command will produce a list of names of all child MBeans of specified type.

param
mbeanName object name of the MBean
param
type type of the child MBeans

        this.objectName = mbeanName;
        this.actionCode = LIST_INSTANCE;
        this.monitoredObjectType = type.getTypeName();
    
Methods Summary
java.lang.ObjectrunCommand()
Run the command to produce a list. The method returns a String[] of length 0 or more.

throws
InstanceNotFoundException if the MBean is not found.

        BaseMonitorMBean mbean = MonitoringHelper.getMonitorMBean(objectName);
        ArrayList childList = null;
        if (actionCode == LIST_INSTANCE) {
            childList = mbean.getChildList(
                    MonitoredObjectType.getMonitoredObjectType(monitoredObjectType));
        } else {
            childList = mbean.getChildList();
        }
        String[] result = new String[childList.size()];
        Iterator iter = childList.iterator();
        int i = 0;
        while (iter.hasNext()) {
            BaseMonitorMBean child = (BaseMonitorMBean)iter.next();
            MonitoredObjectType childType =
                    MonitoredObjectType.getMonitoredObjectType(child.getNodeType());
            if (actionCode == LIST_INSTANCE) {
                result[i] = child.getNodeName();
            } else {
                if (childType.isSingleton()) {
                    result[i] = child.getNodeType();
                } else {
                    result[i] = child.getNodeType() + "." + child.getNodeName();
                }
            }
            i++;
        }
        return result;