@Override public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) { final ResourceBundle bundle = getResourceBundle(locale); Map<String, ModelNode> children = new HashMap<String, ModelNode>(); ModelNode node = new ModelNode(); node.get(DESCRIPTION).set(bundle.getString("statistics")); children.put(STATISTICS, node); return children; } };
warnings.add(JacORBLogger.ROOT_LOGGER.cannotEmulatePropertiesWarning(unsupportedProperties)); for(String unsupportedProperty : unsupportedProperties){ jacorbModel.get(unsupportedProperty).clear(); ModelNode result = new ModelNode(); result.get(MIGRATION_OPERATIONS).set(values); ModelNode rw = new ModelNode().setEmptyList(); for (String warning : warnings) { rw.add(warning); result.get(MIGRATION_WARNINGS).set(rw); context.getResult().set(result); } else {
@Override protected void handleNode(OperationContext context, ModClusterStatus.Node ctx, ModelNode operation) throws OperationFailedException { final ModelNode result = new ModelNode(); for (String alias : ctx.getAliases()) { UndertowLogger.ROOT_LOGGER.tracef("Adding alias %s", alias); result.add(alias); } context.getResult().set(result); } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { nameValidator.validate(operation); final String attributeName = operation.require(NAME).asString(); // Don't require VALUE. Let the validator decide if it's bothered by an undefined value ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : new ModelNode(); final ModelNode resolvedValue = newValue.resolve(); switch (attributeName) { case ModelDescriptionConstants.STATISTICS_ENABLED: { stats.setEnabled(resolvedValue.asBoolean()); break; } } }
@Override protected void executeReadMetricStep(final OperationContext context, final ModelNode operation, final EJBComponent component) throws OperationFailedException { context.getResult().setEmptyObject(); for (final Map.Entry<String, InvocationMetrics.Values> entry : component.getInvocationMetrics().getMethods().entrySet()) { final InvocationMetrics.Values values = entry.getValue(); final ModelNode result = new ModelNode(); result.get("execution-time").set(values.getExecutionTime()); result.get("invocations").set(values.getInvocations()); result.get("wait-time").set(values.getWaitTime()); context.getResult().get(entry.getKey()).set(result); } } });
/** * Returns the attribute value of the specified operation * @param operation an operation * @return an attribute value */ public static ModelNode getAttributeValue(ModelNode operation) { return operation.hasDefined(ModelDescriptionConstants.VALUE) ? operation.get(ModelDescriptionConstants.VALUE) : new ModelNode(); }
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { TxStat stat = TxStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString()); if (stat == null) { context.getFailureDescription().set(TransactionLogger.ROOT_LOGGER.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString())); ModelNode result = new ModelNode(); switch (stat) { case NUMBER_OF_TRANSACTIONS: result.set(txStats.getNumberOfTransactions()); break; case NUMBER_OF_NESTED_TRANSACTIONS: result.set(txStats.getNumberOfNestedTransactions()); break; case NUMBER_OF_HEURISTICS:
/** * {@inheritDoc} */ @Override public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException { // Require no content ParseUtils.requireNoContent(reader); final ModelNode subsystem = new ModelNode(); subsystem.get(OP).set(ADD); subsystem.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); list.add(subsystem); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.isNormalServer()) { try (Connection connection = getDataSource(context).getConnection()) { context.getResult().set(new ModelNode().add(connection.isValid(0))); } catch (SQLException e) { throw AgroalLogger.SERVICE_LOGGER.invalidConnection(e, context.getCurrentAddressValue()); } } } }
@Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> { String jndiName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { ModelNode model = entry.getModel(); if (model.get("jndi-name").asString().equals(jndiName)) { return new ModelNode(entry.getName()); } } } } throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName); }; } };
@Override public ModelNode execute(ExpressionResolver expressionResolver, ModelNode operation, ModClusterServiceMBean service) { Map<InetSocketAddress, String> map = service.getProxyInfo(); if (!map.isEmpty()) { final ModelNode result = new ModelNode(); InetSocketAddress[] addresses = map.keySet().toArray(new InetSocketAddress[0]); for (InetSocketAddress address : addresses) { result.add(address.getHostName() + ":" + address.getPort()); } return result; } return null; } },
static ModelNode dsClsInfoNode(ServiceModuleLoader serviceModuleLoader, ModuleIdentifier mid, String dsClsName, String xaDSClsName) throws OperationFailedException { ModelNode result = new ModelNode(); if (dsClsName != null) { ModelNode dsNode = new ModelNode(); dsNode.get(dsClsName).set(findPropsFromCls(serviceModuleLoader, mid, dsClsName)); result.add(dsNode); } if (xaDSClsName != null) { ModelNode xaDSNode = new ModelNode(); xaDSNode.get(xaDSClsName).set(findPropsFromCls(serviceModuleLoader, mid, xaDSClsName)); result.add(xaDSNode); } return result; }
@Override public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) { Map<String, ModelNode> result = new HashMap<>(); for (Attribute attribute : attributes.values()) { ModelNode value = new ModelNode(); value.get(ModelDescriptionConstants.DESCRIPTION).set(attribute.getDescription()); result.put(attribute.getName(), value); } return result; }