@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { nameValidator.validate(operation); final String attributeName = operation.require(NAME).asString(); final ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : new ModelNode(); final ModelNode submodel = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel(); final AttributeDefinition attributeDefinition = ATTRIBUTES.get(attributeName); if (attributeDefinition != null) { final ModelNode syntheticOp = new ModelNode(); syntheticOp.get(attributeName).set(newValue); attributeDefinition.validateAndSet(syntheticOp, submodel); } else { throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName))); } if (updateRuntime) { // Require a reload context.reloadRequired(); } // Verify the model in a later step context.addStep(VERIFY_HANDLER, OperationContext.Stage.MODEL); OperationContext.RollbackHandler rollbackHandler = updateRuntime ? OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER : OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER; context.completeStep(rollbackHandler); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { nameValidator.validate(operation); final String attributeName = operation.require(NAME).asString(); final ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : new ModelNode(); final ModelNode submodel = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel(); final AttributeDefinition attributeDefinition = ATTRIBUTES.get(attributeName); if (attributeDefinition != null) { final ModelNode syntheticOp = new ModelNode(); syntheticOp.get(attributeName).set(newValue); attributeDefinition.validateAndSet(syntheticOp, submodel); } else { throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName))); } if (updateRuntime) { // Require a reload context.reloadRequired(); } // Verify the model in a later step context.addStep(VERIFY_HANDLER, OperationContext.Stage.MODEL); OperationContext.RollbackHandler rollbackHandler = updateRuntime ? OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER : OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER; context.completeStep(rollbackHandler); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { nameValidator.validate(operation); final String attributeName = operation.require(GlobalOperationHandlers.NAME.getName()).asString(); final AttributeAccess attributeAccess = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if (attributeAccess == null) { throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName))); } else if (attributeAccess.getAccessType() != AttributeAccess.AccessType.READ_WRITE) { throw new OperationFailedException(new ModelNode().set(MESSAGES.attributeNotWritable(attributeName))); } else { OperationStepHandler handler = attributeAccess.getWriteHandler(); ClassLoader oldTccl = SecurityActions.setThreadContextClassLoader(handler.getClass()); try { handler.execute(context, operation); } finally { SecurityActions.setThreadContextClassLoader(oldTccl); } } } }
throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName)));
throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName)));
throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(attributeName))); } else if (attributeAccess.getAccessType() != AttributeAccess.AccessType.READ_WRITE) { throw new OperationFailedException(new ModelNode().set(MESSAGES.attributeNotWritable(attributeName)));