Search in sources :

Example 21 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class JmsHandlers method getPhysicalDestination.

@Handler(id = "getPhysicalDestination", input = { @HandlerInput(name = "name", type = String.class, required = true), @HandlerInput(name = "type", type = String.class, required = true) }, output = { @HandlerOutput(name = "destData", type = java.util.Map.class) })
public static void getPhysicalDestination(HandlerContext handlerCtx) {
    String name = (String) handlerCtx.getInputValue("name");
    String type = (String) handlerCtx.getInputValue("type");
    Map valueMap = new HashMap();
    try {
        String objectName = getJmsDestinationObjectName(SUBTYPE_CONFIG, name, type);
        AttributeList attributes = (AttributeList) JMXUtil.getMBeanServer().getAttributes(new ObjectName(objectName), ATTRS_CONFIG);
        for (Attribute attribute : attributes.asList()) {
            valueMap.put(attribute.getName(), (attribute.getValue() != null) ? attribute.getValue().toString() : null);
        }
        handlerCtx.setOutputValue("destData", valueMap);
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    }
    handlerCtx.setOutputValue("destData", valueMap);
}
Also used : HashMap(java.util.HashMap) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ObjectName(javax.management.ObjectName) Handler(com.sun.jsftemplating.annotation.Handler)

Example 22 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class JmsHandlers method getPhysicalDestinationStats.

@Handler(id = "getPhysicalDestinationStats", input = { @HandlerInput(name = "name", type = String.class, required = true), @HandlerInput(name = "type", type = String.class, required = true), @HandlerInput(name = "target", type = String.class, required = true) }, output = { @HandlerOutput(name = "statsData", type = java.util.List.class) })
public static void getPhysicalDestinationStats(HandlerContext handlerCtx) {
    String name = (String) handlerCtx.getInputValue("name");
    String type = (String) handlerCtx.getInputValue("type");
    String target = (String) handlerCtx.getInputValue("target");
    List statsList = new ArrayList();
    try {
        insureJmsBrokerIsRunning();
        String objectName = getJmsDestinationObjectName(SUBTYPE_MONITOR, name, type);
        AttributeList attributes = (AttributeList) getMBeanServerConnection(target).getAttributes(new ObjectName(objectName), ATTRS_MONITOR);
        ResourceBundle bundle = GuiUtil.getBundle("org.glassfish.jms.admingui.Strings");
        statsList.add(createRow("Name", name, ""));
        statsList.add(createRow("Type", type.substring(0, 1).toUpperCase(GuiUtil.guiLocale) + type.substring(1), ""));
        for (Attribute attribute : attributes.asList()) {
            statsList.add(createRow(GuiUtil.getMessage(bundle, "jmsPhysDestinations." + attribute.getName()), attribute.getValue(), GuiUtil.getMessage(bundle, "jmsPhysDestinations." + attribute.getName() + "Help")));
        }
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    }
    handlerCtx.setOutputValue("statsData", statsList);
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) List(java.util.List) ResourceBundle(java.util.ResourceBundle) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ObjectName(javax.management.ObjectName) Handler(com.sun.jsftemplating.annotation.Handler)

Example 23 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class JmsHandlers method createPhysicalDestination.

/**
 * <p>This handler creates a physical destination.</p>
 * @param context The HandlerContext.
 */
@Handler(id = "createPhysicalDestination", input = { @HandlerInput(name = "name", type = String.class, required = true), @HandlerInput(name = "attributes", type = Map.class, required = true), @HandlerInput(name = "type", type = String.class) })
public static void createPhysicalDestination(HandlerContext handlerCtx) {
    try {
        final String type = (String) handlerCtx.getInputValue("type");
        final String name = (String) handlerCtx.getInputValue("name");
        AttributeList list = new AttributeList();
        // Copy attributes to the AttributeList.
        // Make it work, then make it right. :|
        Map attrMap = (Map) handlerCtx.getInputValue("attributes");
        buildAttributeList(list, attrMap, type);
        String[] types = new String[] { "java.lang.String", "java.lang.String", "javax.management.AttributeList" };
        Object[] params = new Object[] { type, name, list };
        JMXUtil.invoke(OBJECT_DEST_MGR, OP_CREATE, params, types);
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    }
}
Also used : AttributeList(javax.management.AttributeList) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Handler(com.sun.jsftemplating.annotation.Handler)

Example 24 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class JmsHandlers method deleteJMSDest.

@Handler(id = "deleteJMSDest", input = { @HandlerInput(name = "selectedRows", type = List.class, required = true) })
public static void deleteJMSDest(HandlerContext handlerCtx) {
    // String configName = ((String) handlerCtx.getInputValue("targetName"));
    List obj = (List) handlerCtx.getInputValue("selectedRows");
    List<Map> selectedRows = (List) obj;
    try {
        for (Map oneRow : selectedRows) {
            String name = (String) oneRow.get("name");
            String type = ((String) oneRow.get("type")).substring(0, 1).toLowerCase(GuiUtil.guiLocale);
            Object[] params = new Object[] { type, name };
            String[] types = new String[] { "java.lang.String", "java.lang.String" };
            JMXUtil.invoke(OBJECT_DEST_MGR, OP_DESTROY, params, types);
        }
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    }
}
Also used : AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Handler(com.sun.jsftemplating.annotation.Handler)

Example 25 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class JmsHandlers method getPhysicalDestinations.

@Handler(id = "getPhysicalDestinations", input = { @HandlerInput(name = "selectedRows", type = List.class) }, output = { @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getPhysicalDestinations(HandlerContext handlerCtx) {
    ObjectName[] objectNames = null;
    List result = new ArrayList();
    try {
        insureJmsBrokerIsRunning();
        // com.sun.messaging.jms.server:type=Destination,subtype=Config,desttype=q,name="mq.sys.dmq"
        objectNames = (ObjectName[]) JMXUtil.invoke(OBJECT_DEST_MGR, OP_LIST_DESTINATIONS);
        if (objectNames == null) {
            handlerCtx.setOutputValue("result", result);
            // nothing to load..
            return;
        }
        List<Map> selectedList = (List) handlerCtx.getInputValue("selectedRows");
        boolean hasOrig = (selectedList == null || selectedList.size() == 0) ? false : true;
        for (int i = 0; i < objectNames.length; i++) {
            // getAttributes for the given objectName...
            HashMap oneRow = new HashMap();
            oneRow.put("name", objectNames[i].getKeyProperty(PROP_NAME).replaceAll("\"", ""));
            oneRow.put("type", "t".equals(objectNames[i].getKeyProperty(PROP_DEST_TYPE)) ? "topic" : "queue");
            oneRow.put("selected", (hasOrig) ? isSelected(objectNames[i].getKeyProperty(PROP_NAME), selectedList) : false);
            result.add(oneRow);
        }
    } catch (Exception ex) {
        System.out.println("invoke:   " + OBJECT_DEST_MGR + ", method  =  " + OP_LIST_DESTINATIONS);
        GuiUtil.handleException(handlerCtx, ex);
    }
    handlerCtx.setOutputValue("result", result);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ObjectName(javax.management.ObjectName) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

Handler (com.sun.jsftemplating.annotation.Handler)167 ArrayList (java.util.ArrayList)85 Map (java.util.Map)85 List (java.util.List)82 HashMap (java.util.HashMap)81 TreeMap (java.util.TreeMap)14 IOException (java.io.IOException)12 Date (java.util.Date)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)8 LayoutViewHandler (com.sun.jsftemplating.layout.LayoutViewHandler)8 Image (com.sun.pkg.client.Image)8 ListIterator (java.util.ListIterator)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FacesContext (javax.faces.context.FacesContext)7 AttributeList (javax.management.AttributeList)7 RestResponse (org.glassfish.admingui.common.util.RestResponse)7 URL (java.net.URL)6 IntegrationPoint (org.glassfish.admingui.connector.IntegrationPoint)6 MultipleListDataProvider (com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider)5 TableRowGroup (com.sun.webui.jsf.component.TableRowGroup)5