use of org.jboss.as.controller.transform.ResourceTransformer in project wildfly by wildfly.
the class CacheResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
builder.discardChildResource(NoStoreResourceDefinition.PATH);
} else {
NoStoreResourceDefinition.buildTransformation(version, builder);
}
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
// Set batching=true if transaction mode=BATCH
ResourceTransformer batchingTransformer = new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
PathAddress transactionAddress = address.append(TransactionResourceDefinition.PATH);
try {
ModelNode transaction = context.readResourceFromRoot(transactionAddress).getModel();
if (transaction.hasDefined(TransactionResourceDefinition.Attribute.MODE.getName())) {
ModelNode mode = transaction.get(TransactionResourceDefinition.Attribute.MODE.getName());
if ((mode.getType() == ModelType.STRING) && (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH)) {
resource.getModel().get(DeprecatedAttribute.BATCHING.getName()).set(true);
}
}
} catch (NoSuchElementException e) {
// Ignore, nothing to convert
}
context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource);
}
};
builder.setCustomResourceTransformer(batchingTransformer);
}
if (InfinispanModel.VERSION_1_5_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(RejectAttributeChecker.UNDEFINED, Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(new RejectAttributeChecker.SimpleRejectAttributeChecker(new ModelNode(false)), Attribute.STATISTICS_ENABLED.getDefinition());
}
LockingResourceDefinition.buildTransformation(version, builder);
EvictionResourceDefinition.buildTransformation(version, builder);
ExpirationResourceDefinition.buildTransformation(version, builder);
TransactionResourceDefinition.buildTransformation(version, builder);
FileStoreResourceDefinition.buildTransformation(version, builder);
BinaryKeyedJDBCStoreResourceDefinition.buildTransformation(version, builder);
MixedKeyedJDBCStoreResourceDefinition.buildTransformation(version, builder);
StringKeyedJDBCStoreResourceDefinition.buildTransformation(version, builder);
RemoteStoreResourceDefinition.buildTransformation(version, builder);
CustomStoreResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.controller.transform.ResourceTransformer 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);
}
Aggregations