// Transform the model recursively
final ModelNode recursive = Resource.Tools.readModel(resource);
final ModelNode result = transformModel(context, recursive);
// Create the target registration based on the old resource definition
final TransformationTarget target = context.getTarget();
final ResourceDefinition definition = loader.load(target);
final ManagementResourceRegistration targetDefinition = ManagementResourceRegistration.Factory.create(definition);
final Resource transformed = TransformationUtils.modelToResource(address, targetDefinition, result, false);
// Add the model recursively
context.addTransformedRecursiveResource(PathAddress.EMPTY_ADDRESS, transformed);
}