use of org.jboss.as.controller.transform.ResourceTransformationContext in project wildfly by wildfly.
the class BinaryKeyedJDBCStoreResourceDefinition 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.setCustomResourceTransformer(new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
final ModelNode model = resource.getModel();
final ModelNode binaryTableModel = Resource.Tools.readModel(resource.removeChild(BinaryTableResourceDefinition.PATH));
if (binaryTableModel != null && binaryTableModel.isDefined()) {
model.get(DeprecatedAttribute.TABLE.getName()).set(binaryTableModel);
}
final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName());
final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext);
context.processChildren(resource);
}
});
}
BinaryTableResourceDefinition.buildTransformation(version, builder);
JDBCStoreResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.controller.transform.ResourceTransformationContext in project wildfly by wildfly.
the class MixedKeyedJDBCStoreResourceDefinition 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);
BinaryTableResourceDefinition.buildTransformation(version, builder);
StringTableResourceDefinition.buildTransformation(version, builder);
JDBCStoreResourceDefinition.buildTransformation(version, builder);
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
builder.setCustomResourceTransformer(new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
final ModelNode model = resource.getModel();
final ModelNode binaryTableModel = Resource.Tools.readModel(resource.removeChild(BinaryTableResourceDefinition.PATH));
if (binaryTableModel != null && binaryTableModel.isDefined()) {
model.get(DeprecatedAttribute.BINARY_TABLE.getName()).set(binaryTableModel);
}
final ModelNode stringTableModel = Resource.Tools.readModel(resource.removeChild(StringTableResourceDefinition.PATH));
if (stringTableModel != null && stringTableModel.isDefined()) {
model.get(DeprecatedAttribute.STRING_TABLE.getName()).set(stringTableModel);
}
final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName());
final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext);
context.processChildren(resource);
}
});
}
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.addRawOperationTransformationOverride(MapOperations.MAP_GET_DEFINITION.getName(), new SimpleOperationTransformer(new LegacyPropertyMapGetOperationTransformer()));
for (String opName : Operations.getAllWriteAttributeOperationNames()) {
builder.addOperationTransformationOverride(opName).inheritResourceAttributeDefinitions().setCustomOperationTransformer(new LegacyPropertyWriteOperationTransformer());
}
}
}
use of org.jboss.as.controller.transform.ResourceTransformationContext in project wildfly by wildfly.
the class StringKeyedJDBCStoreResourceDefinition 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.setCustomResourceTransformer(new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
final ModelNode model = resource.getModel();
final ModelNode stringTableModel = Resource.Tools.readModel(resource.removeChild(StringTableResourceDefinition.PATH));
if (stringTableModel != null && stringTableModel.isDefined()) {
model.get(DeprecatedAttribute.TABLE.getName()).set(stringTableModel);
}
final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName());
final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext);
context.processChildren(resource);
}
});
}
StringTableResourceDefinition.buildTransformation(version, builder);
JDBCStoreResourceDefinition.buildTransformation(version, builder);
}
Aggregations