use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class ReplicatedCacheResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
SharedStateCacheResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder 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);
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class StringTableResourceDefinition method buildTransformation.
@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
OperationTransformer addTransformer = new OperationTransformer() {
@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);
}
};
builder.addRawOperationTransformationOverride(ModelDescriptionConstants.ADD, new SimpleOperationTransformer(addTransformer));
OperationTransformer removeTransformer = new OperationTransformer() {
@Override
public ModelNode transformOperation(ModelNode operation) {
PathAddress storeAddress = Operations.getPathAddress(operation).getParent();
return Operations.createUndefineAttributeOperation(storeAddress, StringKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE);
}
};
builder.addRawOperationTransformationOverride(ModelDescriptionConstants.REMOVE, new SimpleOperationTransformer(removeTransformer));
}
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class InfinispanSubsystemResourceDefinition method buildTransformation.
static TransformationDescription buildTransformation(ModelVersion version) {
ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
CacheContainerResourceDefinition.buildTransformation(version, builder);
return builder.build();
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class CmpExtension method registerTransformers.
private void registerTransformers(SubsystemRegistration subsystem) {
ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
builder.addChildResource(CmpSubsystemModel.UUID_KEY_GENERATOR_PATH).getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, AbstractKeyGeneratorResourceDefinition.JNDI_NAME).setDiscard(DiscardAttributeChecker.UNDEFINED, AbstractKeyGeneratorResourceDefinition.JNDI_NAME).end();
builder.addChildResource(CmpSubsystemModel.HILO_KEY_GENERATOR_PATH).getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, AbstractKeyGeneratorResourceDefinition.JNDI_NAME).setDiscard(DiscardAttributeChecker.UNDEFINED, AbstractKeyGeneratorResourceDefinition.JNDI_NAME).end();
TransformationDescription.Tools.register(builder.build(), subsystem, ModelVersion.create(1, 0, 0));
}
Aggregations