private ModelNode addAttributeDescription(final ResourceDescriptionResolver resolver, final Locale locale, final ResourceBundle bundle, final ModelNode node, final ModelType type, final boolean nillable, final MeasurementUnit measurementUnit, final String... suffixes) { final ModelNode valNode = node.get(suffixes[suffixes.length -1]); valNode.get(DESCRIPTION).set(resolver.getResourceAttributeValueTypeDescription(getName(), locale, bundle, suffixes)); valNode.get(TYPE).set(type); valNode.get(NILLABLE).set(nillable); if (measurementUnit != null) { valNode.get(UNIT).set(measurementUnit.getName()); } return valNode; }
private String obtainServerUUID() throws OperationFailedException { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), UUID); operation.get(INCLUDE_RUNTIME).set(true); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return null; } catch (IOException ex) { return null; } }
/** * {@inheritDoc} */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { String name = Operations.getAttributeName(operation); ModelNode legacyOperation = org.jboss.as.controller.client.helpers.Operations.createUndefineAttributeOperation(this.addressTransformer.transform(address).toModelNode(), name); return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT); } }
/** * Creates an add operation. * * @param address the address for the operation * * @return the operation */ public static ModelNode createAddOperation(final ModelNode address) { return createOperation(ADD, address); }
Result cmdResult = cli.cmd("/subsystem=jdr:generate-jdr-report()"); ModelNode response = cmdResult.getResponse(); if(Operations.isSuccessfulOutcome(response) || !embedded) { reportFailure(response); ModelNode result = response.get(ClientConstants.RESULT);
public static Double calculateOffset(MeasurementUnit first, MeasurementUnit second) throws MeasurementConversionException { if (first.isComparableTo(second) == false) { throw new MeasurementConversionException(MESSAGES.cannotConvert(first.name(), second.name())); } return Scale.calculateOffset(first.scale, second.scale); }
/** * {@inheritDoc} */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { String name = Operations.getAttributeName(operation); ModelNode legacyOperation = org.jboss.as.controller.client.helpers.Operations.createReadAttributeOperation(this.addressTransformer.transform(address).toModelNode(), name); return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT); } }
/** * Creates a new builder. * * @param autoCloseStreams whether streams should be automatically closed * * @return a new builder */ public static CompositeOperationBuilder create(final boolean autoCloseStreams) { return new CompositeOperationBuilder(createCompositeOperation(), autoCloseStreams); }
/** * Creates a non-recursive operation to read a resource. * * @param address the address to create the read for * * @return the operation */ public static ModelNode createReadResourceOperation(final ModelNode address) { return createReadResourceOperation(address, false); }
/** * {@inheritDoc} */ @Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { String name = Operations.getAttributeName(operation); ModelNode value = Operations.getAttributeValue(operation); ModelNode legacyOperation = org.jboss.as.controller.client.helpers.Operations.createWriteAttributeOperation(this.addressTransformer.transform(address).toModelNode(), name, value); return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT); } }
/** * A Java bean style getter to allow us to access the enum name from JSPs (e.g. ${measureUnits.name}). * * @return the enum name */ public String getName() { return name(); }
@Override public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) { PathAddress rebuiltAddress = PathAddress.EMPTY_ADDRESS; for (PathElement pathElement : aliasAddress) { if (pathElement.equals(LEGACY_PATH)) { try { if (aliasContext.readResourceFromRoot(rebuiltAddress, false).hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) { Set<Resource.ResourceEntry> children = aliasContext.readResourceFromRoot(rebuiltAddress, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()); if (children.size() > 1 && !Operations.getOperationName(aliasContext.getOperation()).equals(AliasContext.RECURSIVE_GLOBAL_OP)) { throw new IllegalStateException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies()); } PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName())); rebuiltAddress = rebuiltAddress.append(proxyPath); } else { // handle :add rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.pathElement("default")); } } catch (Resource.NoSuchResourceException ignore) { // handle recursive-global-op rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.WILDCARD_PATH); } } else { rebuiltAddress = rebuiltAddress.append(pathElement); } } return rebuiltAddress; } });
private String obtainProductName() { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_NAME); operation.get(INCLUDE_RUNTIME).set(false); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return "undefined"; } catch (IOException e) { // This should not be needed since a product name is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } }
/** * Creates a remove operation. * * @param address the address for the operation * * @return the operation */ public static ModelNode createRemoveOperation(final ModelNode address) { return createOperation(REMOVE_OPERATION, address); }
public static Double calculateOffset(MeasurementUnit first, MeasurementUnit second) throws MeasurementConversionException { if (first.isComparableTo(second) == false) { throw new MeasurementConversionException(ControllerClientLogger.ROOT_LOGGER.cannotConvert(first.name(), second.name())); } return Scale.calculateOffset(first.scale, second.scale); }
.setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()) .setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()) .setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getDefinition().getMeasurementUnit().getName())) .setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000) .setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString()))
/** * Creates a new builder. * * @return a new builder */ public static CompositeOperationBuilder create() { return new CompositeOperationBuilder(createCompositeOperation()); }
private String obtainProductVersion() { try { ModelNode operation = Operations.createReadAttributeOperation(new ModelNode().setEmptyList(), PRODUCT_VERSION); operation.get(INCLUDE_RUNTIME).set(false); ModelControllerClient client = env.getClient(); if (client == null) { client = env.getCli().getCommandContext().getModelControllerClient(); } ModelNode result = client.execute(operation); if (Operations.isSuccessfulOutcome(result)) { return Operations.readResult(result).asString(); } return "undefined"; } catch (IOException e) { // This should not be needed since a product version is always returned, even if it doesn't exist. // In that case "undefined" is returned return "undefined"; } } }
/** * Creates a new builder. * * @param autoCloseStreams whether streams should be automatically closed * * @return a new builder */ public static CompositeOperationBuilder create(final boolean autoCloseStreams) { return new CompositeOperationBuilder(createCompositeOperation(), autoCloseStreams); }
/** * Creates a new builder. * * @return a new builder */ public static CompositeOperationBuilder create() { return new CompositeOperationBuilder(createCompositeOperation()); }