FileDocCategorySizeDatePackage
BeanMonitorTask.javaAPI DocGlassfish v2 API8334Fri May 04 22:25:18 BST 2007com.sun.enterprise.cli.commands.monitor

BeanMonitorTask

public abstract class BeanMonitorTask extends MonitorTask

Fields Summary
String
appName
String
ejbName
String
beanName
Constructors Summary
public BeanMonitorTask(ServerRootMonitor srm, String filter, Timer timer, boolean verbose, File fileName)

    

             
                                   
         
    
        super(srm, filter, timer, verbose, fileName);
    
Methods Summary
abstract booleancheckIfBeanExists(java.util.Map ejbModuleMap)

private java.lang.StringgetAvailableFilterMessage(java.lang.String[] appModuleFilters, java.lang.String[] ejbModuleFilters)

        StringBuffer sb = new StringBuffer();
        sb.append(localStrings.getString("commands.monitor.more_than_one_monitoring_elements"));
        if (ejbModuleFilters.length > 0)
        {
            sb.append(localStrings.getString("commands.monitor.available_ejbmodule_elements"));
            for (String ejbmodule : ejbModuleFilters)
            {
                sb.append("    ");
                sb.append(ejbmodule);
                sb.append("\n");
            }
        }
        if (appModuleFilters.length > 0)
        {
            sb.append(localStrings.getString("commands.monitor.available_appmodule_elements"));
            for (String appmodule: appModuleFilters)
            {
                sb.append("    ");
                sb.append(appmodule);
                sb.append("\n");
            }
        }
        return sb.toString();
    
abstract java.util.ListgetBeansInEjbModule(java.lang.String appName, java.util.Map ejbModuleMap)

voidgetDefaultFilter()
If filter option is not specified, then this method will get the default filter value.

        String[] appModuleFilters = possibleAppModuleFilters();
        String[] ejbModuleFilters = possibleEjbModuleFilters();        
            
        if (ejbModuleFilters.length < 1 && appModuleFilters.length < 1)
        {
            throw new MonitorTaskException(localStrings.getString("command.monitor.no_value_to_monitor"));
        }
        else if (ejbModuleFilters.length == 1 && appModuleFilters.length < 1)
        {
            filter = ejbModuleFilters[0];
            final StringTokenizer st = new StringTokenizer(filter, ":");
            ejbName = st.nextToken();
            beanName = st.nextToken();
        }
        else if (ejbModuleFilters.length < 1 && appModuleFilters.length == 1)
        {
            filter = appModuleFilters[0];
            final StringTokenizer st = new StringTokenizer(filter, ":");
            appName = st.nextToken();
            ejbName = st.nextToken();
            beanName = st.nextToken();            
        }
        else
        {
            final String msg = getAvailableFilterMessage(appModuleFilters, ejbModuleFilters);
            throw new MonitorTaskException(msg);
        }
    
java.lang.String[]possibleAppModuleFilters()
Returns all the possible ejbmodules in all the application. The return format is ::

        final Map<String,ApplicationMonitor> appModuleMap = srm.getApplicationMonitorMap();

        List<String> possibleFilters = new Vector<String>();
        if (appModuleMap != null && appModuleMap.size() > 0)
        {
                //search through all application and check for the ejbs
            final String[] appModules = MapUtil.getKeyStrings(appModuleMap);
            for (String appModule : appModules)
            {
                ApplicationMonitor am = (ApplicationMonitor)appModuleMap.get(appModule);
                    //search for the ejb in the appmodule
                final  Map<String,EJBModuleMonitor> innerEjbModuleMap = am.getEJBModuleMonitorMap();
                possibleFilters.addAll(getBeansInEjbModule(appModule, innerEjbModuleMap));
            }
        }
        return (String[])possibleFilters.toArray(new String[0]);
    
java.lang.String[]possibleEjbModuleFilters()
Returns all the possible servlets in all the ejbmodules. The return format is :

        final Map<String,EJBModuleMonitor> ejbModuleMap = srm.getEJBModuleMonitorMap();
        List<String> possibleFilters = getBeansInEjbModule(null, ejbModuleMap);
        return (String[])possibleFilters.toArray(new String[0]);
    
voidverifyFilterValue()

        if (appName != null)
        {
            final Map<String,ApplicationMonitor> appModuleMap = srm.getApplicationMonitorMap();
            if (appModuleMap.containsKey(appName))
            {
                final ApplicationMonitor am = appModuleMap.get(appName);
                final Map<String,EJBModuleMonitor> innerEJBModuleMap = am.getEJBModuleMonitorMap();
                
                final boolean exist = checkIfBeanExists(innerEJBModuleMap);
                if (!exist)
                    throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist_in2", new Object[] {beanName, appName, ejbName}));
            }
            else {
                throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist", new Object[] {appName}));
            }
        }
        else
        {
            final Map<String,EJBModuleMonitor> ejbModuleMap = srm.getEJBModuleMonitorMap();
            final boolean exist = checkIfBeanExists(ejbModuleMap);
            if (!exist)
                    throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist_in1", new Object[] {beanName, ejbName}));                
        }