Search in sources :

Example 1 with Option

use of com.sun.webui.jsf.model.Option 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 Option

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

the class SunOptionUtil method getOptionsArray.

public static Option[] getOptionsArray(String[] values) {
    Option[] options = (Option[]) Array.newInstance(SUN_OPTION_CLASS, values.length);
    for (int i = 0; i < values.length; i++) {
        Option option = getOption(values[i], values[i]);
        options[i] = option;
    }
    return options;
}
Also used : Option(com.sun.webui.jsf.model.Option)

Example 3 with Option

use of com.sun.webui.jsf.model.Option 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 4 with Option

use of com.sun.webui.jsf.model.Option 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)

Example 5 with Option

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

the class WoodstockHandler method populateComponentDropDown.

/**
 * <p>
 * Returns the list of monitorable components of an application</p>
 */
@Handler(id = "populateComponentDropDown", input = { @HandlerInput(name = "ModuleName", type = String.class, required = true), @HandlerInput(name = "VSList", type = List.class, required = true), @HandlerInput(name = "MonitorURL", type = String.class, required = true), @HandlerInput(name = "AppName", type = String.class, required = true) }, output = { @HandlerOutput(name = "ComponentList", type = Option[].class) })
public void populateComponentDropDown(HandlerContext handlerCtx) {
    String moduleName = (String) handlerCtx.getInputValue("ModuleName");
    String appname = (String) handlerCtx.getInputValue("AppName");
    String monitorURL = (String) handlerCtx.getInputValue("MonitorURL");
    List vsList = (List) handlerCtx.getInputValue("VSList");
    ArrayList menuList = new ArrayList();
    menuList.add(new Option("", ""));
    if (appname != null && !appname.isEmpty()) {
        // Servlet Instance Menu Options.
        List servletInstanceMenuOptions = getWebComponentMenuOptions(appname, moduleName, vsList, monitorURL, handlerCtx);
        menuList.addAll(servletInstanceMenuOptions);
        // EJB Menu options.
        if (!appname.equals(moduleName)) {
            Map<String, Object> compsMap = MonitoringHandlers.getSubComponents(appname, moduleName);
            if (compsMap != null && compsMap.size() > 0) {
                for (Map.Entry<String, Object> e : compsMap.entrySet()) {
                    if (!e.getValue().equals("Servlet")) {
                        List compMenuOptions = getEJBComponentMenuOptions(appname, moduleName, e.getKey(), monitorURL, handlerCtx);
                        menuList.addAll(compMenuOptions);
                    }
                }
            }
        }
        List resMenuOptions = getAppScopedResourcesMenuOptions(appname, moduleName, monitorURL, handlerCtx);
        if (resMenuOptions.size() > 0) {
            menuList.addAll(resMenuOptions);
        }
    }
    // Add Menu Options.
    jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
    handlerCtx.setOutputValue("ComponentList", jumpMenuOptions);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

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