Skip to content

Instantly share code, notes, and snippets.

@pferraro
Created June 30, 2014 20:37
Show Gist options
  • Save pferraro/8cb65102365ed7452cb0 to your computer and use it in GitHub Desktop.
Save pferraro/8cb65102365ed7452cb0 to your computer and use it in GitHub Desktop.
CacheResourceDefinition.buildTransformation(...)
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
AttributeConverter batchingConverter = new AttributeConverter() {
@Override
public void convertOperationParameter(PathAddress address, String name, ModelNode value, ModelNode operation, TransformationContext context) {
}
@Override
public void convertResourceAttribute(PathAddress address, String name, ModelNode value, TransformationContext context) {
ModelNode cache = context.readResourceFromRoot(address).getModel();
if (cache.hasDefined(TransactionResourceDefinition.PATH.getKey())) {
ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
if (transaction.isDefined() && transaction.hasDefined(TransactionResourceDefinition.MODE.getName())) {
TransactionMode mode = TransactionMode.valueOf(transaction.get(TransactionResourceDefinition.MODE.getName()).asString());
if (mode == TransactionMode.BATCH) {
value.set(true);
}
}
}
}
};
builder.getAttributeBuilder()
.setValueConverter(batchingConverter, BATCHING);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment