@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress currentAddress = context.getCurrentAddress(); PathAddress targetAddress = this.translation.getPathAddressTransformation().apply(currentAddress); Attribute targetAttribute = this.translation.getTargetAttribute(); ModelNode targetOperation = Operations.createReadAttributeOperation(targetAddress, targetAttribute); ImmutableManagementResourceRegistration targetRegistration = this.translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler readAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getReadHandler(); OperationStepHandler readTranslatedAttributeHandler = new ReadTranslatedAttributeStepHandler(readAttributeHandler, targetAttribute, this.translation.getReadTranslator()); // If targetOperation applies to the current resource, we can execute in the current step if (targetAddress == currentAddress) { readTranslatedAttributeHandler.execute(context, targetOperation); } else { context.addStep(targetOperation, readTranslatedAttributeHandler, context.getCurrentStage(), true); } }
private void attemptReadMissingAttributeValueFromHandler(final OperationContext context, final PathAddress address, final AttributeAccess attributeAccess, final String attributeName, final ErrorHandler errorHandler) throws OperationFailedException { OperationStepHandler handler = attributeAccess.getReadHandler(); if (handler == null) { errorHandler.throwError(); } else { final ModelNode readAttr = Util.getReadAttributeOperation(address, attributeName); //Do a read-attribute as an immediate step final ModelNode resultHolder = new ModelNode(); context.addStep(resultHolder, readAttr, handler, Stage.MODEL, true); //Then check the read-attribute result in a later step and throw the error if it is not set context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (!resultHolder.isDefined() && !resultHolder.hasDefined(RESULT)) { errorHandler.throwError(); } } }, Stage.MODEL); } }
private void attemptReadMissingAttributeValueFromHandler(final OperationContext context, final PathAddress address, final AttributeAccess attributeAccess, final String attributeName, final ErrorHandler errorHandler) throws OperationFailedException { OperationStepHandler handler = attributeAccess.getReadHandler(); if (handler == null) { errorHandler.throwError(); } else { final ModelNode readAttr = Util.getReadAttributeOperation(address, attributeName); //Do a read-attribute as an immediate step final ModelNode resultHolder = new ModelNode(); context.addStep(resultHolder, readAttr, handler, Stage.MODEL, true); //Then check the read-attribute result in a later step and throw the error if it is not set context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (!resultHolder.isDefined() && !resultHolder.hasDefined(RESULT)) { errorHandler.throwError(); } } }, Stage.MODEL); } }
final OperationStepHandler handler = access.getReadHandler(); if (handler != null) {
} else if (attributeAccess.getReadHandler() == null) { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false); final ModelNode subModel = resource.getModel(); OperationStepHandler handler = attributeAccess.getReadHandler(); ClassLoader oldTccl = SecurityActions.setThreadContextClassLoader(handler.getClass()); try {
} else if (attributeAccess.getReadHandler() == null) { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false); final ModelNode subModel = resource.getModel(); OperationStepHandler handler = attributeAccess.getReadHandler(); ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try {
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress currentAddress = context.getCurrentAddress(); PathAddress targetAddress = this.translation.getPathAddressTransformation().apply(currentAddress); Attribute targetAttribute = this.translation.getTargetAttribute(); ModelNode targetOperation = Operations.createReadAttributeOperation(targetAddress, targetAttribute); ImmutableManagementResourceRegistration targetRegistration = this.translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler readAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getReadHandler(); OperationStepHandler readTranslatedAttributeHandler = new ReadTranslatedAttributeStepHandler(readAttributeHandler, targetAttribute, this.translation.getReadTranslator()); // If targetOperation applies to the current resource, we can execute in the current step if (targetAddress == currentAddress) { readTranslatedAttributeHandler.execute(context, targetOperation); } else { context.addStep(targetOperation, readTranslatedAttributeHandler, context.getCurrentStage(), true); } }
private ModelNode readAttributeValue(OperationContext context, AttributeDefinition attribute) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if(this.parentAttribute != null && !this.parentAttribute.equals(attribute)) { model = readAttributeValue(context, this.parentAttribute); } final String attributeName = attribute.getName(); if(model.hasDefined(attributeName)) { return attribute.resolveModelAttribute(context, model); } AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if(access == null) { return new ModelNode(); } OperationStepHandler handler = access.getReadHandler(); ModelNode path; if(handler != null) { ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try { handler.execute(context, Util.getReadAttributeOperation(context.getCurrentAddress(), attributeName)); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } path = context.getResult().clone(); context.getResult().setEmptyObject(); } else { path = new ModelNode(); } return path; }
private ModelNode readAttributeValue(OperationContext context, AttributeDefinition attribute) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if(this.parentAttribute != null && !this.parentAttribute.equals(attribute)) { model = readAttributeValue(context, this.parentAttribute); } final String attributeName = attribute.getName(); if(model.hasDefined(attributeName)) { return attribute.resolveModelAttribute(context, model); } AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if(access == null) { return new ModelNode(); } OperationStepHandler handler = access.getReadHandler(); ModelNode path; if(handler != null) { ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try { handler.execute(context, Util.getReadAttributeOperation(context.getCurrentAddress(), attributeName)); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } path = context.getResult().clone(); context.getResult().setEmptyObject(); } else { path = new ModelNode(); } return path; }
if (attributeAccess.getReadHandler() == null) { resolveAttribute(context, attributeAccess.getAttributeDefinition(), attributeExpression, defaults, useEnhancedSyntax); } else { OperationStepHandler handler = attributeAccess.getReadHandler(); ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try {
if (attributeAccess.getReadHandler() == null) { resolveAttribute(context, attributeAccess.getAttributeDefinition(), attributeExpression, defaults, useEnhancedSyntax); } else { OperationStepHandler handler = attributeAccess.getReadHandler(); ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(handler.getClass()); try {