@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());
    }
  }
  private List<QueueControl> getQueues(final DurabilityType durability) {
    try {
      List<QueueControl> matchingQueues = new ArrayList<>();
      String[] queues = addressControl.getQueueNames();
      for (String queue : queues) {
        QueueControl coreQueueControl =
            (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queue);

        // Ignore the "special" subscription
        if (coreQueueControl != null
            && !coreQueueControl.getName().equals(addressControl.getAddress())) {
          if (durability == DurabilityType.ALL
              || durability == DurabilityType.DURABLE && coreQueueControl.isDurable()
              || durability == DurabilityType.NON_DURABLE && !coreQueueControl.isDurable()) {
            matchingQueues.add(coreQueueControl);
          }
        }
      }
      return matchingQueues;
    } catch (Exception e) {
      return Collections.emptyList();
    }
  }
 @Override
 public void dropAllSubscriptions() throws Exception {
   ActiveMQServerControl serverControl =
       (ActiveMQServerControl) managementService.getResource(ResourceNames.CORE_SERVER);
   String[] queues = addressControl.getQueueNames();
   for (String queue : queues) {
     // Drop all subscription shouldn't delete the dummy queue used to identify if the topic exists
     // on the core queues.
     // we will just ignore this queue
     if (!queue.equals(managedTopic.getAddress())) {
       serverControl.destroyQueue(queue);
     }
   }
 }
  @Override
  public int removeMessages(final String filterStr) throws Exception {
    String filter = JMSTopicControlImpl.createFilterFromJMSSelector(filterStr);
    int count = 0;
    String[] queues = addressControl.getQueueNames();
    for (String queue : queues) {
      QueueControl coreQueueControl =
          (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queue);
      if (coreQueueControl != null) {
        count += coreQueueControl.removeMessages(filter);
      }
    }

    return count;
  }