@Override protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); AddressSettingsValidator.validateModel(context, operation, model); }
/** * Hook to allow subclasses to do any final {@link OperationContext.Stage#MODEL} processing following the * application of the new attribute value. This default implementation calls * {@link #validateUpdatedModel(OperationContext, Resource)}. * <p> * <strong>NOTE:</strong> Implementations must not call * {@link OperationContext#completeStep(OperationContext.ResultHandler)} or any of its variants. The method that * calls this one handles step completion. * </p> * * * @param context the operation context * @param operation the operation * @param attributeName the name of the attribute being modified * @param newValue the new value for the attribute * @param oldValue the previous value for the attribute * @param model the updated model resource * @throws OperationFailedException */ protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { validateUpdatedModel(context, model); }
validateUnresolvedValue(attributeName, newValue); final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final ModelNode submodel = resource.getModel(); final ModelNode currentValue = submodel.get(attributeName).clone(); final AttributeDefinition attributeDefinition = getAttributeDefinition(attributeName); if (attributeDefinition != null) { final ModelNode syntheticOp = new ModelNode(); finishModelStage(context, operation, attributeName, newValue, currentValue, resource); if (requiresRuntime(context)) { final ModelNode updatedValue = newValue; context.addStep(new OperationStepHandler() {
final ModelNode currentValue = submodel.get(attributeName).clone(); final AttributeDefinition attributeDefinition = getAttributeDefinition(attributeName); final ModelNode defaultValue; if (attributeDefinition != null) { attributeDefinition.validateAndSet(syntheticOp, submodel); newValue = submodel.get(attributeName); recordCapabilitiesAndRequirements(context, attributeDefinition, newValue, currentValue); } else { defaultValue = null; finishModelStage(context, operation, attributeName, newValue, currentValue, resource); if (requiresRuntime(context)) { final ModelNode updatedValue = newValue; context.addStep(operation, new OperationStepHandler() {
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode resolvedValue = attributeDefinition != null ? attributeDefinition.resolveModelAttribute(context, submodel) : updatedValue.resolve(); validateResolvedValue(attributeName, updatedValue); final HandbackHolder<T> handback = new HandbackHolder<T>(); final boolean reloadRequired = applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, handback); if (reloadRequired) { context.reloadRequired(); } context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { ModelNode valueToRestore = currentValue.resolve(); try { revertUpdateToRuntime(context, operation, attributeName, valueToRestore, resolvedValue, handback.handback); } catch (Exception e) { MGMT_OP_LOGGER.errorRevertingOperation(e, getClass().getSimpleName(), operation.require(ModelDescriptionConstants.OP).asString(), PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR))); } if (reloadRequired) { context.revertReloadRequired(); } } }); } }, OperationContext.Stage.RUNTIME);
@Override protected boolean requiresRuntime(OperationContext context) { if (context.getProcessType().isServer()) { return super.requiresRuntime(context); } //Check if we are a host's socket binding and install the service if we are PathAddress pathAddress = context.getCurrentAddress(); return pathAddress.size() > 0 && pathAddress.getElement(0).getKey().equals(HOST); }
final ModelNode resolvedValue = attributeDefinition != null ? attributeDefinition.resolveModelAttribute(context, submodel) : context.resolveExpressions(updatedValue); final HandbackHolder<T> handback = new HandbackHolder<T>(); final boolean reloadRequired = applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, handback); if (reloadRequired) { if (attributeDefinition != null && attributeDefinition.getImmutableFlags().contains(AttributeAccess.Flag.RESTART_JVM)){
validateUnresolvedValue(attributeName, newValue); final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final ModelNode submodel = resource.getModel(); final ModelNode currentValue = submodel.get(attributeName).clone(); final AttributeDefinition attributeDefinition = getAttributeDefinition(attributeName); final ModelNode defaultValue; if (attributeDefinition != null) { finishModelStage(context, operation, attributeName, newValue, currentValue, resource); if (requiresRuntime(context)) { final ModelNode updatedValue = newValue; context.addStep(new OperationStepHandler() {
final ModelNode currentValue = submodel.get(attributeName).clone(); final AttributeDefinition attributeDefinition = getAttributeDefinition(attributeName); final ModelNode defaultValue; if (attributeDefinition != null) { attributeDefinition.validateAndSet(syntheticOp, submodel); newValue = submodel.get(attributeName); recordCapabilitiesAndRequirements(context, attributeDefinition, newValue, currentValue); } else { defaultValue = null; finishModelStage(context, operation, attributeName, newValue, currentValue, resource); if (requiresRuntime(context)) { final ModelNode updatedValue = newValue; context.addStep(operation, new OperationStepHandler() {
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode resolvedValue = attributeDefinition != null ? attributeDefinition.resolveModelAttribute(context, submodel) : updatedValue.resolve(); validateResolvedValue(attributeName, updatedValue); final HandbackHolder<T> handback = new HandbackHolder<T>(); final boolean reloadRequired = applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, handback); if (reloadRequired) { if (attributeDefinition != null && attributeDefinition.getFlags().contains(AttributeAccess.Flag.RESTART_JVM)){
@Override protected boolean requiresRuntime(OperationContext context) { if (context.getProcessType().isServer()) { return super.requiresRuntime(context); } //Check if we are a host's socket binding and install the service if we are PathAddress pathAddress = context.getCurrentAddress(); return pathAddress.size() > 0 && pathAddress.getElement(0).getKey().equals(HOST); }
final ModelNode resolvedValue = attributeDefinition != null ? attributeDefinition.resolveModelAttribute(context, submodel) : context.resolveExpressions(updatedValue); final HandbackHolder<T> handback = new HandbackHolder<T>(); final boolean reloadRequired = applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, handback); if (reloadRequired) { if (attributeDefinition != null && attributeDefinition.getImmutableFlags().contains(AttributeAccess.Flag.RESTART_JVM)){
/** * Hook to allow subclasses to do any final {@link OperationContext.Stage#MODEL} processing following the * application of the new attribute value. This default implementation calls * {@link #validateUpdatedModel(OperationContext, Resource)}. * <p> * <strong>NOTE:</strong> Implementations must not call * {@link OperationContext#completeStep(OperationContext.ResultHandler)} or any of its variants. The method that * calls this one handles step completion. * </p> * * * @param context the operation context * @param operation the operation * @param attributeName the name of the attribute being modified * @param newValue the new value for the attribute * @param oldValue the previous value for the attribute * @param model the updated model resource * @throws OperationFailedException */ protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { validateUpdatedModel(context, model); }
@Override protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); AddressSettingsValidator.validateModel(context, operation, model); }
/** * Hook to allow subclasses to do any final {@link OperationContext.Stage#MODEL} processing following the * application of the new attribute value. This default implementation calls * {@link #validateUpdatedModel(OperationContext, Resource)}. * <p> * <strong>NOTE:</strong> Implementations must not call * {@link OperationContext#completeStep(OperationContext.ResultHandler)} or any of its variants. The method that * calls this one handles step completion. * </p> * * * @param context the operation context * @param operation the operation * @param attributeName the name of the attribute being modified * @param newValue the new value for the attribute * @param oldValue the previous value for the attribute * @param model the updated model resource * @throws OperationFailedException */ protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { validateUpdatedModel(context, model); }
/** * Hook to allow subclasses to do any final {@link OperationContext.Stage#MODEL} processing following the * application of the new attribute value. This default implementation calls * {@link #validateUpdatedModel(OperationContext, Resource)}. * <p> * <strong>NOTE:</strong> Implementations must not call * {@link OperationContext#completeStep(OperationContext.ResultHandler)} or any of its variants. The method that * calls this one handles step completion. * </p> * * * @param context the operation context * @param operation the operation * @param attributeName the name of the attribute being modified * @param newValue the new value for the attribute * @param oldValue the previous value for the attribute * @param model the updated model resource * @throws OperationFailedException */ protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { validateUpdatedModel(context, model); }
@Override protected void validateUpdatedModel(final OperationContext context, final Resource model) throws OperationFailedException { super.validateUpdatedModel(context, model); final ModelNode submodel = model.getModel(); if (submodel.hasDefined(CommonAttributes.FILTER.getName())) { final String filterSpec = Filters.filterToFilterSpec(CommonAttributes.FILTER.resolveModelAttribute(context, submodel)); submodel.remove(CommonAttributes.FILTER.getName()); submodel.get(CommonAttributes.FILTER_SPEC.getName()).set(filterSpec); } }