private void handleReadAttribute(OperationContext context, ModelNode operation) {

    if (ignoreOperationIfServerNotActive(context, operation)) {
      return;
    }

    final AddressControl addressControl = getAddressControl(context, operation);
    if (addressControl == null) {
      PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
      throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }

    final String name = operation.require(ModelDescriptionConstants.NAME).asString();

    try {
      if (ROLES_ATTR_NAME.equals(name)) {
        String json = addressControl.getRolesAsJSON();
        reportRoles(context, json);
      } else if (QUEUE_NAMES.equals(name)) {
        String[] queues = addressControl.getQueueNames();
        reportListOfStrings(context, queues);
      } else if (NUMBER_OF_BYTES_PER_PAGE.equals(name)) {
        long l = addressControl.getNumberOfBytesPerPage();
        context.getResult().set(l);
      } else if (NUMBER_OF_PAGES.equals(name)) {
        int i = addressControl.getNumberOfPages();
        context.getResult().set(i);
      } else if (BINDING_NAMES.equals(name)) {
        String[] bindings = addressControl.getBindingNames();
        reportListOfStrings(context, bindings);
      } else {
        // Bug
        throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(name);
      }
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      context.getFailureDescription().set(e.getLocalizedMessage());
    }

    context.stepCompleted();
  }
  @Override
  public void executeRuntimeStep(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();

    PathAddress pathAddress =
        PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
    String addressName = pathAddress.getElement(pathAddress.size() - 2).getValue();
    String roleName = pathAddress.getLastElement().getValue();

    final ServiceName serviceName =
        MessagingServices.getActiveMQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    AddressControl control =
        AddressControl.class.cast(
            server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName));

    if (control == null) {
      PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
      throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }

    try {
      String rolesAsJSON = control.getRolesAsJSON();
      ModelNode res = ModelNode.fromJSONString(rolesAsJSON);
      ModelNode roles = ManagementUtil.convertSecurityRole(res);
      ModelNode matchedRole = findRole(roleName, roles);
      if (matchedRole == null || !matchedRole.hasDefined(attributeName)) {
        throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
      }
      boolean value = matchedRole.get(attributeName).asBoolean();
      context.getResult().set(value);
    } catch (Exception e) {
      context.getFailureDescription().set(e.getLocalizedMessage());
    }
  }
  @Override
  public void executeRuntimeStep(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    if (ignoreOperationIfServerNotActive(context, operation)) {
      return;
    }

    validator.validate(operation);
    final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();

    PathAddress address =
        PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
    String queueName = address.getLastElement().getValue();

    if (forwardToRuntimeQueue(context, operation, RUNTIME_INSTANCE)) {
      return;
    }

    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    QueueControl control =
        QueueControl.class.cast(
            server.getManagementService().getResource(ResourceNames.CORE_QUEUE + queueName));

    if (control == null) {
      throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }

    if (MESSAGE_COUNT.getName().equals(attributeName)) {
      context.getResult().set(control.getMessageCount());
    } else if (SCHEDULED_COUNT.getName().equals(attributeName)) {
      context.getResult().set(control.getScheduledCount());
    } else if (CONSUMER_COUNT.getName().equals(attributeName)) {
      context.getResult().set(control.getConsumerCount());
    } else if (DELIVERING_COUNT.getName().equals(attributeName)) {
      context.getResult().set(control.getDeliveringCount());
    } else if (MESSAGES_ADDED.getName().equals(attributeName)) {
      context.getResult().set(control.getMessagesAdded());
    } else if (ID.getName().equals(attributeName)) {
      context.getResult().set(control.getID());
    } else if (PAUSED.getName().equals(attributeName)) {
      try {
        context.getResult().set(control.isPaused());
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    } else if (TEMPORARY.getName().equals(attributeName)) {
      context.getResult().set(control.isTemporary());
    } else if (EXPIRY_ADDRESS.getName().equals(attributeName)) {
      if (control.getExpiryAddress() != null) {
        context.getResult().set(control.getExpiryAddress());
      }
    } else if (DEAD_LETTER_ADDRESS.getName().equals(attributeName)) {
      if (control.getDeadLetterAddress() != null) {
        context.getResult().set(control.getDeadLetterAddress());
      }
    } else if (readStorageAttributes && getStorageAttributeNames().contains(attributeName)) {
      if (ADDRESS.getName().equals(attributeName)) {
        context.getResult().set(control.getAddress());
      } else if (DURABLE.getName().equals(attributeName)) {
        context.getResult().set(control.isDurable());
      } else if (FILTER.getName().equals(attributeName)) {
        ModelNode result = context.getResult();
        String filter = control.getFilter();
        if (filter != null) {
          result.set(filter);
        }
      }
    } else {
      throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
    }
  }