private void parseStoreProperty(XMLExtendedStreamReader reader, ModelNode node)
     throws XMLStreamException {
   int attributes = reader.getAttributeCount();
   String property = null;
   for (int i = 0; i < attributes; i++) {
     String value = reader.getAttributeValue(i);
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case NAME:
         {
           property = value;
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   if (property == null) {
     throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
   }
   String value = reader.getElementText();
   node.get(ModelKeys.PROPERTIES).add(property, value);
 }
 private void parseCacheAttribute(
     XMLExtendedStreamReader reader, int index, Attribute attribute, String value, ModelNode cache)
     throws XMLStreamException {
   switch (attribute) {
     case NAME:
       {
         cache.get(ModelKeys.NAME).set(value);
         break;
       }
     case START:
       {
         CommonAttributes.START.parseAndSetParameter(value, cache, reader);
         break;
       }
     case BATCHING:
       {
         CommonAttributes.BATCHING.parseAndSetParameter(value, cache, reader);
         break;
       }
     case INDEXING:
       {
         try {
           Indexing indexing = Indexing.valueOf(value);
           CommonAttributes.INDEXING.parseAndSetParameter(indexing.name(), cache, reader);
         } catch (IllegalArgumentException e) {
           throw ParseUtils.invalidAttributeValue(reader, index);
         }
         break;
       }
     default:
       {
         throw ParseUtils.unexpectedAttribute(reader, index);
       }
   }
 }
  private void parseRehashing(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the rehashing add operation
    ModelNode rehashingAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    rehashingAddress.add(ModelKeys.STATE_TRANSFER, ModelKeys.STATE_TRANSFER_NAME);
    rehashingAddress.protect();
    ModelNode rehashing = Util.getEmptyOperation(ModelDescriptionConstants.ADD, rehashingAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case ENABLED:
          {
            CommonAttributes.ENABLED.parseAndSetParameter(value, rehashing, reader);
            break;
          }
        case TIMEOUT:
          {
            CommonAttributes.TIMEOUT.parseAndSetParameter(value, rehashing, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(rehashing);
  }
  private void parseStoreProperty(
      XMLExtendedStreamReader reader, ModelNode node, final List<ModelNode> operations)
      throws XMLStreamException {

    int attributes = reader.getAttributeCount();
    String propertyName = null;
    for (int i = 0; i < attributes; i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case NAME:
          {
            propertyName = value;
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    if (propertyName == null) {
      throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
    }
    String propertyValue = reader.getElementText();

    PathAddress propertyAddress =
        PathAddress.pathAddress(node.get(OP_ADDR)).append(ModelKeys.PROPERTY, propertyName);
    ModelNode property = Util.createAddOperation(propertyAddress);

    // represent the value as a ModelNode to cater for expressions
    StorePropertyResource.VALUE.parseAndSetParameter(propertyValue, property, reader);

    operations.add(property);
  }
Exemplo n.º 5
0
 private ModelNode parseJPA(XMLExtendedStreamReader reader) throws XMLStreamException {
   String dataSourceName = null;
   int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     final String value = reader.getAttributeValue(i);
     final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case DEFAULT_DATASOURCE_NAME:
         {
           dataSourceName = value;
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   // Require no content
   ParseUtils.requireNoContent(reader);
   if (dataSourceName == null) {
     throw ParseUtils.missingRequired(
         reader, Collections.singleton(Attribute.DEFAULT_DATASOURCE_NAME));
   }
   return createAddOperation(dataSourceName);
 }
 private void parseStateTransfer(XMLExtendedStreamReader reader, ModelNode stateTransfer)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     String value = reader.getAttributeValue(i);
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case ENABLED:
         {
           stateTransfer.get(ModelKeys.ENABLED).set(Boolean.parseBoolean(value));
           break;
         }
       case TIMEOUT:
         {
           stateTransfer.get(ModelKeys.TIMEOUT).set(Long.parseLong(value));
           break;
         }
       case FLUSH_TIMEOUT:
         {
           stateTransfer.get(ModelKeys.FLUSH_TIMEOUT).set(Long.parseLong(value));
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
Exemplo n.º 7
0
    /** {@inheritDoc} */
    @Override
    public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
        throws XMLStreamException {
      ModelNode subsystemAdd = null;

      while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
          case JPA:
            {
              subsystemAdd = parseJPA(reader);
              break;
            }
          default:
            {
              throw ParseUtils.unexpectedElement(reader);
            }
        }
      }
      if (subsystemAdd == null) {
        throw ParseUtils.missingRequiredElement(
            reader, Collections.singleton(Element.JPA.getLocalName()));
      }
      list.add(subsystemAdd);
    }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementReader#readElement(org.jboss.staxmapper.XMLExtendedStreamReader,
   *     java.lang.Object)
   */
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    ModelNode subsystemAddress = new ModelNode();
    subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, InfinispanExtension.SUBSYSTEM_NAME);
    subsystemAddress.protect();

    ModelNode subsystem = Util.getEmptyOperation(ModelDescriptionConstants.ADD, subsystemAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case DEFAULT_CACHE_CONTAINER:
          {
            subsystem.get(ModelKeys.DEFAULT_CACHE_CONTAINER).set(value);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    if (!subsystem.hasDefined(ModelKeys.DEFAULT_CACHE_CONTAINER)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.DEFAULT_CACHE_CONTAINER));
    }

    // command to add the subsystem
    operations.add(subsystem);

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      switch (Namespace.forUri(reader.getNamespaceURI())) {
        case INFINISPAN_1_0:
        case INFINISPAN_1_1:
          {
            Element element = Element.forName(reader.getLocalName());
            switch (element) {
              case CACHE_CONTAINER:
                {
                  parseContainer(reader, subsystemAddress, operations);
                  break;
                }
              default:
                {
                  throw ParseUtils.unexpectedElement(reader);
                }
            }
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
 private void parseEviction(XMLExtendedStreamReader reader, ModelNode eviction)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     String value = reader.getAttributeValue(i);
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case STRATEGY:
         {
           try {
             EvictionStrategy strategy = EvictionStrategy.valueOf(value);
             eviction.get(ModelKeys.STRATEGY).set(strategy.name());
           } catch (IllegalArgumentException e) {
             throw ParseUtils.invalidAttributeValue(reader, i);
           }
           break;
         }
       case MAX_ENTRIES:
         {
           eviction.get(ModelKeys.MAX_ENTRIES).set(Integer.parseInt(value));
           break;
         }
       case INTERVAL:
         {
           ROOT_LOGGER.deprecatedAttribute(
               attribute.getLocalName(), Element.EVICTION.getLocalName(), "ISPN-1268");
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
  private void parseThreadPool(
      ThreadPoolResourceDefinition pool,
      XMLExtendedStreamReader reader,
      PathAddress parentAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    PathAddress address = parentAddress.append(pool.getPathElement());
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case MIN_THREADS:
          readAttribute(reader, i, operation, pool.getMinThreads());
          break;
        case MAX_THREADS:
          readAttribute(reader, i, operation, pool.getMaxThreads());
          break;
        case QUEUE_LENGTH:
          readAttribute(reader, i, operation, pool.getQueueLength());
          break;
        case KEEPALIVE_TIME:
          readAttribute(reader, i, operation, pool.getKeepAliveTime());
          break;
        default:
          throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }

    ParseUtils.requireNoContent(reader);
  }
 private void parseExpiration(XMLExtendedStreamReader reader, ModelNode expiration)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     String value = reader.getAttributeValue(i);
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case MAX_IDLE:
         {
           expiration.get(ModelKeys.MAX_IDLE).set(Long.parseLong(value));
           break;
         }
       case LIFESPAN:
         {
           expiration.get(ModelKeys.LIFESPAN).set(Long.parseLong(value));
           break;
         }
       case INTERVAL:
         {
           expiration.get(ModelKeys.INTERVAL).set(Long.parseLong(value));
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
  private void parseEviction(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    PathAddress evictionAddress =
        PathAddress.pathAddress(cache.get(OP_ADDR))
            .append(ModelKeys.EVICTION, ModelKeys.EVICTION_NAME);
    ModelNode eviction = Util.createAddOperation(evictionAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STRATEGY:
          {
            EvictionResource.EVICTION_STRATEGY.parseAndSetParameter(value, eviction, reader);
            break;
          }
        case MAX_ENTRIES:
          {
            EvictionResource.MAX_ENTRIES.parseAndSetParameter(value, eviction, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(eviction);
  }
Exemplo n.º 13
0
    /** {@inheritDoc} */
    @Override
    public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
        throws XMLStreamException {
      ParseUtils.requireNoAttributes(reader);
      ParseUtils.requireNoContent(reader);

      list.add(createAddOperation());
    }
  private void parseTransport(
      XMLExtendedStreamReader reader, ModelNode containerAddress, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the transport add operation
    ModelNode transport = Util.getEmptyOperation(ModelDescriptionConstants.ADD, null);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STACK:
          {
            transport.get(ModelKeys.STACK).set(value);
            break;
          }
        case EXECUTOR:
          {
            transport.get(ModelKeys.EXECUTOR).set(value);
            break;
          }
        case LOCK_TIMEOUT:
          {
            transport.get(ModelKeys.LOCK_TIMEOUT).set(Long.parseLong(value));
            break;
          }
        case SITE:
          {
            transport.get(ModelKeys.SITE).set(value);
            break;
          }
        case RACK:
          {
            transport.get(ModelKeys.RACK).set(value);
            break;
          }
        case MACHINE:
          {
            transport.get(ModelKeys.MACHINE).set(value);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);

    // setup the transport address
    ModelNode transportAddress = containerAddress.clone();
    transportAddress.add(ModelKeys.SINGLETON, ModelKeys.TRANSPORT);
    transportAddress.protect();
    transport.get(ModelDescriptionConstants.OP_ADDR).set(transportAddress);

    operations.add(transport);
  }
  private void parseJDBCStoreTable(XMLExtendedStreamReader reader, ModelNode table)
      throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case PREFIX:
          {
            table.get(ModelKeys.PREFIX).set(value);
            break;
          }
        case FETCH_SIZE:
          {
            table.get(ModelKeys.FETCH_SIZE).set(Integer.parseInt(value));
            break;
          }
        case BATCH_SIZE:
          {
            table.get(ModelKeys.BATCH_SIZE).set(Integer.parseInt(value));
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case ID_COLUMN:
          {
            this.parseJDBCStoreColumn(reader, table.get(ModelKeys.ID_COLUMN).setEmptyObject());
            break;
          }
        case DATA_COLUMN:
          {
            this.parseJDBCStoreColumn(reader, table.get(ModelKeys.DATA_COLUMN).setEmptyObject());
            break;
          }
        case TIMESTAMP_COLUMN:
          {
            this.parseJDBCStoreColumn(
                reader, table.get(ModelKeys.TIMESTAMP_COLUMN).setEmptyObject());
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
  private void parseChannel(
      XMLExtendedStreamReader reader,
      PathAddress subsystemAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    String name = require(reader, XMLAttribute.NAME);
    PathAddress address = subsystemAddress.append(ChannelResourceDefinition.pathElement(name));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case NAME:
          {
            // Already parsed
            break;
          }
        case STACK:
          {
            readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.STACK);
            break;
          }
        case MODULE:
          {
            readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.MODULE);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      XMLElement element = XMLElement.forName(reader.getLocalName());
      switch (element) {
        case FORK:
          {
            this.parseFork(reader, address, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
 @Override
 public void parse(
     final XMLExtendedStreamReader reader, PathAddress parentAddress, List<ModelNode> list)
     throws XMLStreamException {
   if (getXmlWrapperElement() != null) {
     if (reader.getLocalName().equals(getXmlWrapperElement())) {
       if (reader.hasNext()) {
         if (reader.nextTag() == END_ELEMENT) {
           return;
         }
       }
     } else {
       throw ParseUtils.unexpectedElement(reader);
     }
   }
   boolean wildcard = getPathElement().isWildcard();
   String name = null;
   ModelNode op = Util.createAddOperation();
   Map<String, AttributeDefinition> attributes = getAttributeMap();
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     String attributeName = reader.getAttributeLocalName(i);
     String value = reader.getAttributeValue(i);
     if (wildcard && NAME.equals(attributeName)) {
       name = value;
     } else if (attributes.containsKey(attributeName)) {
       AttributeDefinition def = attributes.get(attributeName);
       if (def instanceof SimpleAttributeDefinition) {
         ((SimpleAttributeDefinition) def).parseAndSetParameter(value, op, reader);
       } else if (def instanceof StringListAttributeDefinition) {
         ((StringListAttributeDefinition) def).parseAndSetParameter(value, op, reader);
       } else {
         throw new IllegalArgumentException("we should know how to handle " + def);
       }
     } else {
       throw ParseUtils.unexpectedAttribute(reader, i);
     }
   }
   if (wildcard && name == null) {
     throw MESSAGES.missingRequiredAttributes(new StringBuilder(NAME), reader.getLocation());
   }
   PathElement path =
       wildcard ? PathElement.pathElement(getPathElement().getKey(), name) : getPathElement();
   PathAddress address = parentAddress.append(path);
   op.get(ADDRESS).set(address.toModelNode());
   list.add(op);
   parseChildren(reader, address, list);
   if (getXmlWrapperElement() != null) {
     ParseUtils.requireNoContent(reader);
   }
 }
  private void parseIndexing(XMLExtendedStreamReader reader, ModelNode node)
      throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      if (attribute == Attribute.INDEX) {
        CacheResource.INDEXING.parseAndSetParameter(value, node, reader);
      } else {
        throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case PROPERTY:
          {
            int attributes = reader.getAttributeCount();
            String property = null;
            for (int i = 0; i < attributes; i++) {
              String value = reader.getAttributeValue(i);
              Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
              switch (attribute) {
                case NAME:
                  {
                    property = value;
                    break;
                  }
                default:
                  {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                  }
              }
            }
            if (property == null) {
              throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
            }
            String value = reader.getElementText();
            CacheResource.INDEXING_PROPERTIES.parseAndAddParameterElement(
                property, value, node, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
    // ParseUtils.requireNoContent(reader);
  }
  private void parseRelay(
      XMLExtendedStreamReader reader,
      PathAddress stackAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    PathAddress address = stackAddress.append(RelayResourceDefinition.PATH);
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case SITE:
          {
            readAttribute(reader, i, operation, RelayResourceDefinition.Attribute.SITE);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    if (!operation.hasDefined(RelayResourceDefinition.Attribute.SITE.getDefinition().getName())) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.SITE));
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      XMLElement element = XMLElement.forName(reader.getLocalName());
      switch (element) {
        case REMOTE_SITE:
          {
            this.parseRemoteSite(reader, address, operations);
            break;
          }
        case PROPERTY:
          {
            this.parseProperty(reader, address, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
 private void parseProtocolAttribute(
     XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException {
   XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index));
   switch (attribute) {
     case TYPE:
       {
         // Already parsed
         break;
       }
     case SOCKET_BINDING:
       {
         readAttribute(
             reader, index, operation, ProtocolResourceDefinition.Attribute.SOCKET_BINDING);
         break;
       }
     case MODULE:
       {
         if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
           readAttribute(reader, index, operation, ProtocolResourceDefinition.Attribute.MODULE);
           break;
         }
       }
     default:
       {
         throw ParseUtils.unexpectedAttribute(reader, index);
       }
   }
 }
 private void parseProperty(
     XMLExtendedStreamReader reader, PathAddress address, Map<PathAddress, ModelNode> operations)
     throws XMLStreamException {
   ModelNode operation = operations.get(address);
   ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName());
   readAttribute(reader, 0, operation, ProtocolResourceDefinition.Attribute.PROPERTIES);
 }
Exemplo n.º 22
0
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    ParseUtils.requireNoAttributes(reader);
    final Map<String, List<ModelNode>> profileOps = new LinkedHashMap<String, List<ModelNode>>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      if (Namespace.forUri(reader.getNamespaceURI()) != Namespace.UNKNOWN) {
        throw unexpectedElement(reader);
      }
      if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
        throw unexpectedElement(reader);
      }
      String namespace = reader.getNamespaceURI();
      if (profileOps.containsKey(namespace)) {
        throw ControllerMessages.MESSAGES.duplicateDeclaration("subsystem", reader.getLocation());
      }
      // parse subsystem
      final List<ModelNode> subsystems = new ArrayList<ModelNode>();
      reader.handleAny(subsystems);

      profileOps.put(namespace, subsystems);
    }

    // Let extensions modify the profile
    Set<ProfileParsingCompletionHandler> completionHandlers =
        extensionRegistry.getProfileParsingCompletionHandlers();
    for (ProfileParsingCompletionHandler completionHandler : completionHandlers) {
      completionHandler.handleProfileParsingCompletion(profileOps, operations);
    }

    for (List<ModelNode> subsystems : profileOps.values()) {
      operations.addAll(subsystems);
    }
  }
 /** {@inheritDoc} */
 @Override
 public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
     throws XMLStreamException {
   // Require no content
   ParseUtils.requireNoContent(reader);
   list.add(createAddSubsystemOperation());
 }
 public void parse(final XMLExtendedStreamReader reader, final ModelNode operation)
     throws XMLStreamException {
   while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
     if (reader.getLocalName().equals(getXmlName())) {
       final String[] array =
           requireAttributes(
               reader,
               org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(),
               org.jboss.as.controller.parsing.Attribute.VALUE.getLocalName());
       parseAndAddParameterElement(array[0], array[1], operation, reader);
       ParseUtils.requireNoContent(reader);
     } else {
       throw ParseUtils.unexpectedElement(reader);
     }
   }
 }
  private void parseCustomStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    PathAddress storeAddress =
        PathAddress.pathAddress(cache.get(OP_ADDR)).append(ModelKeys.STORE, ModelKeys.STORE_NAME);
    ModelNode store = Util.createAddOperation(storeAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case CLASS:
          {
            StoreResource.CLASS.parseAndSetParameter(value, store, reader);
            break;
          }
        default:
          {
            this.parseStoreAttribute(reader, i, attribute, value, store);
          }
      }
    }

    if (!store.hasDefined(ModelKeys.CLASS)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.CLASS));
    }

    List<ModelNode> additionalConfigurationOperations = new ArrayList<ModelNode>();
    this.parseStoreElements(reader, store, additionalConfigurationOperations);
    operations.add(store);
    operations.addAll(additionalConfigurationOperations);
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementReader#readElement(org.jboss.staxmapper.XMLExtendedStreamReader,
   *     Object)
   */
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    PathAddress subsystemAddress = PathAddress.pathAddress(InfinispanExtension.SUBSYSTEM_PATH);
    ModelNode subsystem = Util.createAddOperation(subsystemAddress);

    // command to add the subsystem
    operations.add(subsystem);

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case CACHE_CONTAINER:
          {
            parseContainer(reader, subsystemAddress, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
 private void parseCacheAttribute(
     XMLExtendedStreamReader reader, int index, Attribute attribute, String value, ModelNode cache)
     throws XMLStreamException {
   switch (attribute) {
     case NAME:
       {
         CacheResource.NAME.parseAndSetParameter(value, cache, reader);
         break;
       }
     case START:
       {
         CacheResource.START.parseAndSetParameter(value, cache, reader);
         break;
       }
     case JNDI_NAME:
       {
         CacheResource.JNDI_NAME.parseAndSetParameter(value, cache, reader);
         break;
       }
     case BATCHING:
       {
         CacheResource.BATCHING.parseAndSetParameter(value, cache, reader);
         break;
       }
     case MODULE:
       {
         CacheResource.CACHE_MODULE.parseAndSetParameter(value, cache, reader);
         break;
       }
     default:
       {
         throw ParseUtils.unexpectedAttribute(reader, index);
       }
   }
 }
 private void parseProtocolElement(
     XMLExtendedStreamReader reader, PathAddress address, Map<PathAddress, ModelNode> operations)
     throws XMLStreamException {
   XMLElement element = XMLElement.forName(reader.getLocalName());
   switch (element) {
     case PROPERTY:
       {
         this.parseProperty(reader, address, operations);
         break;
       }
     case DEFAULT_THREAD_POOL:
       parseThreadPool(ThreadPoolResourceDefinition.DEFAULT, reader, address, operations);
       break;
     case INTERNAL_THREAD_POOL:
       parseThreadPool(ThreadPoolResourceDefinition.INTERNAL, reader, address, operations);
       break;
     case OOB_THREAD_POOL:
       parseThreadPool(ThreadPoolResourceDefinition.OOB, reader, address, operations);
       break;
     case TIMER_THREAD_POOL:
       parseThreadPool(ThreadPoolResourceDefinition.TIMER, reader, address, operations);
       break;
     default:
       {
         throw ParseUtils.unexpectedElement(reader);
       }
   }
 }
  private ModelNode parseDatabaseBinaryStorage(
      final XMLExtendedStreamReader reader, final String repositoryName) throws XMLStreamException {
    final ModelNode storageType = new ModelNode();
    storageType.get(OP).set(ADD);
    storageType
        .get(OP_ADDR)
        .add(SUBSYSTEM, ModeShapeExtension.SUBSYSTEM_NAME)
        .add(ModelKeys.REPOSITORY, repositoryName)
        .add(ModelKeys.CONFIGURATION, ModelKeys.BINARY_STORAGE)
        .add(ModelKeys.STORAGE_TYPE, ModelKeys.DB_BINARY_STORAGE);

    if (reader.getAttributeCount() > 0) {
      for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attrName = reader.getAttributeLocalName(i);
        String attrValue = reader.getAttributeValue(i);
        Attribute attribute = Attribute.forName(attrName);
        switch (attribute) {
            // The rest go on the ModelNode for the type ...
          case DATA_SOURCE_JNDI_NAME:
            ModelAttributes.DATA_SOURCE_JNDI_NAME.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case MIN_VALUE_SIZE:
            ModelAttributes.MINIMUM_BINARY_SIZE.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          default:
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
      }
    }
    requireNoElements(reader);

    return storageType;
  }
  private void parseCustomStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the store add operation
    ModelNode storeAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    storeAddress.add(ModelKeys.STORE, ModelKeys.STORE_NAME);
    storeAddress.protect();
    ModelNode store = Util.getEmptyOperation(ModelDescriptionConstants.ADD, storeAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case CLASS:
          {
            CommonAttributes.CLASS.parseAndSetParameter(value, store, reader);
            break;
          }
        default:
          {
            this.parseStoreAttribute(reader, i, attribute, value, store);
          }
      }
    }

    if (!store.hasDefined(ModelKeys.CLASS)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.CLASS));
    }

    this.parseStoreProperties(reader, store);
    operations.add(store);
  }