Example #1
0
 /**
  * Read an element which contains only a single string attribute.
  *
  * @param reader the reader
  * @param attributeName the attribute name, usually "value" or "name"
  * @return the string value
  * @throws javax.xml.stream.XMLStreamException if an error occurs or if the element does not
  *     contain the specified attribute, contains other attributes, or contains child elements.
  */
 public static String readStringAttributeElement(
     final XMLExtendedStreamReader reader, final String attributeName) throws XMLStreamException {
   requireSingleAttribute(reader, attributeName);
   final String value = reader.getAttributeValue(0);
   requireNoContent(reader);
   return value;
 }
Example #2
0
 /**
  * Read an element which contains only a single boolean attribute.
  *
  * @param reader the reader
  * @param attributeName the attribute name, usually "value"
  * @return the boolean value
  * @throws javax.xml.stream.XMLStreamException if an error occurs or if the element does not
  *     contain the specified attribute, contains other attributes, or contains child elements.
  */
 public static boolean readBooleanAttributeElement(
     final XMLExtendedStreamReader reader, final String attributeName) throws XMLStreamException {
   requireSingleAttribute(reader, attributeName);
   final boolean value = Boolean.parseBoolean(reader.getAttributeValue(0));
   requireNoContent(reader);
   return value;
 }
 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);
 }
  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);
  }
Example #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);
 }
Example #6
0
    private void parseArchiveValidation(final XMLExtendedStreamReader reader, final ModelNode node)
        throws XMLStreamException {

      final int cnt = reader.getAttributeCount();
      for (int i = 0; i < cnt; i++) {
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch (attribute) {
          case ENABLED:
            {
              node.get(ARCHIVE_VALIDATION_ENABLED)
                  .set(Boolean.parseBoolean(reader.getAttributeValue(i)));
              break;
            }
          case FAIL_ON_ERROR:
            {
              node.get(ARCHIVE_VALIDATION_FAIL_ON_ERROR)
                  .set(Boolean.parseBoolean(reader.getAttributeValue(i)));

              break;
            }
          case FAIL_ON_WARN:
            {
              node.get(ARCHIVE_VALIDATION_FAIL_ON_WARN)
                  .set(Boolean.parseBoolean(reader.getAttributeValue(i)));
              break;
            }
          default:
            {
              throw unexpectedAttribute(reader, i);
            }
        }
      }
      // Handle elements
      requireNoContent(reader);
    }
 /** {@inheritDoc} */
 @Override
 public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
     throws XMLStreamException {
   // Require no content
   ParseUtils.requireNoContent(reader);
   list.add(createAddSubsystemOperation());
 }
Example #8
0
    ModelNode parseModulesElement(XMLExtendedStreamReader reader) throws XMLStreamException {

      // Handle attributes
      requireNoAttributes(reader);

      ModelNode modules = new ModelNode();

      // Handle elements
      while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch (Namespace.forUri(reader.getNamespaceURI())) {
          case OSGI_1_0:
            {
              final Element element = Element.forName(reader.getLocalName());
              if (element == Element.MODULE) {
                String identifier = null;
                String start = null;
                final int count = reader.getAttributeCount();
                for (int i = 0; i < count; i++) {
                  requireNoNamespaceAttribute(reader, i);
                  final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
                  switch (attribute) {
                    case IDENTIFIER:
                      {
                        identifier = reader.getAttributeValue(i);
                        break;
                      }
                    case START:
                      {
                        start = reader.getAttributeValue(i);
                        break;
                      }
                    default:
                      throw unexpectedAttribute(reader, i);
                  }
                }
                if (identifier == null)
                  throw missingRequired(reader, Collections.singleton(Attribute.IDENTIFIER));
                if (modules.has(identifier))
                  throw new XMLStreamException(
                      element.getLocalName() + " already declared", reader.getLocation());

                ModelNode module = new ModelNode();
                if (start != null) {
                  module.get(START).set(start);
                }
                modules.get(identifier).set(module);

                requireNoContent(reader);
              } else {
                throw unexpectedElement(reader);
              }
              break;
            }
          default:
            throw unexpectedElement(reader);
        }
      }

      return modules;
    }
  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 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 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 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);
 }
Example #13
0
 /** {@inheritDoc} */
 @Override
 public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list)
     throws XMLStreamException {
   // Require no attributes or content
   requireNoAttributes(reader);
   requireNoContent(reader);
   list.add(Util.createAddOperation(PathAddress.pathAddress(PATH_SUBSYSTEM)));
 }
Example #14
0
    /** {@inheritDoc} */
    @Override
    public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
        throws XMLStreamException {
      ParseUtils.requireNoAttributes(reader);
      ParseUtils.requireNoContent(reader);

      list.add(createAddOperation());
    }
  /** Adds the worker thread pool attributes to the subysystem add method */
  void parseWorkerThreadPool(final XMLExtendedStreamReader reader, final ModelNode subsystemAdd)
      throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
      requireNoNamespaceAttribute(reader, i);
      final String value = reader.getAttributeValue(i);
      final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case WORKER_READ_THREADS:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_READ_THREADS)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_READ_THREADS);
          }
          RemotingSubsystemRootResource.WORKER_READ_THREADS.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        case WORKER_TASK_CORE_THREADS:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_CORE_THREADS)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_CORE_THREADS);
          }
          RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        case WORKER_TASK_KEEPALIVE:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_KEEPALIVE)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_KEEPALIVE);
          }
          RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        case WORKER_TASK_LIMIT:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_LIMIT)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_LIMIT);
          }
          RemotingSubsystemRootResource.WORKER_TASK_LIMIT.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        case WORKER_TASK_MAX_THREADS:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_MAX_THREADS)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_MAX_THREADS);
          }
          RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        case WORKER_WRITE_THREADS:
          if (subsystemAdd.hasDefined(CommonAttributes.WORKER_WRITE_THREADS)) {
            throw duplicateAttribute(reader, CommonAttributes.WORKER_WRITE_THREADS);
          }
          RemotingSubsystemRootResource.WORKER_WRITE_THREADS.parseAndSetParameter(
              value, subsystemAdd, reader);
          break;
        default:
          throw unexpectedAttribute(reader, i);
      }
    }

    requireNoContent(reader);
  }
  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);
  }
Example #17
0
 /**
  * Read an element which contains only a single list attribute of a given type.
  *
  * @param reader the reader
  * @param attributeName the attribute name, usually "value"
  * @param type the value type class
  * @param <T> the value type
  * @return the value list
  * @throws javax.xml.stream.XMLStreamException if an error occurs or if the element does not
  *     contain the specified attribute, contains other attributes, or contains child elements.
  */
 @SuppressWarnings({"unchecked"})
 public static <T> List<T> readListAttributeElement(
     final XMLExtendedStreamReader reader, final String attributeName, final Class<T> type)
     throws XMLStreamException {
   requireSingleAttribute(reader, attributeName);
   // todo: fix this when this method signature is corrected
   final List<T> value = (List<T>) reader.getListAttributeValue(0, type);
   requireNoContent(reader);
   return value;
 }
Example #18
0
 static ModelNode parseSsl(XMLExtendedStreamReader reader) throws XMLStreamException {
   final ModelNode ssl = new ModelNode();
   ssl.setEmptyObject();
   final int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     requireNoNamespaceAttribute(reader, i);
     final String value = reader.getAttributeValue(i);
     final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case NAME:
         ssl.get(NAME).set(value);
         break;
       case KEY_ALIAS:
         ssl.get(KEY_ALIAS).set(value);
         break;
       case PASSWORD:
         ssl.get(PASSWORD).set(value);
         break;
       case CERTIFICATE_KEY_FILE:
         ssl.get(CERTIFICATE_KEY_FILE).set(value);
         break;
       case CIPHER_SUITE:
         ssl.get(CIPHER_SUITE).set(value);
         break;
       case PROTOCOL:
         ssl.get(PROTOCOL).set(value);
         break;
       case VERIFY_CLIENT:
         ssl.get(VERIFY_CLIENT).set(value);
         break;
       case VERIFY_DEPTH:
         ssl.get(VERIFY_DEPTH).set(Integer.valueOf(value));
         break;
       case CERTIFICATE_FILE:
         ssl.get(CERTIFICATE_FILE).set(value);
         break;
       case CA_CERTIFICATE_FILE:
         ssl.get(CA_CERTIFICATE_FILE).set(value);
         break;
       case CA_REVOCATION_URL:
         ssl.get(CA_REVOCATION_URL).set(value);
         break;
       case SESSION_CACHE_SIZE:
         ssl.get(SESSION_CACHE_SIZE).set(value);
         break;
       case SESSION_TIMEOUT:
         ssl.get(SESSION_TIMEOUT).set(value);
         break;
       default:
         throw unexpectedAttribute(reader, i);
     }
   }
   requireNoContent(reader);
   return ssl;
 }
Example #19
0
    private void parseCcm(final XMLExtendedStreamReader reader, final ModelNode node)
        throws XMLStreamException {

      final boolean debug =
          Boolean.parseBoolean(reader.getAttributeValue("", Attribute.DEBUG.getLocalName()));
      final boolean error =
          Boolean.parseBoolean(reader.getAttributeValue("", Attribute.ERROR.getLocalName()));

      node.get(CACHED_CONNECTION_MANAGER_DEBUG).set(debug);
      node.get(CACHED_CONNECTION_MANAGER_ERROR).set(error);

      requireNoContent(reader);
    }
Example #20
0
    private void parseBeanValidation(final XMLExtendedStreamReader reader, final ModelNode node)
        throws XMLStreamException {
      requireSingleAttribute(reader, Attribute.ENABLED.getLocalName());
      final boolean value =
          reader.getAttributeValue(0) != null
              ? Boolean.parseBoolean(reader.getAttributeValue(0))
              : true;
      requireNoContent(reader);

      node.get(BEAN_VALIDATION_ENABLED).set(value);
      // Don't add a requireNoContent here as readBooleanAttributeElement
      // already performs that check.
    }
 @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);
   }
 }
 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 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:
          {
            TransportResource.STACK.parseAndSetParameter(value, transport, reader);
            break;
          }
        case CLUSTER:
          {
            TransportResource.CLUSTER.parseAndSetParameter(value, transport, reader);
            break;
          }
        case EXECUTOR:
          {
            TransportResource.EXECUTOR.parseAndSetParameter(value, transport, reader);
            break;
          }
        case LOCK_TIMEOUT:
          {
            TransportResource.LOCK_TIMEOUT.parseAndSetParameter(value, transport, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);

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

    operations.add(transport);
  }
 public void parseChildren(
     final XMLExtendedStreamReader reader, PathAddress parentAddress, List<ModelNode> list)
     throws XMLStreamException {
   if (getChildren().size() == 0) {
     ParseUtils.requireNoContent(reader);
   } else {
     Map<String, PersistentResourceDefinition> children = getChildrenMap();
     while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
       PersistentResourceDefinition child = children.get(reader.getLocalName());
       if (child != null) {
         child.parse(reader, parentAddress, list);
       } else {
         throw ParseUtils.unexpectedElement(reader);
       }
     }
   }
 }
  private void parseStoreWriteBehind(
      XMLExtendedStreamReader reader, ModelNode store, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the write-behind add operation
    ModelNode writeBehindAddress = store.get(ModelDescriptionConstants.OP_ADDR).clone();
    writeBehindAddress.add(ModelKeys.WRITE_BEHIND, ModelKeys.WRITE_BEHIND_NAME);
    writeBehindAddress.protect();
    ModelNode writeBehind =
        Util.getEmptyOperation(ModelDescriptionConstants.ADD, writeBehindAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case FLUSH_LOCK_TIMEOUT:
          {
            StoreWriteBehindResource.FLUSH_LOCK_TIMEOUT.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case MODIFICATION_QUEUE_SIZE:
          {
            StoreWriteBehindResource.MODIFICATION_QUEUE_SIZE.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case SHUTDOWN_TIMEOUT:
          {
            StoreWriteBehindResource.SHUTDOWN_TIMEOUT.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case THREAD_POOL_SIZE:
          {
            StoreWriteBehindResource.THREAD_POOL_SIZE.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        default:
          throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(writeBehind);
  }
  @SuppressWarnings("deprecation")
  private void parseTransaction(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the transaction add operation
    ModelNode transactionAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    transactionAddress.add(ModelKeys.TRANSACTION, ModelKeys.TRANSACTION_NAME);
    transactionAddress.protect();
    ModelNode transaction =
        Util.getEmptyOperation(ModelDescriptionConstants.ADD, transactionAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STOP_TIMEOUT:
          {
            CommonAttributes.STOP_TIMEOUT.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case MODE:
          {
            CommonAttributes.MODE.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case LOCKING:
          {
            CommonAttributes.LOCKING.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case EAGER_LOCKING:
          {
            ROOT_LOGGER.eagerAttributeDeprecated();
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(transaction);
  }
 private void parseTransport(XMLExtendedStreamReader reader, ModelNode transport)
     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 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);
 }
 static ModelNode parseSimpleLoadProvider(XMLExtendedStreamReader reader)
     throws XMLStreamException {
   final ModelNode load = new ModelNode();
   final int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     requireNoNamespaceAttribute(reader, i);
     final String value = reader.getAttributeValue(i);
     final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case FACTOR:
         load.get(FACTOR).set(value);
         break;
       default:
         unexpectedAttribute(reader, i);
     }
   }
   ParseUtils.requireNoContent(reader);
   return load;
 }
Example #29
0
 static ModelNode parseContainerConfig(XMLExtendedStreamReader reader) throws XMLStreamException {
   final ModelNode config = new ModelNode();
   // no attributes
   if (reader.getAttributeCount() > 0) {
     throw unexpectedAttribute(reader, 0);
   }
   // elements
   while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
     final Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case STATIC_RESOURCES:
         {
           final ModelNode resourceServing = parseStaticResources(reader);
           config.get(STATIC_RESOURCES).set(resourceServing);
           break;
         }
       case JSP_CONFIGURATION:
         {
           final ModelNode jspConfiguration = parseJSPConfiguration(reader);
           config.get(JSP_CONFIGURATION).set(jspConfiguration);
           break;
         }
       case MIME_MAPPING:
         {
           final String[] array =
               requireAttributes(
                   reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
           config.get(MIME_MAPPING).get(array[0]).set(array[1]);
           requireNoContent(reader);
           break;
         }
       case WELCOME_FILE:
         {
           final String welcomeFile = reader.getElementText().trim();
           config.get(WELCOME_FILE).add(welcomeFile);
           break;
         }
       default:
         throw unexpectedElement(reader);
     }
   }
   return config;
 }
 private void parseRemoteServer(XMLExtendedStreamReader reader, ModelNode server)
     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 OUTBOUND_SOCKET_BINDING:
         {
           server.get(ModelKeys.OUTBOUND_SOCKET_BINDING).set(value);
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }