org.jboss.as.clustering.controller.Attribute.getName()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(70)

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

Attribute.getName介绍

[英]Returns the name of this attribute.
[中]返回此属性的名称。

代码示例

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

XMLElement(Attribute attribute) {
  this.name = attribute.getName();
}

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

XMLAttribute(Attribute attribute) {
  this.name = attribute.getName();
}

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

private static boolean hasDefined(ModelNode model, Collection<? extends Attribute> attributes) {
  for (Attribute attribute : attributes) {
    if (model.hasDefined(attribute.getName())) return true;
  }
  return false;
}

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

public static ModelNode createMapClearOperation(PathAddress address, Attribute attribute) {
  ModelNode operation = Util.createOperation(MapOperations.MAP_CLEAR_DEFINITION, address);
  operation.get(ModelDescriptionConstants.NAME).set(attribute.getName());
  return operation;
}

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

<E extends Enum<E> & org.jboss.as.clustering.controller.Attribute> LegacyAddOperationTransformation(Class<E> attributeClass) {
  // If none of the specified attributes are defined, then this is a legacy operation
  this.legacy = operation -> {
    for (org.jboss.as.clustering.controller.Attribute attribute : EnumSet.allOf(attributeClass)) {
      if (operation.hasDefined(attribute.getName())) return false;
    }
    return true;
  };
}

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

/**
 * Creates a new reference between the specified capability and the specified requirement
 * @param capability the capability referencing the specified requirement
 * @param requirement the requirement of the specified capability
 * @param parentAttribute the attribute containing the value of the parent dynamic component of the requirement
 */
public CapabilityReference(Capability capability, BinaryRequirement requirement, Attribute parentAttribute) {
  this(capability, requirement, context -> context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel().get(parentAttribute.getName()).asString(), parentAttribute.getName());
}

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

private static ModelNode createAttributeOperation(String operationName, PathAddress address, Attribute attribute) {
  ModelNode operation = Util.createOperation(operationName, address);
  operation.get(ModelDescriptionConstants.NAME).set(attribute.getName());
  return operation;
}

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

private static boolean hasDefined(ModelNode model, Iterable<? extends Attribute> attributes) {
  for (Attribute attribute : attributes) {
    if (model.hasDefined(attribute.getName())) return true;
  }
  return false;
}

代码示例来源: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

/**
 * 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

@Override
  public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) {
    ModelNode legacyOperation = this.transformer.transformOperation(operation);
    for (Attribute attribute: this.attributes) {
      String name = attribute.getName();
      if (operation.hasDefined(name)) {
        legacyOperation.get(name).set(operation.get(name));
      }
    }
    return new TransformedOperation(legacyOperation, OperationResultTransformer.ORIGINAL_RESULT);
  }
}

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

@Override
  public ModelNode transformOperation(ModelNode operation) {
    PathAddress storeAddress = Operations.getPathAddress(operation).getParent();
    ModelNode value = new ModelNode();
    for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.ColumnAttribute.class)) {
      for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) {
        String name = attribute.getName();
        if (operation.hasDefined(name)) {
          value.get(name).set(operation.get(name));
        }
      }
    }
    return value.isDefined() ? Operations.createWriteAttributeOperation(storeAddress, StringKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE, value) : Operations.createUndefineAttributeOperation(storeAddress, StringKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE);
  }
};

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

@Override
  public ModelNode transformOperation(ModelNode operation) {
    PathAddress storeAddress = Operations.getPathAddress(operation).getParent();
    ModelNode value = new ModelNode();
    for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.ColumnAttribute.class)) {
      for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) {
        String name = attribute.getName();
        if (operation.hasDefined(name)) {
          value.get(name).set(operation.get(name));
        }
      }
    }
    return value.isDefined() ? Operations.createWriteAttributeOperation(storeAddress, BinaryKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE, value) : Operations.createUndefineAttributeOperation(storeAddress, BinaryKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE);
  }
};

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

@Override
  public DiscardPolicy checkResource(TransformationContext context, PathAddress address) {
    ModelNode model = Resource.Tools.readModel(context.readResourceFromRoot(address));
    for (Attribute attribute : this.attributes) {
      if (model.hasDefined(attribute.getName())) {
        return DiscardPolicy.REJECT_AND_WARN;
      }
    }
    return DiscardPolicy.SILENT;
  }
}

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

@SuppressWarnings("deprecation")
  @Override
  public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress().append(StringTableResourceDefinition.PATH);
    ModelNode table = Operations.getAttributeValue(operation);
    for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(StringTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) {
      for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) {
        ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName()));
        context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(StringTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage());
      }
    }
  }
};

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

@SuppressWarnings("deprecation")
  @Override
  public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH);
    ModelNode table = Operations.getAttributeValue(operation);
    for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(BinaryTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) {
      for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) {
        ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName()));
        context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(BinaryTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage());
      }
    }
  }
};

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

void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(this.definition);

    if (JGroupsModel.VERSION_6_0_0.requiresTransformation(version)) {
      builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(this.queueLength.getDefinition()), this.queueLength.getName());
    }

    if (JGroupsModel.VERSION_5_0_0.requiresTransformation(version)) {
      for (Attribute attribute : Arrays.asList(this.minThreads, this.maxThreads)) {
        builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(attribute.getDefinition()), attribute.getName());
      }
    }
  }
}

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

@Override
public OperationStepHandler apply(OperationStepHandler handler) {
  return (context, operation) -> {
    if (operation.hasDefined(this.attribute.getName())) {
      // Translate deprecated table attribute into separate add table operation
      ModelNode addTableOperation = Util.createAddOperation(context.getCurrentAddress().append(this.path));
      ModelNode parameters = operation.get(this.attribute.getName());
      for (Property parameter : parameters.asPropertyList()) {
        addTableOperation.get(parameter.getName()).set(parameter.getValue());
      }
      context.addStep(addTableOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(this.path), ModelDescriptionConstants.ADD), context.getCurrentStage());
    }
    handler.execute(context, operation);
  };
}

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

private static void require(XMLExtendedStreamReader reader, ModelNode operation, Attribute... attributes) throws XMLStreamException {
  for (Attribute attribute : attributes) {
    if (!operation.hasDefined(attribute.getName())) {
      AttributeDefinition definition = attribute.getDefinition();
      Set<String> names = Collections.singleton(definition.getXmlName());
      throw definition.getParser().isParseAsElement() ? ParseUtils.missingRequiredElement(reader, names) : ParseUtils.missingRequired(reader, names);
    }
  }
}

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

@Override
  void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(this.getDefinition());
    if (JGroupsModel.VERSION_6_0_0.requiresTransformation(version)) {
      for (Attribute attribute : Arrays.asList(this.getMinThreads(), this.getMaxThreads(), this.getQueueLength())) {
        builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(attribute.getDefinition()), attribute.getName());
      }
    }
  }
},

相关文章

微信公众号

最新文章

更多