Skip to content

Instantly share code, notes, and snippets.

@ctomc
Last active December 11, 2015 23:39
Show Gist options
  • Save ctomc/4678429 to your computer and use it in GitHub Desktop.
Save ctomc/4678429 to your computer and use it in GitHub Desktop.
static void registerTransformers(final TransformersSubRegistration registration, final TransformersSubRegistration loggingProfileReg,
final PathElement handlerPath, final AttributeDefinition[] additionalAttributes, final String... additionalOperations) {
final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(handlerPath)
.addRawOperationTransformationOverride(ADD, LoggingOperationTransformer.INSTANCE)
.addRawOperationTransformationOverride(WRITE_ATTRIBUTE_OPERATION, LoggingOperationTransformer.INSTANCE)
.addRawOperationTransformationOverride(UPDATE_OPERATION_NAME, LoggingOperationTransformer.INSTANCE)
.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, DEFAULT_ATTRIBUTES)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, LEGACY_ATTRIBUTES)
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, additionalAttributes).end()
.setCustomResourceTransformer(new LoggingResourceTransformer(NAME, FILTER_SPEC, ENABLED));
for (String operationName : additionalOperations) {
builder.addOperationTransformationOverride(operationName);
.setCustomOperationTransformer(LoggingOperationTransformer.INSTANCE)
.inheritResourceAttributeDefinitions().end();
}
TransformationDescription.Tools.register(builder.build(), registration);
// Ignore logging profiles
loggingProfileReg.registerSubResource(handlerPath, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment