Search in sources :

Example 1 with OptionGroup

use of com.sun.webui.jsf.model.OptionGroup in project Payara by payara.

the class WoodstockHandler method populateApplicationsMonitorDropDown.

/**
 * <p>
 * Returns the list of monitorable application components</p>
 */
@Handler(id = "populateApplicationsMonitorDropDown", input = { @HandlerInput(name = "AppsList", type = List.class, required = true), @HandlerInput(name = "monitorURL", type = String.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class), @HandlerOutput(name = "FirstItem", type = String.class) })
public void populateApplicationsMonitorDropDown(HandlerContext handlerCtx) {
    List aList = (List) handlerCtx.getInputValue("AppsList");
    String monitorURL = (String) handlerCtx.getInputValue("monitorURL");
    ArrayList menuList = new ArrayList();
    String firstItem = null;
    String title = null;
    if (aList != null) {
        ListIterator al = aList.listIterator();
        while (al.hasNext()) {
            ArrayList moduleList = new ArrayList();
            String appName = (String) al.next();
            // Add the application name link in the dropdown if there are any app scoped resources.
            if (MonitoringHandlers.doesMonitoringDataExist(monitorURL + "/applications/" + appName + "/resources")) {
                moduleList.add(appName);
            }
            Set<String> modules = new HashSet<String>();
            try {
                modules = RestUtil.getChildMap(GuiUtil.getSessionValue("REST_URL") + "/applications/application/" + appName + "/module").keySet();
            } catch (Exception ex) {
                GuiUtil.handleException(handlerCtx, ex);
            }
            for (String moduleName : modules) {
                if (MonitoringHandlers.doesAppProxyExist(appName, moduleName)) {
                    if (!moduleList.contains(moduleName)) {
                        moduleList.add(moduleName);
                    }
                }
            }
            if (moduleList.isEmpty()) {
                menuList.add(new Option(appName, appName));
                if (firstItem == null) {
                    firstItem = appName;
                }
            } else {
                OptionGroup menuOptions = getMenuOptions(moduleList, appName, "", false);
                menuList.add(menuOptions);
                if (firstItem == null) {
                    firstItem = (String) moduleList.get(0);
                }
            }
        }
    }
    // Add Menu Options.
    jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
    handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
    handlerCtx.setOutputValue("FirstItem", firstItem);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) ListIterator(java.util.ListIterator) IOException(java.io.IOException) HashSet(java.util.HashSet) Handler(com.sun.jsftemplating.annotation.Handler)

Example 2 with OptionGroup

use of com.sun.webui.jsf.model.OptionGroup in project Payara by payara.

the class WoodstockHandler method getEJBComponentMenuOptions.

private static List getEJBComponentMenuOptions(String appname, String modulename, String compName, String monitorURL, HandlerContext handlerCtx) {
    String endpoint = monitorURL + "/applications/" + appname + "/" + modulename + "/" + compName;
    List compMenuList = new ArrayList();
    List menuList = new ArrayList();
    Set<String> compChildSet = null;
    try {
        if (appname.equals(modulename)) {
            endpoint = monitorURL + "/applications/" + appname + "/" + compName;
        }
        compChildSet = RestUtil.getChildMap(endpoint).keySet();
    } catch (Exception ex) {
        GuiUtil.getLogger().severe("Error in getEJBComponentMenuOptions ; \nendpoint = " + endpoint + "method=GET");
    }
    if (compChildSet != null) {
        for (String child : compChildSet) {
            Set<String> subCompChildSet = null;
            try {
                subCompChildSet = RestUtil.getChildMap(endpoint + "/" + child).keySet();
            } catch (Exception ex) {
                GuiUtil.getLogger().severe("Error in getEJBComponentMenuOptions ; \nendpoint = " + endpoint + "/" + child + "method=GET");
            }
            if ((subCompChildSet != null) && subCompChildSet.size() > 0) {
                // For ex: bean-methods
                OptionGroup childCompMenuOptions = getMenuOptions(new ArrayList(subCompChildSet), child, compName, true);
                menuList.add(childCompMenuOptions);
            } else {
                // For ex: bean-cache and bean-
                compMenuList.add(child);
            }
        }
    }
    compMenuList.add(0, compName);
    OptionGroup compMenuOptions = getMenuOptions(compMenuList, compName, "", true);
    menuList.add(0, compMenuOptions);
    return menuList;
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException)

Example 3 with OptionGroup

use of com.sun.webui.jsf.model.OptionGroup in project Payara by payara.

the class WoodstockHandler method getAppScopedResourcesMenuOptions.

private static List getAppScopedResourcesMenuOptions(String appname, String modulename, String monitorURL, HandlerContext handlerCtx) {
    String endpoint = monitorURL + "/applications/" + appname + "/" + modulename + "/resources";
    List menuList = new ArrayList();
    Set<String> resChildSet = null;
    try {
        if (appname.equals(modulename)) {
            endpoint = monitorURL + "/applications/" + appname + "/resources";
        }
        resChildSet = RestUtil.getChildMap(endpoint).keySet();
    } catch (Exception ex) {
        GuiUtil.getLogger().severe("Error in getAppScopedResourcesMenuOptions ; \nendpoint = " + endpoint + "method=GET");
    }
    if (resChildSet != null && resChildSet.size() > 0) {
        OptionGroup childResMenuOptions = getMenuOptions(new ArrayList(resChildSet), "resources", "", true);
        menuList.add(childResMenuOptions);
    }
    return menuList;
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException)

Example 4 with OptionGroup

use of com.sun.webui.jsf.model.OptionGroup in project Payara by payara.

the class WoodstockHandler method populateServerMonitorDropDown.

/**
 * <p>
 * Returns the list of monitorable server components</p>
 */
@Handler(id = "populateServerMonitorDropDown", input = { @HandlerInput(name = "VSList", type = List.class, required = true), @HandlerInput(name = "GCList", type = List.class, required = true), @HandlerInput(name = "NLList", type = List.class, required = true), @HandlerInput(name = "ThreadSystemList", type = List.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class) })
public void populateServerMonitorDropDown(HandlerContext handlerCtx) {
    List vsList = (List) handlerCtx.getInputValue("VSList");
    List threadList = (List) handlerCtx.getInputValue("ThreadSystemList");
    List gcList = (List) handlerCtx.getInputValue("GCList");
    List nlList = (List) handlerCtx.getInputValue("NLList");
    ArrayList menuList = new ArrayList();
    menuList.add(new Option("", ""));
    // Menu for Virtual Servers
    OptionGroup vsMenuOptions = getMenuOptions(vsList, "virtual-server", "", false);
    if (vsMenuOptions != null) {
        menuList.add(vsMenuOptions);
    }
    // Menu for Listeners
    OptionGroup nlMenuOptions = getMenuOptions(nlList, "http-listener", "", false);
    if (nlMenuOptions != null) {
        menuList.add(nlMenuOptions);
    }
    // Menu for Garbage Collectors
    OptionGroup gcMenuOptions = getMenuOptions(gcList, "garbage-collector", "", false);
    if (gcMenuOptions != null) {
        menuList.add(gcMenuOptions);
    }
    // Menu for Thread System
    OptionGroup tsMenuOptions = getMenuOptions(threadList, "thread-system", "", false);
    if (tsMenuOptions != null) {
        menuList.add(tsMenuOptions);
    }
    // Add Menu Options.
    jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
    // Arrays.sort(jumpMenuOptions);
    handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) Handler(com.sun.jsftemplating.annotation.Handler)

Example 5 with OptionGroup

use of com.sun.webui.jsf.model.OptionGroup in project Payara by payara.

the class WoodstockHandler method populateResourceMonitorDropDown.

/**
 * <p>
 * Returns the list of monitorable resource components</p>
 */
@Handler(id = "populateResourceMonitorDropDown", input = { @HandlerInput(name = "ResourceList", type = List.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class), @HandlerOutput(name = "FirstItem", type = String.class) })
public void populateResourceMonitorDropDown(HandlerContext handlerCtx) {
    List rList = (List) handlerCtx.getInputValue("ResourceList");
    ArrayList menuList = new ArrayList();
    // Menu for Resources
    ArrayList resList = new ArrayList();
    String firstItem = null;
    if (rList != null) {
        ListIterator rl = rList.listIterator();
        while (rl.hasNext()) {
            String name = (String) rl.next();
            resList.add(new Option(name, name));
            if (firstItem == null) {
                firstItem = name;
            }
        }
    }
    Option[] groupedOptions1 = (Option[]) resList.toArray(new Option[resList.size()]);
    OptionGroup jumpGroup1 = new OptionGroup();
    jumpGroup1.setLabel("resources");
    jumpGroup1.setOptions(groupedOptions1);
    menuList.add(jumpGroup1);
    // Add Menu Options.
    jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
    handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
    handlerCtx.setOutputValue("FirstItem", firstItem);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) ListIterator(java.util.ListIterator) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

OptionGroup (com.sun.webui.jsf.model.OptionGroup)7 ArrayList (java.util.ArrayList)7 List (java.util.List)6 Option (com.sun.webui.jsf.model.Option)4 IOException (java.io.IOException)4 ListIterator (java.util.ListIterator)4 Handler (com.sun.jsftemplating.annotation.Handler)3 HashSet (java.util.HashSet)1