use of org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer in project wildfly by wildfly.
the class FileStoreResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH);
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer())).inheritResourceAttributeDefinitions();
builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
}
StoreResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer in project wildfly by wildfly.
the class RemoteStoreResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH);
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setValueConverter(new AttributeConverter.DefaultAttributeConverter() {
@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());
}
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer())).inheritResourceAttributeDefinitions();
builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
}
StoreResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer in project wildfly by wildfly.
the class JDBCStoreResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
if (InfinispanModel.VERSION_4_2_0.requiresTransformation(version) && !InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
// DATASOURCE attribute was only supported as an add operation parameter
builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, DeprecatedAttribute.DATASOURCE.getDefinition());
}
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
// Converts pool name to its JNDI name
Converter converter = new Converter() {
@Override
public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) {
if (value.isDefined()) {
PathAddress rootAddress = address.subAddress(0, address.size() - 4);
PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources"));
Resource subsystem = context.readResourceFromRoot(subsystemAddress);
String poolName = value.asString();
for (String type : Arrays.asList("data-source", "xa-data-source")) {
if (subsystem.hasChildren(type)) {
for (Resource.ResourceEntry entry : subsystem.getChildren(type)) {
if (entry.getName().equals(poolName)) {
value.set(entry.getModel().get("jndi-name"));
return;
}
}
}
}
}
}
};
builder.getAttributeBuilder().addRename(Attribute.DATA_SOURCE.getName(), DeprecatedAttribute.DATASOURCE.getName()).setValueConverter(new SimpleAttributeConverter(converter), Attribute.DATA_SOURCE.getDefinition());
}
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer())).inheritResourceAttributeDefinitions();
}
if (InfinispanModel.VERSION_2_0_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.UNDEFINED, Attribute.DIALECT.getDefinition()).addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.DIALECT.getDefinition()).end();
}
StoreResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer in project wildfly by wildfly.
the class TransportResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
AbstractProtocolResourceDefinition.addTransformations(version, builder);
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(Attribute.SHARED.getDefinition()), Attribute.SHARED.getDefinition());
builder.setCustomResourceTransformer(new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
new LegacyPropertyResourceTransformer().transformResource(context, LEGACY_ADDRESS_TRANSFORMER.transform(address), resource);
}
});
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new org.jboss.as.clustering.controller.transform.OperationTransformer() {
@Override
public ModelNode transformOperation(final ModelNode operation) {
operation.get(ModelDescriptionConstants.OP_ADDR).set(LEGACY_ADDRESS_TRANSFORMER.transform(Operations.getPathAddress(operation)).toModelNode());
return new LegacyPropertyAddOperationTransformer().transformOperation(operation);
}
})).inheritResourceAttributeDefinitions();
builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleRemoveOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
builder.addOperationTransformationOverride(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleReadAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
builder.addOperationTransformationOverride(ModelDescriptionConstants.DESCRIBE).setCustomOperationTransformer(new SimpleDescribeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
List<OperationTransformer> getOpTransformerChain = new LinkedList<>();
getOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
getOpTransformerChain.add(new SimpleOperationTransformer(new LegacyPropertyMapGetOperationTransformer()));
ChainedOperationTransformer getOpChainedTransformer = new ChainedOperationTransformer(getOpTransformerChain, false);
builder.addRawOperationTransformationOverride(MapOperations.MAP_GET_DEFINITION.getName(), getOpChainedTransformer);
List<OperationTransformer> writeOpTransformerChain = new LinkedList<>();
writeOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
writeOpTransformerChain.add(new LegacyPropertyWriteOperationTransformer());
ChainedOperationTransformer writeOpChainedTransformer = new ChainedOperationTransformer(writeOpTransformerChain, false);
for (String opName : Operations.getAllWriteAttributeOperationNames()) {
builder.addOperationTransformationOverride(opName).inheritResourceAttributeDefinitions().setCustomOperationTransformer(writeOpChainedTransformer);
}
// Reject thread pool configuration, discard if undefined, support EAP 6.x slaves using deprecated attributes
builder.addChildResource(ThreadPoolResourceDefinition.WILDCARD_PATH, RequiredChildResourceDiscardPolicy.REJECT_AND_WARN);
} else {
EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(p -> p.buildTransformation(version, parent));
}
}
use of org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer in project wildfly by wildfly.
the class ProtocolResourceDefinition method addTransformations.
static void addTransformations(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
AbstractProtocolResourceDefinition.addTransformations(version, builder);
if (JGroupsModel.VERSION_4_1_0.requiresTransformation(version)) {
// See WFLY-6782, add-index parameter was missing from add operation definition
builder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, ModelDescriptionConstants.ADD_INDEX);
}
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
// Translate /subsystem=jgroups/stack=*/protocol=*:add() -> /subsystem=jgroups/stack=*:add-protocol()
OperationTransformer addTransformer = new OperationTransformer() {
@Override
public ModelNode transformOperation(ModelNode operation) {
PathAddress address = Operations.getPathAddress(operation);
PathAddress stackAddress = address.subAddress(0, address.size() - 1);
ModelNode addProtocolOp = operation.clone();
addProtocolOp.get(ModelDescriptionConstants.OP_ADDR).set(stackAddress.toModelNode());
addProtocolOp.get(ModelDescriptionConstants.OP).set("add-protocol");
addProtocolOp = new LegacyPropertyAddOperationTransformer().transformOperation(addProtocolOp);
return addProtocolOp;
}
};
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(addTransformer)).inheritResourceAttributeDefinitions();
// Translate /subsystem=jgroups/stack=*/protocol=*:remove() -> /subsystem=jgroups/stack=*:remove-protocol()
OperationTransformer removeTransformer = new OperationTransformer() {
@SuppressWarnings("deprecation")
@Override
public ModelNode transformOperation(ModelNode operation) {
PathAddress address = Operations.getPathAddress(operation);
String protocol = address.getLastElement().getValue();
PathAddress stackAddress = address.subAddress(0, address.size() - 1);
ModelNode legacyOperation = Util.createOperation("remove-protocol", stackAddress);
legacyOperation.get(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).set(protocol);
return legacyOperation;
}
};
builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleOperationTransformer(removeTransformer));
builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
}
}
Aggregations