context.getLogger().logAttributeWarning(address, ControllerMessages.MESSAGES.attributesAreNotUnderstoodAndMustBeIgnored(), attributes);
}
}
});
TransformersSubRegistration jsfSubsystem = parent.registerSubResource(PathElement.pathElement(SUBSYSTEM, JSF_SUBSYSTEM));
jsfSubsystem.registerOperationTransformer(ADD, new OperationTransformer() {
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
if (operation.hasDefined(SLOT_ATTRIBUTE_NAME)) {
ModelNode slot = operation.get(SLOT_ATTRIBUTE_NAME);
if (!SLOT_DEFAULT_VALUE.equals(slot.asString())) {
return new TransformedOperation(operation,
new RejectionWithFailurePolicy(MESSAGES.invalidJSFSlotValue(slot.asString())),
OperationResultTransformer.ORIGINAL_RESULT);
}
}
Set<String> attributes = new HashSet<String>();
for (Property prop : operation.asPropertyList()) {
attributes.add(prop.getName());
}
attributes.remove(SLOT_ATTRIBUTE_NAME);
if (!attributes.isEmpty()) {
return new TransformedOperation(operation,
new RejectionWithFailurePolicy(MESSAGES.unknownAttributesFromSubsystemVersion(ADD,
JSF_SUBSYSTEM,
context.getTarget().getSubsystemVersion(JSF_SUBSYSTEM),
attributes)),
OperationResultTransformer.ORIGINAL_RESULT);
}
return DISCARD.transformOperation(context, address, operation);
}
});
jsfSubsystem.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, new OperationTransformer() {
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
final String name = operation.require(NAME).asString();
final ModelNode value = operation.get(ModelDescriptionConstants.VALUE);
if (SLOT_ATTRIBUTE_NAME.equals(name)) {
if (value.isDefined() && value.equals(SLOT_DEFAULT_VALUE)) {
return DISCARD.transformOperation(context, address, operation);
} else {
return new TransformedOperation(operation,
new RejectionWithFailurePolicy(MESSAGES.invalidJSFSlotValue(value.asString())),
OperationResultTransformer.ORIGINAL_RESULT);
}
}
// reject the operation for any other attribute
return new TransformedOperation(operation,
new RejectionWithFailurePolicy(MESSAGES.unknownAttributesFromSubsystemVersion(ADD,
JSF_SUBSYSTEM,
context.getTarget().getSubsystemVersion(JSF_SUBSYSTEM),
Arrays.asList(name))),
OperationResultTransformer.ORIGINAL_RESULT);
}
});
jsfSubsystem.registerOperationTransformer(UNDEFINE_ATTRIBUTE_OPERATION, new OperationTransformer() {
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
String attributeName = operation.require(NAME).asString();
if (!SLOT_ATTRIBUTE_NAME.equals(attributeName)) {
return DEFAULT.transformOperation(context, address, operation);