@Override
 public void persist(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
   boolean wildcard = getPathElement().isWildcard();
   model =
       wildcard
           ? model.get(getPathElement().getKey())
           : model.get(getPathElement().getKeyValuePair());
   if (!model.isDefined()) {
     return;
   }
   boolean writeWrapper = getXmlWrapperElement() != null;
   if (writeWrapper) {
     writer.writeStartElement(getXmlWrapperElement());
   }
   writer.writeStartElement(getXmlElementName());
   if (wildcard) {
     for (Property p : model.asPropertyList()) {
       writer.writeAttribute(NAME, p.getName());
       for (AttributeDefinition def : getAttributes()) {
         def.getAttributeMarshaller().marshallAsAttribute(def, p.getValue(), false, writer);
       }
       persistChildren(writer, p.getValue());
     }
   } else {
     for (AttributeDefinition def : getAttributes()) {
       def.getAttributeMarshaller().marshallAsAttribute(def, model, false, writer);
     }
     persistChildren(writer, model);
   }
   writer.writeEndElement();
   if (writeWrapper) {
     writer.writeEndElement();
   }
 }
 private void writeXaProperty(XMLExtendedStreamWriter streamWriter, Entry<String, String> entry)
     throws XMLStreamException {
   streamWriter.writeStartElement(XaDataSource.Tag.XADATASOURCEPROPERTY.getLocalName());
   streamWriter.writeAttribute("name", entry.getKey());
   streamWriter.writeCharacters(entry.getValue());
   streamWriter.writeEndElement();
 }
Esempio n. 3
0
    private void writeBoundedQueueThreadPool(
        final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
      writer.writeStartElement(Element.BOUNDED_QUEUE_THREAD_POOL.getLocalName());

      if (node.hasDefined(NAME)) {
        writeAttribute(writer, Attribute.NAME, node.get(NAME));
      }
      if (node.hasDefined(BLOCKING)) {
        writeAttribute(writer, Attribute.BLOCKING, node.get(BLOCKING));
      }
      if (node.hasDefined(ALLOW_CORE_TIMEOUT)) {
        writeAttribute(writer, Attribute.ALLOW_CORE_TIMEOUT, node.get(ALLOW_CORE_TIMEOUT));
      }
      writeRef(writer, node, Element.HANDOFF_EXECUTOR, HANDOFF_EXECUTOR);
      writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY);
      writeThreads(writer, node, Element.CORE_THREADS);
      writeThreads(writer, node, Element.QUEUE_LENGTH);
      writeThreads(writer, node, Element.MAX_THREADS);
      writeTime(writer, node, Element.KEEPALIVE_TIME);

      if (node.hasDefined(PROPERTIES)) {
        writeProperties(writer, node.get(PROPERTIES));
      }

      writer.writeEndElement();
    }
 /* (non-Javadoc)
  * @see org.jboss.as.model.AbstractModelElement#writeContent(org.jboss.staxmapper.XMLExtendedStreamWriter)
  */
 @Override
 public void writeContent(XMLExtendedStreamWriter streamWriter) throws XMLStreamException {
   streamWriter.writeAttribute(Attribute.REF.getLocalName(), ref);
   if (portOffset != 0) {
     streamWriter.writeAttribute(Attribute.PORT_OFFSET.getLocalName(), String.valueOf(portOffset));
   }
 }
 /* Property logic */
 static void writeProperty(final XMLExtendedStreamWriter writer, Property property)
     throws XMLStreamException {
   writer.writeStartElement(Element.PROPERTY.getLocalName());
   writer.writeAttribute(NAME, property.getName());
   writer.writeAttribute(VALUE, property.getValue().asString());
   writer.writeEndElement();
 }
 private void writeWebAppConfiguration(
     XMLExtendedStreamWriter writer, ModelNode webapp, String repositoryName)
     throws XMLStreamException {
   writer.writeStartElement(Element.WEBAPP.getLocalName());
   writer.writeAttribute(Attribute.NAME.getLocalName(), repositoryName);
   ModelAttributes.EXPLODED.marshallAsAttribute(webapp, false, writer);
   writer.writeEndElement();
 }
Esempio n. 7
0
 // TODO use a custom attribute marshaller
 private static void writeFilter(final XMLExtendedStreamWriter writer, final ModelNode node)
     throws XMLStreamException {
   if (node.hasDefined(CommonAttributes.FILTER.getName())) {
     writer.writeEmptyElement(CommonAttributes.FILTER.getXmlName());
     writer.writeAttribute(
         CommonAttributes.STRING, node.get(CommonAttributes.FILTER.getName()).asString());
   }
 }
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    final ModelNode model = context.getModelNode();

    writeWorkerThreadPoolIfAttributesSet(writer, model);

    if (model.hasDefined(CONNECTOR)) {
      final ModelNode connector = model.get(CONNECTOR);
      for (String name : connector.keys()) {
        writeConnector(writer, connector.require(name), name);
      }
    }
    if (model.hasDefined(OUTBOUND_CONNECTION)
        || model.hasDefined(REMOTE_OUTBOUND_CONNECTION)
        || model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
      // write <outbound-connections> element
      writer.writeStartElement(Element.OUTBOUND_CONNECTIONS.getLocalName());

      if (model.hasDefined(OUTBOUND_CONNECTION)) {
        final List<Property> outboundConnections = model.get(OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : outboundConnections) {
          final String connectionName = property.getName();
          // get the specific outbound-connection
          final ModelNode genericOutboundConnectionModel = property.getValue();
          // process and write outbound connection
          this.writeOutboundConnection(writer, connectionName, genericOutboundConnectionModel);
        }
      }
      if (model.hasDefined(REMOTE_OUTBOUND_CONNECTION)) {
        final List<Property> remoteOutboundConnections =
            model.get(REMOTE_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : remoteOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific remote outbound connection
          final ModelNode remoteOutboundConnectionModel = property.getValue();
          // process and write remote outbound connection
          this.writeRemoteOutboundConnection(writer, connectionName, remoteOutboundConnectionModel);
        }
      }
      if (model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
        final List<Property> localOutboundConnections =
            model.get(LOCAL_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : localOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific local outbound connection
          final ModelNode localOutboundConnectionModel = property.getValue();
          // process and write local outbound connection
          this.writeLocalOutboundConnection(writer, connectionName, localOutboundConnectionModel);
        }
      }
      // </outbound-connections>
      writer.writeEndElement();
    }

    writer.writeEndElement();
  }
 private void writeStoreCompression(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.get(ModelKeys.COMPRESSION, ModelKeys.COMPRESSION_NAME).isDefined()) {
     ModelNode compression = store.get(ModelKeys.COMPRESSION, ModelKeys.COMPRESSION_NAME);
     writer.writeStartElement(Element.COMPRESSION.getLocalName());
     this.writeOptional(writer, Attribute.TYPE, compression, ModelKeys.TYPE);
     writer.writeEndElement();
   }
 }
 private void writeStartElement(
     XMLExtendedStreamWriter writer, String namespaceURI, String localName)
     throws XMLStreamException {
   if (namespaceURI != null) {
     writer.writeStartElement(namespaceURI, localName);
   } else {
     writer.writeStartElement(localName);
   }
 }
 private void writeStoreImplementation(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.get(ModelKeys.IMPLEMENTATION, ModelKeys.IMPLEMENTATION_NAME).isDefined()) {
     ModelNode implementation = store.get(ModelKeys.IMPLEMENTATION, ModelKeys.IMPLEMENTATION_NAME);
     writer.writeStartElement(Element.IMPLEMENTATION.getLocalName());
     this.writeOptional(writer, Attribute.TYPE, implementation, ModelKeys.IMPLEMENTATION);
     writer.writeEndElement();
   }
 }
Esempio n. 12
0
 private void writeRef(
     final XMLExtendedStreamWriter writer, final ModelNode node, Element element, String name)
     throws XMLStreamException {
   if (node.hasDefined(name)) {
     writer.writeStartElement(element.getLocalName());
     writeAttribute(writer, Attribute.NAME, node.get(name));
     writer.writeEndElement();
   }
 }
    private void writeProperty(
        XMLExtendedStreamWriter writer, ModelNode node, String name, String value, String localName)
        throws XMLStreamException {

      writer.writeStartElement(localName);
      writer.writeAttribute("name", name);
      writer.writeCharacters(value);
      writer.writeEndElement();
    }
  private void writeWorkspaces(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    boolean started = false;
    // Write these model attributes of 'repository' onto the 'workspaces' XML element ...
    if (ModelAttributes.DEFAULT_WORKSPACE.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.DEFAULT_WORKSPACE.marshallAsAttribute(repository, writer);
    }
    if (ModelAttributes.ALLOW_WORKSPACE_CREATION.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.ALLOW_WORKSPACE_CREATION.marshallAsAttribute(repository, writer);
    }
    if (ModelAttributes.WORKSPACES_CACHE_CONTAINER.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.WORKSPACES_CACHE_CONTAINER.marshallAsAttribute(repository, writer);
    }
    if (has(repository, ModelKeys.PREDEFINED_WORKSPACE_NAMES)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelNode names = repository.get(ModelKeys.PREDEFINED_WORKSPACE_NAMES);
      if (names.isDefined()) {
        Map<String, String> workspacesInitialContent = new HashMap<String, String>();
        if (has(repository, ModelKeys.WORKSPACES_INITIAL_CONTENT)) {
          List<ModelNode> initialContentNodes =
              repository.get(ModelKeys.WORKSPACES_INITIAL_CONTENT).asList();
          for (ModelNode modelNode : initialContentNodes) {
            Property property = modelNode.asProperty();
            workspacesInitialContent.put(property.getName(), property.getValue().asString());
          }
        }

        for (ModelNode workspace : repository.get(ModelKeys.PREDEFINED_WORKSPACE_NAMES).asList()) {
          writer.writeStartElement(Element.WORKSPACE.getLocalName());
          String name = workspace.asString();
          writer.writeAttribute(Attribute.NAME.getLocalName(), name);

          if (workspacesInitialContent.containsKey(name)) {
            writer.writeStartElement(Element.INITIAL_CONTENT.getLocalName());
            writer.writeCharacters(workspacesInitialContent.get(name));
            writer.writeEndElement();
          }

          writer.writeEndElement();
        }
      }
    }
    if (has(repository, ModelKeys.DEFAULT_INITIAL_CONTENT)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      writer.writeStartElement(Element.INITIAL_CONTENT.getLocalName());
      writer.writeCharacters(repository.get(ModelKeys.DEFAULT_INITIAL_CONTENT).asString());
      writer.writeEndElement();
    }
    if (started) {
      writer.writeEndElement();
    }
  }
 private void writeStoreProperties(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.hasDefined(ModelKeys.PROPERTY)) {
     for (Property property : store.get(ModelKeys.PROPERTY).asPropertyList()) {
       writer.writeStartElement(Element.PROPERTY.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       writer.writeCharacters(property.getValue().asString());
       writer.writeEndElement();
     }
   }
 }
 private void writeProperties(final XMLExtendedStreamWriter writer, final ModelNode node)
     throws XMLStreamException {
   writer.writeStartElement(Element.PROPERTIES.getLocalName());
   for (Property prop : node.asPropertyList()) {
     writer.writeStartElement(Element.PROPERTY.getLocalName());
     writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
     PropertyResource.VALUE.marshallAsAttribute(prop.getValue(), writer);
     writer.writeEndElement();
   }
   writer.writeEndElement();
 }
 private void writeStoreExpiration(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.get(ModelKeys.EXPIRATION, ModelKeys.EXPIRATION_NAME).isDefined()) {
     ModelNode expiration = store.get(ModelKeys.EXPIRATION, ModelKeys.EXPIRATION_NAME);
     writer.writeStartElement(Element.EXPIRATION.getLocalName());
     this.writeOptional(writer, Attribute.PATH, expiration, ModelKeys.PATH);
     this.writeOptional(writer, Attribute.RELATIVE_TO, expiration, ModelKeys.RELATIVE_TO);
     this.writeOptional(writer, Attribute.QUEUE_SIZE, expiration, ModelKeys.QUEUE_SIZE);
     writer.writeEndElement();
   }
 }
 private void writeJDBCStoreColumn(
     XMLExtendedStreamWriter writer, Element element, ModelNode table, String key)
     throws XMLStreamException {
   if (table.hasDefined(key)) {
     ModelNode column = table.get(key);
     writer.writeStartElement(element.getLocalName());
     this.writeOptional(writer, Attribute.NAME, column, ModelKeys.NAME);
     this.writeOptional(writer, Attribute.TYPE, column, ModelKeys.TYPE);
     writer.writeEndElement();
   }
 }
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode scanners = context.getModelNode();
      for (final Property list : scanners.asPropertyList()) {
        final ModelNode node = list.getValue();

        for (final Property scanner : node.asPropertyList()) {

          writer.writeEmptyElement(Element.DEPLOYMENT_SCANNER.getLocalName());
          writer.writeAttribute(Attribute.NAME.getLocalName(), scanner.getName());
          ModelNode configuration = scanner.getValue();
          if (configuration.hasDefined(CommonAttributes.PATH)) {
            writer.writeAttribute(
                Attribute.PATH.getLocalName(), configuration.get(CommonAttributes.PATH).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_ENABLED)) {
            writer.writeAttribute(
                Attribute.SCAN_ENABLED.getLocalName(),
                configuration.get(CommonAttributes.SCAN_ENABLED).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_INTERVAL)) {
            writer.writeAttribute(
                Attribute.SCAN_INTERVAL.getLocalName(),
                configuration.get(CommonAttributes.SCAN_INTERVAL).asString());
          }
          if (configuration.hasDefined(CommonAttributes.RELATIVE_TO)) {
            writer.writeAttribute(
                Attribute.RELATIVE_TO.getLocalName(),
                configuration.get(CommonAttributes.RELATIVE_TO).asString());
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_ZIPPED)) {
            if (!configuration.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_ZIPPED.getLocalName(), Boolean.FALSE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_EXPLODED)) {
            if (configuration.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_EXPLODED.getLocalName(), Boolean.TRUE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.DEPLOYMENT_TIMEOUT)) {
            writer.writeAttribute(
                Attribute.DEPLOYMENT_TIMEOUT.getLocalName(),
                configuration.get(CommonAttributes.DEPLOYMENT_TIMEOUT).asString());
          }
        }
        writer.writeEndElement();
      }
    }
 private void writePolicy(final XMLExtendedStreamWriter writer, final ModelNode node)
     throws XMLStreamException {
   writer.writeStartElement(Element.POLICY.getLocalName());
   final ModelNode policy = node.get(POLICY);
   SaslPolicyResource.FORWARD_SECRECY.marshallAsElement(policy, writer);
   SaslPolicyResource.NO_ACTIVE.marshallAsElement(policy, writer);
   SaslPolicyResource.NO_ANONYMOUS.marshallAsElement(policy, writer);
   SaslPolicyResource.NO_DICTIONARY.marshallAsElement(policy, writer);
   SaslPolicyResource.NO_PLAIN_TEXT.marshallAsElement(policy, writer);
   SaslPolicyResource.PASS_CREDENTIALS.marshallAsElement(policy, writer);
   writer.writeEndElement();
 }
 static void writeSSL(XMLExtendedStreamWriter writer, ModelNode sslConfig)
     throws XMLStreamException {
   writer.writeStartElement(Element.SSL.getLocalName());
   writeAttribute(writer, Attribute.KEY_ALIAS.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.PASSWORD.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CERTIFICATE_KEY_FILE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CIPHER_SUITE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CA_CERTIFICATE_FILE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CA_REVOCATION_URL.getLocalName(), sslConfig);
   writer.writeEndElement();
 }
Esempio n. 22
0
 private boolean writeStaticResourceAttribute(
     XMLExtendedStreamWriter writer, String attribute, ModelNode config, boolean startWritten)
     throws XMLStreamException {
   if (DefaultStaticResources.hasNotDefault(config, attribute)) {
     if (!startWritten) {
       writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       writer.writeStartElement(Element.STATIC_RESOURCES.getLocalName());
     }
     writer.writeAttribute(attribute, config.get(attribute).asString());
     return true;
   }
   return false;
 }
    private void writeAdminObject(
        XMLExtendedStreamWriter streamWriter, ModelNode adminObject, final String poolName)
        throws XMLStreamException {
      streamWriter.writeStartElement(ResourceAdapter.Tag.ADMIN_OBJECT.getLocalName());
      CLASS_NAME.marshallAsAttribute(adminObject, streamWriter);
      JNDINAME.marshallAsAttribute(adminObject, streamWriter);
      ENABLED.marshallAsAttribute(adminObject, streamWriter);
      USE_JAVA_CONTEXT.marshallAsAttribute(adminObject, streamWriter);
      streamWriter.writeAttribute("pool-name", poolName);

      writeNewConfigProperties(streamWriter, adminObject);
      streamWriter.writeEndElement();
    }
 private static void writeModuleItem(
     final XMLExtendedStreamWriter writer,
     final DistributionModuleItem item,
     final Element element)
     throws XMLStreamException {
   writer.writeEmptyElement(element.name);
   writer.writeAttribute(Attribute.NAME.name, item.getName());
   writer.writeAttribute(Attribute.SLOT.name, item.getSlot());
   writer.writeAttribute(
       Attribute.COMPARISON_HASH.name, HashUtils.bytesToHexString(item.getComparisonHash()));
   writer.writeAttribute(
       Attribute.METADATA_HASH.name, HashUtils.bytesToHexString(item.getMetadataHash()));
 }
Esempio n. 25
0
 private static void writeTransportParam(
     final XMLExtendedStreamWriter writer, final ModelNode param) throws XMLStreamException {
   if (param.isDefined()) {
     for (final Property parameter : param.asPropertyList()) {
       writer.writeStartElement(Element.PARAM.getLocalName());
       writer.writeAttribute(Attribute.KEY.getLocalName(), parameter.getName());
       writer.writeAttribute(
           Attribute.VALUE.getLocalName(),
           parameter.getValue().get(TransportParamDefinition.VALUE.getName()).asString());
       writer.writeEndElement();
     }
   }
 }
Esempio n. 26
0
 private static void writeAcceptors(final XMLExtendedStreamWriter writer, final ModelNode node)
     throws XMLStreamException {
   if (node.hasDefined(ACCEPTOR)
       || node.hasDefined(REMOTE_ACCEPTOR)
       || node.hasDefined(IN_VM_ACCEPTOR)) {
     writer.writeStartElement(Element.ACCEPTORS.getLocalName());
     if (node.hasDefined(REMOTE_ACCEPTOR)) {
       for (final Property property : node.get(REMOTE_ACCEPTOR).asPropertyList()) {
         writer.writeStartElement(Element.NETTY_ACCEPTOR.getLocalName());
         writeAcceptorContent(writer, property);
         writer.writeEndElement();
       }
     }
     if (node.hasDefined(IN_VM_ACCEPTOR)) {
       for (final Property property : node.get(IN_VM_ACCEPTOR).asPropertyList()) {
         writer.writeStartElement(Element.IN_VM_ACCEPTOR.getLocalName());
         writeAcceptorContent(writer, property);
         writer.writeEndElement();
       }
     }
     if (node.hasDefined(ACCEPTOR)) {
       for (final Property property : node.get(ACCEPTOR).asPropertyList()) {
         writer.writeStartElement(Element.ACCEPTOR.getLocalName());
         writeAcceptorContent(writer, property);
         writer.writeEndElement();
       }
     }
     writer.writeEndElement();
     writeNewLine(writer);
   }
 }
  public void persist(XMLExtendedStreamWriter writer, ModelNode model, String namespaceURI)
      throws XMLStreamException {
    boolean wildcard = getPathElement().isWildcard();
    model =
        wildcard
            ? model.get(getPathElement().getKey())
            : model.get(getPathElement().getKeyValuePair());
    if (!model.isDefined() && !useValueAsElementName()) {
      return;
    }
    boolean isSubsystem = getPathElement().getKey().equals(ModelDescriptionConstants.SUBSYSTEM);

    boolean writeWrapper = getXmlWrapperElement() != null;
    if (writeWrapper) {
      writeStartElement(writer, namespaceURI, getXmlWrapperElement());
    }

    if (wildcard) {
      for (Property p : model.asPropertyList()) {
        if (useValueAsElementName()) {
          writeStartElement(writer, namespaceURI, p.getName());
        } else {
          writeStartElement(writer, namespaceURI, getXmlElementName());
          writer.writeAttribute(NAME, p.getName());
        }
        for (AttributeDefinition def : getAttributes()) {
          def.getAttributeMarshaller().marshallAsAttribute(def, p.getValue(), false, writer);
        }
        persistChildren(writer, p.getValue());
        writer.writeEndElement();
      }
    } else {
      if (useValueAsElementName()) {
        writeStartElement(writer, namespaceURI, getPathElement().getValue());
      } else if (isSubsystem) {
        startSubsystemElement(writer, namespaceURI, getChildren().isEmpty());
      } else {
        writeStartElement(writer, namespaceURI, getXmlElementName());
      }
      for (AttributeDefinition def : getAttributes()) {
        def.getAttributeMarshaller().marshallAsAttribute(def, model, false, writer);
      }
      persistChildren(writer, model);
      writer.writeEndElement();
    }

    if (writeWrapper) {
      writer.writeEndElement();
    }
  }
  private void writeTextExtraction(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    if (has(repository, ModelKeys.TEXT_EXTRACTOR)) {
      writer.writeStartElement(Element.TEXT_EXTRACTORS.getLocalName());
      if (repository.hasDefined(ModelKeys.TEXT_EXTRACTORS_THREAD_POOL_NAME)) {
        writer.writeAttribute(
            Attribute.THREAD_POOL_NAME.getLocalName(),
            repository.get(ModelKeys.TEXT_EXTRACTORS_THREAD_POOL_NAME).asString());
      }
      if (repository.hasDefined(ModelKeys.TEXT_EXTRACTORS_MAX_POOL_SIZE)) {
        writer.writeAttribute(
            Attribute.MAX_POOL_SIZE.getLocalName(),
            repository.get(ModelKeys.TEXT_EXTRACTORS_MAX_POOL_SIZE).asString());
      }
      for (Property extractor : repository.get(ModelKeys.TEXT_EXTRACTOR).asPropertyList()) {
        writer.writeStartElement(Element.TEXT_EXTRACTOR.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), extractor.getName());
        ModelNode prop = extractor.getValue();
        ModelAttributes.TEXT_EXTRACTOR_CLASSNAME.marshallAsAttribute(prop, writer);
        ModelAttributes.MODULE.marshallAsAttribute(prop, writer);

        // Write out the extra properties ...
        if (has(prop, ModelKeys.PROPERTIES)) {
          ModelNode properties = prop.get(ModelKeys.PROPERTIES);
          for (Property property : properties.asPropertyList()) {
            writer.writeAttribute(property.getName(), property.getValue().asString());
          }
        }
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
  }
Esempio n. 29
0
 private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (!node.isDefined()) {
     return;
   }
   List<Property> properties = node.asPropertyList();
   if (!properties.isEmpty()) {
     writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
     for (final Property property : node.asPropertyList()) {
       writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       final ModelNode service = property.getValue();
       for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
         attribute.marshallAsElement(property.getValue(), writer);
       }
       // TODO use a custom attribute marshaller
       if (service.hasDefined(CommonAttributes.PARAM)) {
         for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
           writer.writeEmptyElement(Element.PARAM.getLocalName());
           writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
           writer.writeAttribute(
               Attribute.VALUE.getLocalName(),
               param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
         }
       }
       writer.writeEndElement();
     }
     writer.writeEndElement();
     writeNewLine(writer);
   }
 }
  /* Dynamic load provider */
  static void writeDynamicLoadProvider(XMLExtendedStreamWriter writer, ModelNode config)
      throws XMLStreamException {
    writer.writeStartElement(Element.DYNAMIC_LOAD_PROVIDER.getLocalName());
    writeAttribute(writer, HISTORY, config);
    writeAttribute(writer, DECAY, config);

    // write the elements.
    if (config.hasDefined(LOAD_METRIC)) {
      writeLoadMetric(writer, config.get(LOAD_METRIC));
    }
    if (config.hasDefined(CUSTOM_LOAD_METRIC)) {
      writeCustomLoadMetric(writer, config.get(CUSTOM_LOAD_METRIC));
    }
    writer.writeEndElement();
  }