@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { if (MAX_POOL_SIZE.equals(parameterName)) { intValidator.validateParameter(parameterName, value); } else if (MIN_POOL_SIZE.equals(parameterName)) { intValidator.validateParameter(parameterName, value); } else if (BLOCKING_TIMEOUT_WAIT_MILLIS.equals(parameterName)) { longValidator.validateParameter(parameterName, value); } else if (IDLETIMEOUTMINUTES.equals(parameterName)) { longValidator.validateParameter(parameterName, value); } else if (BACKGROUNDVALIDATION.equals(parameterName)) { boolValidator.validateParameter(parameterName, value); } else if (BACKGROUNDVALIDATIONMINUTES.equals(parameterName)) { intValidator.validateParameter(parameterName, value); } else if (POOL_PREFILL.equals(parameterName)) { boolValidator.validateParameter(parameterName, value); } else if (POOL_USE_STRICT_MIN.equals(parameterName)) { boolValidator.validateParameter(parameterName, value); } else if (USE_FAST_FAIL.equals(parameterName)) { boolValidator.validateParameter(parameterName, value); } else { throw new OperationFailedException( new ModelNode().set("Wrong parameter name for " + parameterName)); } }
@Override protected boolean applyUpdateToRuntime( final OperationContext context, final ModelNode operation, final ResultHandler resultHandler, final String parameterName, final ModelNode newValue, final ModelNode currentValue) throws OperationFailedException { if (context.getRuntimeContext() != null) { context .getRuntimeContext() .setRuntimeTask( new RuntimeTask() { public void execute(RuntimeTaskContext runtimeCtx) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String jndiName = address.getLastElement().getValue(); final ServiceController<?> managementRepoService = runtimeCtx .getServiceRegistry() .getService(ConnectorServices.MANAGEMENT_REPOSISTORY_SERVICE); if (managementRepoService != null) { try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); List<PoolConfiguration> poolConfigs = getMatchingPoolConfigs(jndiName, repository); for (PoolConfiguration pc : poolConfigs) { if (MAX_POOL_SIZE.equals(parameterName)) { pc.setMaxSize(newValue.asInt()); } if (MIN_POOL_SIZE.equals(parameterName)) { pc.setMinSize(newValue.asInt()); } if (BLOCKING_TIMEOUT_WAIT_MILLIS.equals(parameterName)) { pc.setBlockingTimeout(newValue.asLong()); } if (POOL_USE_STRICT_MIN.equals(parameterName)) { pc.setStrictMin(newValue.asBoolean()); } if (USE_FAST_FAIL.equals(parameterName)) { pc.setUseFastFail(newValue.asBoolean()); } } resultHandler.handleResultComplete(); } catch (Exception e) { throw new OperationFailedException( new ModelNode().set("failed to set attribute" + e.getMessage())); } } else { resultHandler.handleResultComplete(); } } }); } else { resultHandler.handleResultComplete(); } return (IDLETIMEOUTMINUTES.equals(parameterName) || BACKGROUNDVALIDATION.equals(parameterName) || BACKGROUNDVALIDATIONMINUTES.equals(parameterName) || POOL_PREFILL.equals(parameterName)); }