@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(PROPERTIES)) { final ModelNode addOperation = operation.clone(); List<Property> properties = addOperation.remove(PROPERTIES).asPropertyList(); List<ModelNode> operations = new ArrayList<>(properties.size() + 1); operations.add(addOperation); PathAddress address = this.addressResolver.apply(addOperation); for (final Property property : properties) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode propertyAddOperation = Util.createAddOperation(address.append(PathElement.pathElement(PROPERTY, key))); propertyAddOperation.get(VALUE).set(value); operations.add(propertyAddOperation); } return Operations.createCompositeOperation(operations); } return operation; } }
@Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { if (operation != null && !(operation.hasDefined(OPERATION_HEADERS) && operation.get(OPERATION_HEADERS, "push-to-servers").asBoolean(false)) ){ operation = operation.clone(); String statefulCache = operation.get(DEFAULT_SFSB_CACHE).asString(); String statefulPassivationDisabledCache = operation.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).asString(); operation.get(DEFAULT_SFSB_CACHE).set(statefulPassivationDisabledCache); operation.get(EJB3SubsystemModel.DEFAULT_CLUSTERED_SFSB_CACHE).set(statefulCache); operation.remove(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE); } return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); } }
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.get(NAME).asString().equals(PROPERTIES)) { String key = operation.get("key").asString(); PathAddress address = Operations.getPathAddress(operation); ModelNode transformedOperation = Util.createOperation(READ_ATTRIBUTE_OPERATION, address.append(PathElement.pathElement(PROPERTY, key))); transformedOperation.get(NAME).set(VALUE); return transformedOperation; } return operation; } }
private void parseJts(final XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException { // no attributes if (reader.getAttributeCount() > 0) { throw unexpectedAttribute(reader, 0); } operation.get(CommonAttributes.JTS).set(true); requireNoContent(reader); }
@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); } });
private ModelNode getNoTextValueTypeDescription(final ModelNode parent) { final ModelNode valueType = parent.get(VALUE_TYPE); final ModelNode code = valueType.get(CODE); code.get(DESCRIPTION); // placeholder code.get(TYPE).set(ModelType.STRING); code.get(NILLABLE).set(false); code.get(MIN_LENGTH).set(1); final ModelNode flag = valueType.get(Constants.FLAG); flag.get(DESCRIPTION); // placeholder flag.get(TYPE).set(ModelType.STRING); flag.get(NILLABLE).set(false); for (ModuleFlag value : ModuleFlag.values()) { flag.get(ALLOWED).add(value.toString()); } final ModelNode module = valueType.get(Constants.MODULE); module.get(TYPE).set(ModelType.STRING); module.get(NILLABLE).set(true); final ModelNode moduleOptions = valueType.get(Constants.MODULE_OPTIONS); moduleOptions.get(DESCRIPTION); // placeholder moduleOptions.get(TYPE).set(ModelType.OBJECT); moduleOptions.get(VALUE_TYPE).set(ModelType.STRING); moduleOptions.get(NILLABLE).set(true); return valueType; } }
/** * {@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); }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String parameterName = operation.require(NAME).asString(); final ModelNode submodel = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); final ModelNode currentValue = submodel.hasDefined(parameterName) ? submodel.get(parameterName).clone() : new ModelNode(); context.getResult().set(currentValue); } }
@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; } };
@Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) { if (operation != null && !(operation.hasDefined(OPERATION_HEADERS) && operation.get(OPERATION_HEADERS, "push-to-servers").asBoolean(false)) ){ String originalAttribute = Operations.getAttributeName(operation); if (renames.containsKey(originalAttribute)){ operation = operation.clone(); operation.get(NAME).set(renames.get(originalAttribute)); } } return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT); }
@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { Resource untransformedResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode untransformedModel = Resource.Tools.readModel(untransformedResource); String statefulCache = untransformedModel.get(DEFAULT_SFSB_CACHE).asString(); String statefulPassivationDisabledCache = untransformedModel.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).asString(); ModelNode transformed = resource.getModel(); transformed.get(DEFAULT_SFSB_CACHE).set(statefulPassivationDisabledCache); transformed.get(EJB3SubsystemModel.DEFAULT_CLUSTERED_SFSB_CACHE).set(statefulCache); transformed.remove(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); childContext.processChildren(resource); } }
protected void parseJts(final XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException { // no attributes if (reader.getAttributeCount() > 0) { throw unexpectedAttribute(reader, 0); } operation.get(CommonAttributes.JTS).set(true); requireNoContent(reader); }
@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 protected void convertAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { if (attributeValue.isDefined()) { List<ModelNode> remoteServers = attributeValue.clone().asList(); ModelNode legacyListObject = new ModelNode(); for (ModelNode server : remoteServers) { ModelNode legacyListItem = new ModelNode(); legacyListItem.get("outbound-socket-binding").set(server); legacyListObject.add(legacyListItem); } attributeValue.set(legacyListObject); } } }, Attribute.SOCKET_BINDINGS.getDefinition());
private void populateModelWithObjectStoreConfig(ModelNode operation, ModelNode objectStoreModel) throws OperationFailedException { TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.validateAndSet(operation, objectStoreModel); TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.validateAndSet(operation, objectStoreModel); ModelNode relativeVal = objectStoreModel.get(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.getName()); ModelNode pathVal = objectStoreModel.get(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.getName()); if (!relativeVal.isDefined() && (!pathVal.isDefined() || pathVal.asString().equals(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.getDefaultValue().asString()))) { relativeVal.set(new ModelNode().set("jboss.server.data.dir")); TransactionLogger.ROOT_LOGGER.objectStoreRelativeToIsSetToDefault(); } }
@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; }