public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { ParameterValidator parameterValidator = validators.get(parameterName); if (parameterValidator != null) parameterValidator.validateResolvedParameter(parameterName, value); } }
public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { ParameterValidator parameterValidator = validators.get(parameterName); if (parameterValidator != null) parameterValidator.validateResolvedParameter(parameterName, value); } }
/** * If a resolved value validator was passed to the constructor, uses it to validate the value. * Subclasses can alter this behavior. * * @param attributeName the name of the attribute being updated * @param resolvedValue the resolved value * @deprecated provide an {@link AttributeDefinition} to the constructor; it will validate */ @Deprecated protected void validateResolvedValue(final String attributeName, final ModelNode resolvedValue) throws OperationFailedException { if (resolvedValueValidator != null) { resolvedValueValidator.validateResolvedParameter(VALUE, resolvedValue); } }
public void validateResolved(ModelNode operation) throws OperationFailedException { for (Map.Entry<String, ParameterValidator> entry : validators.entrySet()) { String paramName = entry.getKey(); ModelNode paramVal = operation.has(paramName) ? operation.get(paramName) : new ModelNode(); entry.getValue().validateResolvedParameter(paramName, paramVal); } }
public void validateResolved(ModelNode operation) throws OperationFailedException { for (Map.Entry<String, ParameterValidator> entry : validators.entrySet()) { String paramName = entry.getKey(); ModelNode paramVal = operation.has(paramName) ? operation.get(paramName) : new ModelNode(); entry.getValue().validateResolvedParameter(paramName, paramVal); } }
@Override public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { switch (value.getType()) { case EXPRESSION: if (!allowExpression) { throw MESSAGES.expressionNotAllowed(parameterName); } break; case UNDEFINED: if (allowNull != null) { if (!allowNull) { throw MESSAGES.nullNotAllowed(parameterName); } break; } // else fall through and let the delegate validate default: delegate.validateResolvedParameter(parameterName, value); } }
@Override public void validateResolvedParameter(String parameterName, ModelNode value) throws OperationFailedException { switch (value.getType()) { case EXPRESSION: if (!allowExpression) { throw MESSAGES.expressionNotAllowed(parameterName); } break; case UNDEFINED: if (allowNull != null) { if (!allowNull) { throw MESSAGES.nullNotAllowed(parameterName); } break; } // else fall through and let the delegate validate default: delegate.validateResolvedParameter(parameterName, value); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ManagementLookup stats; boolean oldSetting = false; { final ModelNode value = operation.get(ModelDescriptionConstants.VALUE).resolve(); validator.validateResolvedParameter(ModelDescriptionConstants.VALUE, value); final boolean setting = value.asBoolean(); final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final String puName = address.getLastElement().getValue(); stats = ManagementLookup.create(persistenceUnitRegistry, puName); if (stats != null) { oldSetting = stats.getStatistics().isStatisticsEnabled(); stats.getStatistics().setStatisticsEnabled(setting); } } final boolean rollBackValue = oldSetting; context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { if (stats != null) { stats.getStatistics().setStatisticsEnabled(rollBackValue); } } }); } }, OperationContext.Stage.RUNTIME);