org.jboss.as.controller.operations.common.Util.createAddOperation()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.jboss.as.controller.operations.common.Util.createAddOperation()方法的一些代码示例,展示了Util.createAddOperation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createAddOperation()方法的具体详情如下:
包路径:org.jboss.as.controller.operations.common.Util
类名称:Util
方法名:createAddOperation

Util.createAddOperation介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

/**
 * Creates an add operation using the specified address and parameters
 * @param address a path address
 * @param parameters a map of values per attribute
 * @return an add operation
 */
public static ModelNode createAddOperation(PathAddress address, Map<Attribute, ModelNode> parameters) {
  ModelNode operation = Util.createAddOperation(address);
  for (Map.Entry<Attribute, ModelNode> entry : parameters.entrySet()) {
    operation.get(entry.getKey().getName()).set(entry.getValue());
  }
  return operation;
}

代码示例来源:origin: wildfly/wildfly

protected void parseRemote(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException {
  final int count = reader.getAttributeCount();
  ModelNode operation = Util.createAddOperation(SUBSYSTEM_PATH.append(SERVICE, REMOTE));
  final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.CONNECTOR_REF, EJB3SubsystemXMLAttribute.THREAD_POOL_NAME);
  for (int i = 0; i < count; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String value = reader.getAttributeValue(i);
    final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
    required.remove(attribute);
    switch (attribute) {
      case CONNECTOR_REF:
        EJB3RemoteResourceDefinition.CONNECTOR_REF.parseAndSetParameter(value, operation, reader);
        break;
      case THREAD_POOL_NAME:
        EJB3RemoteResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader);
        break;
      default:
        throw unexpectedAttribute(reader, i);
    }
  }
  if (!required.isEmpty()) {
    throw missingRequired(reader, required);
  }
  operation.get(EJB3SubsystemModel.EXECUTE_IN_WORKER).set(new ModelNode(false));
  requireNoContent(reader);
  operations.add(operation);
}

代码示例来源:origin: wildfly/wildfly

private void parseRemoteNaming(final XMLExtendedStreamReader reader, final List<ModelNode> operations, PathAddress parent) throws XMLStreamException {
  requireNoAttributes(reader);
  requireNoContent(reader);
  operations.add(Util.createAddOperation(parent.append(NamingSubsystemModel.SERVICE, NamingSubsystemModel.REMOTE_NAMING)));
}

代码示例来源:origin: wildfly/wildfly

private void parseAsync(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException {
  final int count = reader.getAttributeCount();
  //String threadPoolName = null;
  ModelNode operation = Util.createAddOperation(SUBSYSTEM_PATH.append(SERVICE, ASYNC));
  final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME);
  for (int i = 0; i < count; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String value = reader.getAttributeValue(i);
    final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
    required.remove(attribute);
    switch (attribute) {
      case THREAD_POOL_NAME:
        EJB3AsyncResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader);
        break;
      default:
        throw unexpectedAttribute(reader, i);
    }
  }
  if (!required.isEmpty()) {
    throw missingRequired(reader, required);
  }
  requireNoContent(reader);
  operations.add(operation);
}

代码示例来源:origin: wildfly/wildfly

@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;
  }
}

代码示例来源:origin: org.infinispan.server/infinispan-server-endpoints

private void parsePrefix(final XMLExtendedStreamReader reader, final ModelNode prefix, final List<ModelNode> operations) throws XMLStreamException {
 ParseUtils.requireAttributes(reader, Attribute.PATH.getLocalName());
 String path = reader.getAttributeValue(null, Attribute.PATH.getLocalName());
 PathAddress pathOpAddress = PathAddress.pathAddress(prefix.get(OP_ADDR)).append(ModelKeys.PREFIX, path);
 ModelNode pathOp = Util.createAddOperation(pathOpAddress);
 PrefixResource.PATH.parseAndSetParameter(path, pathOp, reader);
 ParseUtils.requireNoContent(reader);
 operations.add(pathOp);
}

代码示例来源:origin: wildfly/wildfly

private void parseOffHeapMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  PathAddress address = cacheAddress.append(OffHeapMemoryResourceDefinition.PATH);
  ModelNode operation = Util.createAddOperation(address);
  operations.put(address, operation);
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
    switch (attribute) {
      case CAPACITY: {
        readAttribute(reader, i, operation, OffHeapMemoryResourceDefinition.Attribute.CAPACITY);
        break;
      }
      default: {
        this.parseBinaryMemoryAttribute(reader, i, operation);
      }
    }
  }
  ParseUtils.requireNoContent(reader);
}

代码示例来源:origin: wildfly/wildfly

private void parseSimpleElectionPolicy(XMLExtendedStreamReader reader, PathAddress policyAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  PathAddress address = policyAddress.append(SimpleElectionPolicyResourceDefinition.PATH);
  ModelNode operation = Util.createAddOperation(address);
  operations.put(address, operation);
  for (int i = 0; i < reader.getAttributeCount(); ++i) {
    XMLAttribute attribute = XMLAttribute.forName(reader, i);
    switch (attribute) {
      case POSITION: {
        readAttribute(reader, i, operation, SimpleElectionPolicyResourceDefinition.Attribute.POSITION);
        break;
      }
      default: {
        throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }
  }
  this.parsePreferences(reader, operation);
}

代码示例来源:origin: wildfly/wildfly

private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException {
  final int attCount = reader.getAttributeCount();
  String name = null;
  final ModelNode bindingAdd = Util.createAddOperation();
  bindingAdd.get(BINDING_TYPE).set(LOOKUP);
  final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP);
  for (int i = 0; i < attCount; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String value = reader.getAttributeValue(i);
    final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
    required.remove(attribute);
    switch (attribute) {
        break;
      default:
        throw unexpectedAttribute(reader, i);
  bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode());
  operations.add(bindingAdd);

代码示例来源:origin: wildfly/wildfly

private void parseRemoteCacheContainerSecurity(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  PathAddress address = cacheAddress.append(SecurityResourceDefinition.PATH);
  ModelNode operation = Util.createAddOperation(address);
  operations.put(address, operation);
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
    switch (attribute) {
      case SSL_CONTEXT: {
        readAttribute(reader, i, operation, SecurityResourceDefinition.Attribute.SSL_CONTEXT);
        break;
      }
      default: {
        throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }
  }
  ParseUtils.requireNoContent(reader);
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
  @Override
  public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes or content
    requireNoAttributes(reader);
    requireNoContent(reader);
    list.add(Util.createAddOperation(PathAddress.pathAddress(WeldExtension.PATH_SUBSYSTEM)));
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
  if (operation.get(NAME).asString().equals(PROPERTIES)) {
    ModelNode newValue = context.readResourceFromRoot(resolvedAddress).getModel().get(PROPERTIES).clone();
          ModelNode addOp = Util.createAddOperation(legacyAddress.append(PathElement.pathElement(PROPERTY, key)));
          addOp.get(VALUE).set(value);
          operations.add(addOp);
        } else {
          final ModelNode oldPropValue = oldMap.get(key);
            operations.add(writeOp);
      operations.add(removeOperation);
    initialValue.set(newValue.clone());

代码示例来源:origin: wildfly/wildfly

/**
 * Creates an indexed add operation using the specified address and parameters
 * @param address a path address
 * @param parameters a map of values per attribute
 * @return an add operation
 */
public static ModelNode createAddOperation(PathAddress address, int index, Map<Attribute, ModelNode> parameters) {
  ModelNode operation = Util.createAddOperation(address);
  operation.get(ModelDescriptionConstants.ADD_INDEX).set(index);
  for (Map.Entry<Attribute, ModelNode> entry : parameters.entrySet()) {
    operation.get(entry.getKey().getName()).set(entry.getValue());
  }
  return operation;
}

代码示例来源:origin: wildfly/wildfly

private void parseJDBCStoreStringTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  PathAddress address = storeAddress.append(StringTableResourceDefinition.PATH);
  ModelNode operation = Util.createAddOperation(address);
  operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(StringTableResourceDefinition.PATH), operation);
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
    switch (attribute) {
      case PREFIX: {
        readAttribute(reader, i, operation, StringTableResourceDefinition.Attribute.PREFIX);
        break;
      }
      default: {
        this.parseJDBCStoreTableAttribute(reader, i, operation);
      }
    }
  }
  this.parseJDBCStoreTableElements(reader, operation);
}

代码示例来源:origin: wildfly/wildfly

private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException {
  final int attCount = reader.getAttributeCount();
  String name = null;
  final ModelNode bindingAdd = Util.createAddOperation();
  bindingAdd.get(BINDING_TYPE).set(LOOKUP);
  final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP);
  for (int i = 0; i < attCount; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String value = reader.getAttributeValue(i);
    final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
    required.remove(attribute);
    switch (attribute) {
        break;
      default:
        throw unexpectedAttribute(reader, i);
  bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode());
  operations.add(bindingAdd);

代码示例来源:origin: wildfly/wildfly

private List<ModelNode> parseJuddiServer(XMLExtendedStreamReader reader, PathAddress parent) throws XMLStreamException {
  List<ModelNode> result = new ArrayList<ModelNode>();
  Set<Attribute> required = EnumSet.of(Attribute.PUBLISH_URL, Attribute.QUERY_URL);
  int count = reader.getAttributeCount();
  for (int i = 0; i < count; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String attrValue = reader.getAttributeValue(i);
    final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
    required.remove(attribute);
    switch (attribute) {
      case PUBLISH_URL: {
        ModelNode propOp = Util.createAddOperation(parent.append(ModelDescriptionConstants.PROPERTY, "javax.xml.registry.lifeCycleManagerURL"));
        VALUE.parseAndSetParameter(attrValue, propOp, reader);
        result.add(propOp);
        break;
      }
      case QUERY_URL: {
        ModelNode propOp = Util.createAddOperation(parent.append(ModelDescriptionConstants.PROPERTY, "javax.xml.registry.queryManagerURL"));
        VALUE.parseAndSetParameter(attrValue, propOp, reader);
        result.add(propOp);
        break;
      }
      default:
        throw unexpectedAttribute(reader, i);
    }
  }
  if (required.size() > 0) { throw missingRequired(reader, required); }
  requireNoContent(reader);
  return result;
}

代码示例来源:origin: wildfly/wildfly

private void parseAuthentication(List<ModelNode> list, PathAddress parentAddress, XMLExtendedStreamReader reader)
    throws XMLStreamException {
  requireNoAttributes(reader);
  PathAddress address = parentAddress.append(AUTHENTICATION, CLASSIC);
  ModelNode op = Util.createAddOperation(address);
  list.add(op);
  parseLoginModules(reader, address, list);
}

代码示例来源:origin: wildfly/wildfly

final ModelNode eeSubSystem = Util.createAddOperation(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM));
list.add(eeSubSystem);
        case GLOBAL_MODULES: {
          final ModelNode model = parseGlobalModules(reader);
          eeSubSystem.get(GlobalModulesDefinition.GLOBAL_MODULES).set(model);
          break;

代码示例来源:origin: wildfly/wildfly

private void addOpenjdkSubsystem(final PathAddress address, final ModelNode model,
                 final Map<PathAddress, ModelNode> migrateOperations) {
  final ModelNode operation = Util.createAddOperation(address);
  for (final Property property : model.asPropertyList()) {
    if (property.getValue().isDefined()) {
      operation.get(property.getName()).set(property.getValue());
    }
  }
  migrateOperations.put(address, operation);
}

代码示例来源:origin: wildfly/wildfly

private void parseJDBCStoreBinaryTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  PathAddress address = storeAddress.append(BinaryTableResourceDefinition.PATH);
  ModelNode operation = Util.createAddOperation(address);
  operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(BinaryTableResourceDefinition.PATH), operation);
  for (int i = 0; i < reader.getAttributeCount(); i++) {
    XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
    switch (attribute) {
      case PREFIX: {
        readAttribute(reader, i, operation, BinaryTableResourceDefinition.Attribute.PREFIX);
        break;
      }
      default: {
        this.parseJDBCStoreTableAttribute(reader, i, operation);
      }
    }
  }
  this.parseJDBCStoreTableElements(reader, operation);
}

相关文章