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);
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations