public void stepCompleted() {
   if (nextStep != null) {
     try {
       OperationStepHandler step = nextStep;
       nextStep = null;
       step.execute(this, null);
     } catch (OperationFailedException e) {
       throw new OperationFailedRuntimeException(e);
     }
   }
 }
 private void doExecuteInternal(
     OperationContext context,
     ModelNode operation,
     AttributeAccess attributeAccess,
     String attributeName,
     ModelNode currentValue,
     boolean useEnhancedSyntax,
     String attributeExpression)
     throws OperationFailedException {
   if (useEnhancedSyntax) {
     operation =
         getEnhancedSyntaxResolvedOperation(
             operation, currentValue, attributeName, attributeExpression);
   }
   OperationStepHandler writeHandler = attributeAccess.getWriteHandler();
   ClassLoader oldTccl =
       WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(writeHandler.getClass());
   try {
     writeHandler.execute(context, operation);
   } finally {
     WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
   }
 }
Example #3
0
  @Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String childType = CHILD_TYPE.resolveModelAttribute(context, operation).asString();

    // Build up the op we're going to repeatedly execute
    final ModelNode readOp = new ModelNode();
    readOp.get(OP).set(READ_RESOURCE_OPERATION);
    INCLUDE_RUNTIME.validateAndSet(operation, readOp);
    RECURSIVE.validateAndSet(operation, readOp);
    RECURSIVE_DEPTH.validateAndSet(operation, readOp);
    PROXIES.validateAndSet(operation, readOp);
    INCLUDE_DEFAULTS.validateAndSet(operation, readOp);

    final Map<PathElement, ModelNode> resources = new HashMap<PathElement, ModelNode>();

    final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false);
    final ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
    Map<String, Set<String>> childAddresses =
        GlobalOperationHandlers.getChildAddresses(context, address, registry, resource, childType);
    Set<String> childNames = childAddresses.get(childType);
    if (childNames == null) {
      throw new OperationFailedException(
          new ModelNode().set(ControllerLogger.ROOT_LOGGER.unknownChildType(childType)));
    }

    // Track any excluded items
    FilteredData filteredData = new FilteredData(address);

    // We're going to add a bunch of steps that should immediately follow this one. We are going to
    // add them
    // in reverse order of how they should execute, building up a stack.

    // Last to execute is the handler that assembles the overall response from the pieces created by
    // all the other steps
    final ReadChildrenResourcesAssemblyHandler assemblyHandler =
        new ReadChildrenResourcesAssemblyHandler(resources, filteredData, address, childType);
    context.addStep(assemblyHandler, OperationContext.Stage.MODEL, true);

    for (final String key : childNames) {
      final PathElement childPath = PathElement.pathElement(childType, key);
      final PathAddress childAddress =
          PathAddress.EMPTY_ADDRESS.append(PathElement.pathElement(childType, key));

      final ModelNode readResOp = readOp.clone();
      readResOp.get(OP_ADDR).set(PathAddress.pathAddress(address, childPath).toModelNode());

      // See if there was an override registered for the standard :read-resource handling
      // (unlikely!!!)
      OperationStepHandler overrideHandler =
          context
              .getResourceRegistration()
              .getOperationHandler(childAddress, READ_RESOURCE_OPERATION);
      if (overrideHandler == null) {
        throw new OperationFailedException(
            new ModelNode().set(ControllerLogger.ROOT_LOGGER.noOperationHandler()));
      } else if (overrideHandler.getClass() == ReadResourceHandler.class) {
        // not an override
        overrideHandler = null;
      }
      OperationStepHandler rrHandler =
          new ReadResourceHandler(filteredData, overrideHandler, false);
      final ModelNode rrRsp = new ModelNode();
      resources.put(childPath, rrRsp);
      context.addStep(rrRsp, readResOp, rrHandler, OperationContext.Stage.MODEL, true);
    }

    context.stepCompleted();
  }
 public void executeNextStep() throws OperationFailedException {
   nextStep.execute(this, new ModelNode());
 }