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);
   }
 }
 private void writeBeanValidation(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (has(node, BEAN_VALIDATION_ENABLED)) {
     writer.writeEmptyElement(Element.BEAN_VALIDATION.getLocalName());
     writeAttribute(writer, Attribute.ENABLED, node.require(BEAN_VALIDATION_ENABLED));
   }
 }
 // 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());
   }
 }
Exemple #4
0
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode node = context.getModelNode();

      if (has(node, ACTIVATION)) {
        writeAttribute(writer, Attribute.ACTIVATION, node.get(ACTIVATION));
      }

      if (has(node, CONFIGURATION)) {
        ModelNode configuration = node.get(CONFIGURATION);
        writer.writeStartElement(Element.CONFIGURATION.getLocalName());
        writeAttribute(writer, Attribute.PID, configuration.require(PID));
        if (has(configuration, CONFIGURATION_PROPERTIES)) {
          ModelNode configurationProperties = configuration.get(CONFIGURATION_PROPERTIES);
          Set<String> keys = configurationProperties.keys();
          for (String current : keys) {
            String value = configurationProperties.get(current).asString();
            writer.writeStartElement(Element.PROPERTY.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), current);
            writer.writeCharacters(value);
            writer.writeEndElement();
          }
        }
        writer.writeEndElement();
      }

      if (has(node, PROPERTIES)) {
        ModelNode properties = node.get(PROPERTIES);
        writer.writeStartElement(Element.PROPERTIES.getLocalName());
        Set<String> keys = properties.keys();
        for (String current : keys) {
          String value = properties.get(current).asString();
          writer.writeStartElement(Element.PROPERTY.getLocalName());
          writer.writeAttribute(Attribute.NAME.getLocalName(), current);
          writer.writeCharacters(value);
          writer.writeEndElement();
        }
        writer.writeEndElement();
      }

      if (has(node, MODULES)) {
        ModelNode modules = node.get(MODULES);
        writer.writeStartElement(Element.MODULES.getLocalName());
        Set<String> keys = modules.keys();
        for (String current : keys) {
          ModelNode currentModule = modules.get(current);
          writer.writeEmptyElement(Element.MODULE.getLocalName());
          writer.writeAttribute(Attribute.IDENTIFIER.getLocalName(), current);
          if (has(currentModule, START)) {
            writeAttribute(writer, Attribute.START, currentModule.require(START));
          }
        }
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
 private void writeCachedConnectionManager(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (has(node, CACHED_CONNECTION_MANAGER_DEBUG)
       || has(node, CACHED_CONNECTION_MANAGER_ERROR)) {
     writer.writeEmptyElement(Element.CACHED_CONNECTION_MANAGER.getLocalName());
     if (has(node, CACHED_CONNECTION_MANAGER_DEBUG))
       writeAttribute(writer, Attribute.DEBUG, node.require(CACHED_CONNECTION_MANAGER_DEBUG));
     if (has(node, CACHED_CONNECTION_MANAGER_ERROR))
       writeAttribute(writer, Attribute.ERROR, node.require(CACHED_CONNECTION_MANAGER_ERROR));
   }
 }
    /** {@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();
      }
    }
  public void startSubsystemElement(
      XMLExtendedStreamWriter writer, String namespaceURI, boolean empty)
      throws XMLStreamException {

    if (writer.getNamespaceContext().getPrefix(namespaceURI) == null) {
      // Unknown namespace; it becomes default
      writer.setDefaultNamespace(namespaceURI);
      if (empty) {
        writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
      } else {
        writer.writeStartElement(Element.SUBSYSTEM.getLocalName());
      }
      writer.writeNamespace(null, namespaceURI);
    } else {
      if (empty) {
        writer.writeEmptyElement(namespaceURI, Element.SUBSYSTEM.getLocalName());
      } else {
        writer.writeStartElement(namespaceURI, Element.SUBSYSTEM.getLocalName());
      }
    }
  }
 private static void writeDirectory(
     final XMLExtendedStreamWriter writer, final Element element, final ModelNode node)
     throws XMLStreamException {
   final String localName = element.getLocalName();
   if (node.hasDefined(localName)) {
     final ModelNode localNode = node.get(localName);
     if (RELATIVE_TO.isMarshallable(localNode) || PATHS.get(localName).isMarshallable(localNode)) {
       writer.writeEmptyElement(localName);
       PATHS.get(localName).marshallAsAttribute(node.get(localName), writer);
       RELATIVE_TO.marshallAsAttribute(node.get(localName), writer);
     }
   }
 }
 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()));
 }
Exemple #10
0
 private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode)
     throws XMLStreamException {
   boolean hasRolloutPlans =
       modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH);
   boolean mustWrite = hasRolloutPlans; // || other elements we may add later
   if (mustWrite) {
     writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName());
     if (hasRolloutPlans) {
       writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName());
       writer.writeAttribute(
           Attribute.SHA1.getLocalName(),
           HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes()));
     }
     writer.writeEndElement();
   }
 }
 private void writeContainerConfig(XMLExtendedStreamWriter writer, ModelNode config)
     throws XMLStreamException {
   boolean containerConfigStartWritten = false;
   if (config.hasDefined(STATIC_RESOURCES)) {
     containerConfigStartWritten = writeStaticResources(writer, config.get(STATIC_RESOURCES));
   }
   if (config.hasDefined(JSP_CONFIGURATION)) {
     containerConfigStartWritten =
         writeJSPConfiguration(writer, config.get(JSP_CONFIGURATION), containerConfigStartWritten)
             || containerConfigStartWritten;
   }
   ModelNode container = config;
   if (config.hasDefined(CONTAINER)) {
     // this has been added to get the stuff manageable
     container = config.get(CONTAINER);
   }
   if (container.hasDefined(MIME_MAPPING)) {
     if (!containerConfigStartWritten) {
       writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       containerConfigStartWritten = true;
     }
     for (final Property entry : container.get(MIME_MAPPING).asPropertyList()) {
       writer.writeEmptyElement(Element.MIME_MAPPING.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), entry.getName());
       writer.writeAttribute(Attribute.VALUE.getLocalName(), entry.getValue().asString());
     }
   }
   if (container.hasDefined(WELCOME_FILE)) {
     if (!containerConfigStartWritten) {
       writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       containerConfigStartWritten = true;
     }
     for (final ModelNode file : container.get(WELCOME_FILE).asList()) {
       writer.writeStartElement(Element.WELCOME_FILE.getLocalName());
       writer.writeCharacters(file.asString());
       writer.writeEndElement();
     }
   }
   if (containerConfigStartWritten) {
     writer.writeEndElement();
   }
 }
Exemple #12
0
 private void writeArchiveValidation(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (hasAnyOf(
       node,
       ARCHIVE_VALIDATION_ENABLED,
       ARCHIVE_VALIDATION_FAIL_ON_ERROR,
       ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
     writer.writeEmptyElement(Element.ARCHIVE_VALIDATION.getLocalName());
     if (has(node, ARCHIVE_VALIDATION_ENABLED)) {
       writeAttribute(writer, Attribute.ENABLED, node.require(ARCHIVE_VALIDATION_ENABLED));
     }
     if (has(node, ARCHIVE_VALIDATION_FAIL_ON_ERROR)) {
       writeAttribute(
           writer, Attribute.FAIL_ON_ERROR, node.require(ARCHIVE_VALIDATION_FAIL_ON_ERROR));
     }
     if (has(node, ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
       writeAttribute(
           writer, Attribute.FAIL_ON_WARN, node.require(ARCHIVE_VALIDATION_FAIL_ON_WARN));
     }
   }
 }
Exemple #13
0
  private void writeProfile(
      final XMLExtendedStreamWriter writer,
      final String profileName,
      final ModelNode profileNode,
      final ModelMarshallingContext context)
      throws XMLStreamException {

    writer.writeStartElement(Element.PROFILE.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), profileName);

    if (profileNode.hasDefined(INCLUDES)) {
      for (final ModelNode include : profileNode.get(INCLUDES).asList()) {
        writer.writeEmptyElement(INCLUDE);
        writer.writeAttribute(PROFILE, include.asString());
      }
    }
    if (profileNode.hasDefined(SUBSYSTEM)) {
      final Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
      if (subsystemNames.size() > 0) {
        String defaultNamespace =
            writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
        for (String subsystemName : subsystemNames) {
          try {
            ModelNode subsystem = profileNode.get(SUBSYSTEM, subsystemName);
            XMLElementWriter<SubsystemMarshallingContext> subsystemWriter =
                context.getSubsystemWriter(subsystemName);
            if (subsystemWriter
                != null) { // FIXME -- remove when extensions are doing the registration
              subsystemWriter.writeContent(
                  writer, new SubsystemMarshallingContext(subsystem, writer));
            }
          } finally {
            writer.setDefaultNamespace(defaultNamespace);
          }
        }
      }
    }
    writer.writeEndElement();
  }
 private static void writeClusterConnections(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (!node.isDefined()) {
     return;
   }
   List<Property> properties = node.asPropertyList();
   if (!properties.isEmpty()) {
     writer.writeStartElement(Element.CLUSTER_CONNECTIONS.getLocalName());
     for (final Property property : node.asPropertyList()) {
       writer.writeStartElement(Element.CLUSTER_CONNECTION.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       final ModelNode cluster = property.getValue();
       for (AttributeDefinition attribute : ClusterConnectionDefinition.ATTRIBUTES) {
         if (attribute == ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY) {
           // we nest it in static-connectors
           continue;
         }
         if (attribute == CONNECTOR_REFS) {
           if (attribute.isMarshallable(cluster)) {
             writer.writeStartElement(Element.STATIC_CONNECTORS.getLocalName());
             ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
             CONNECTOR_REFS.marshallAsElement(cluster, writer);
             writer.writeEndElement();
           } else if (ALLOW_DIRECT_CONNECTIONS_ONLY.isMarshallable(cluster)) {
             writer.writeEmptyElement(Element.STATIC_CONNECTORS.getLocalName());
             ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
           }
         } else {
           attribute.marshallAsElement(property.getValue(), writer);
         }
       }
       writer.writeEndElement();
     }
     writer.writeEndElement();
     writeNewLine(writer);
   }
 }
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {

    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

    ModelNode node = context.getModelNode();

    writeAttribute(writer, Attribute.NATIVE.getLocalName(), node);
    writeAttribute(writer, Attribute.DEFAULT_VIRTUAL_SERVER.getLocalName(), node);
    writeAttribute(writer, Attribute.INSTANCE_ID.getLocalName(), node);
    if (node.hasDefined(CONTAINER_CONFIG)) {
      writeContainerConfig(writer, node.get(CONTAINER_CONFIG));
    }
    if (node.hasDefined(CONNECTOR)) {
      for (final Property connector : node.get(CONNECTOR).asPropertyList()) {
        final ModelNode config = connector.getValue();
        writer.writeStartElement(Element.CONNECTOR.getLocalName());
        writer.writeAttribute(NAME, connector.getName());
        writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), config);
        writeAttribute(writer, Attribute.SOCKET_BINDING.getLocalName(), config);
        writeAttribute(writer, Attribute.SCHEME.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLED.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLE_LOOKUPS.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_NAME.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_PORT.getLocalName(), config);
        writeAttribute(writer, Attribute.SECURE.getLocalName(), config);
        writeAttribute(writer, Attribute.EXECUTOR.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_SAVE_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_CONNECTIONS.getLocalName(), config);
        writeAttribute(writer, Attribute.REDIRECT_PORT.getLocalName(), config);

        if (config.get(SSL).isDefined() && config.get(SSL).has("configuration")) {
          ModelNode sslConfig = config.get(SSL).get("configuration");
          writer.writeStartElement(Element.SSL.getLocalName());
          writeAttribute(writer, Attribute.NAME.getLocalName(), sslConfig);
          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.VERIFY_CLIENT.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.VERIFY_DEPTH.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_REVOCATION_URL.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_CACHE_SIZE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_TIMEOUT.getLocalName(), sslConfig);
          writer.writeEndElement();
        }
        if (config.hasDefined(VIRTUAL_SERVER)) {
          for (final ModelNode virtualServer : config.get(VIRTUAL_SERVER).asList()) {
            writer.writeEmptyElement(VIRTUAL_SERVER);
            writer.writeAttribute(NAME, virtualServer.asString());
          }
        }

        writer.writeEndElement();
      }
    }
    if (node.hasDefined(VIRTUAL_SERVER)) {
      for (final Property host : node.get(VIRTUAL_SERVER).asPropertyList()) {
        final ModelNode config = host.getValue();
        writer.writeStartElement(Element.VIRTUAL_SERVER.getLocalName());
        writer.writeAttribute(NAME, host.getName());
        writeAttribute(writer, Attribute.DEFAULT_WEB_MODULE.getLocalName(), config);
        if (config.hasDefined(ENABLE_WELCOME_ROOT) && config.get(ENABLE_WELCOME_ROOT).asBoolean())
          writer.writeAttribute(ENABLE_WELCOME_ROOT, "true");

        if (config.hasDefined(ALIAS)) {
          for (final ModelNode alias : config.get(ALIAS).asList()) {
            writer.writeEmptyElement(ALIAS);
            writer.writeAttribute(NAME, alias.asString());
          }
        }

        if (config.get(ACCESS_LOG).isDefined() && config.get(ACCESS_LOG).has("configuration")) {
          ModelNode accessLog = config.get(ACCESS_LOG).get("configuration");
          writer.writeStartElement(Element.ACCESS_LOG.getLocalName());
          writeAttribute(writer, Attribute.PATTERN.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.RESOLVE_HOSTS.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.EXTENDED.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.PREFIX.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.ROTATE.getLocalName(), accessLog);

          if (accessLog.has(DIRECTORY) && accessLog.get(DIRECTORY).has("configuration")) {
            ModelNode directory = accessLog.get(DIRECTORY).get("configuration");
            String name = Element.DIRECTORY.getLocalName();
            boolean startwritten = false;
            startwritten =
                writeAttribute(
                    writer, Attribute.PATH.getLocalName(), directory, startwritten, name);
            startwritten =
                writeAttribute(
                    writer, Attribute.RELATIVE_TO.getLocalName(), directory, startwritten, name);
            if (startwritten) writer.writeEndElement();
          }
          writer.writeEndElement();
        }

        if (config.hasDefined(REWRITE)) {
          for (final ModelNode rewritenode : config.get(REWRITE).asList()) {
            String name = getAddedRule(rewritenode);
            ModelNode rewrite;
            if (rewritenode.hasDefined(name)) rewrite = rewritenode.get(name);
            else rewrite = rewritenode;
            writer.writeStartElement(REWRITE);
            writeAttribute(writer, Attribute.PATTERN.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.SUBSTITUTION.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.FLAGS.getLocalName(), rewrite);

            if (rewrite.hasDefined(CONDITION)) {
              for (final ModelNode conditionnode : rewrite.get(CONDITION).asList()) {
                String condname = getAddedConditionName(conditionnode);
                ModelNode condition;
                if (conditionnode.hasDefined(condname)) condition = conditionnode.get(condname);
                else condition = conditionnode;
                writer.writeStartElement(CONDITION);
                writeAttribute(writer, Attribute.TEST.getLocalName(), condition);
                writeAttribute(writer, Attribute.PATTERN.getLocalName(), condition);
                writeAttribute(writer, Attribute.FLAGS.getLocalName(), condition);
                writer.writeEndElement();
              }
            }
            writer.writeEndElement();
          }
        }

        if (config.hasDefined(SSO) && config.get(SSO).has("configuration")) {
          final ModelNode sso;
          sso = config.get(SSO).get("configuration");
          writer.writeStartElement(SSO);
          writeAttribute(writer, Attribute.CACHE_CONTAINER.getLocalName(), sso);
          writeAttribute(writer, Attribute.CACHE_NAME.getLocalName(), sso);
          writeAttribute(writer, Attribute.DOMAIN.getLocalName(), sso);
          writeAttribute(writer, Attribute.REAUTHENTICATE.getLocalName(), sso);
          writer.writeEndElement();
        }

        // End of the VIRTUAL_SERVER
        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementWriter#writeContent(org.jboss.staxmapper.XMLExtendedStreamWriter,
   *     java.lang.Object)
   */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
    ModelNode model = context.getModelNode();
    if (model.isDefined()) {
      for (Property entry : model.get(ModelKeys.CACHE_CONTAINER).asPropertyList()) {

        String containerName = entry.getName();
        ModelNode container = entry.getValue();

        writer.writeStartElement(Element.CACHE_CONTAINER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), containerName);
        // AS7-3488 make default-cache a non required attribute
        // this.writeRequired(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
        this.writeListAsAttribute(writer, Attribute.ALIASES, container, ModelKeys.ALIASES);
        this.writeOptional(writer, Attribute.ASYNC_EXECUTOR, container, ModelKeys.ASYNC_EXECUTOR);
        this.writeOptional(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
        this.writeOptional(
            writer, Attribute.EVICTION_EXECUTOR, container, ModelKeys.EVICTION_EXECUTOR);
        this.writeOptional(writer, Attribute.JNDI_NAME, container, ModelKeys.JNDI_NAME);
        this.writeOptional(
            writer, Attribute.LISTENER_EXECUTOR, container, ModelKeys.LISTENER_EXECUTOR);
        this.writeOptional(
            writer,
            Attribute.REPLICATION_QUEUE_EXECUTOR,
            container,
            ModelKeys.REPLICATION_QUEUE_EXECUTOR);
        this.writeOptional(
            writer,
            Attribute.STATE_TRANSFER_EXECUTOR,
            container,
            ModelKeys.STATE_TRANSFER_EXECUTOR);
        this.writeOptional(writer, Attribute.START, container, ModelKeys.START);
        this.writeOptional(writer, Attribute.MODULE, container, ModelKeys.MODULE);
        this.writeOptional(writer, Attribute.STATISTICS, container, ModelKeys.STATISTICS);

        if (container.hasDefined(ModelKeys.TRANSPORT)) {
          writer.writeStartElement(Element.TRANSPORT.getLocalName());
          ModelNode transport = container.get(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
          this.writeOptional(writer, Attribute.STACK, transport, ModelKeys.STACK);
          this.writeOptional(writer, Attribute.CLUSTER, transport, ModelKeys.CLUSTER);
          this.writeOptional(writer, Attribute.EXECUTOR, transport, ModelKeys.EXECUTOR);
          this.writeOptional(writer, Attribute.LOCK_TIMEOUT, transport, ModelKeys.LOCK_TIMEOUT);
          this.writeOptional(
              writer,
              Attribute.REMOTE_COMMAND_EXECUTOR,
              transport,
              ModelKeys.REMOTE_COMMAND_EXECUTOR);
          this.writeOptional(
              writer, Attribute.STRICT_PEER_TO_PEER, transport, ModelKeys.STRICT_PEER_TO_PEER);
          this.writeOptional(
              writer, Attribute.TOTAL_ORDER_EXECUTOR, transport, ModelKeys.TOTAL_ORDER_EXECUTOR);
          writer.writeEndElement();
        }

        if (container.hasDefined(ModelKeys.SECURITY)) {
          writer.writeStartElement(Element.SECURITY.getLocalName());
          ModelNode security = container.get(ModelKeys.SECURITY, ModelKeys.SECURITY_NAME);
          if (security.hasDefined(ModelKeys.AUTHORIZATION)) {
            writer.writeStartElement(Element.AUTHORIZATION.getLocalName());
            ModelNode authorization =
                security.get(ModelKeys.AUTHORIZATION, ModelKeys.AUTHORIZATION_NAME);
            if (authorization.hasDefined(ModelKeys.MAPPER)) {
              String mapper = authorization.get(ModelKeys.MAPPER).asString();
              if (CommonNameRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.COMMON_NAME_ROLE_MAPPER.getLocalName());
              } else if (ClusterRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.CLUSTER_ROLE_MAPPER.getLocalName());
              } else if (IdentityRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.IDENTITY_ROLE_MAPPER.getLocalName());
              } else {
                writer.writeStartElement(Element.CUSTOM_ROLE_MAPPER.getLocalName());
                writer.writeAttribute(Attribute.CLASS.getLocalName(), mapper);
                writer.writeEndElement();
              }
            }

            ModelNode roles = authorization.get(ModelKeys.ROLE);
            for (ModelNode roleNode : roles.asList()) {
              ModelNode role = roleNode.get(0);
              writer.writeStartElement(Element.ROLE.getLocalName());
              AuthorizationRoleResource.NAME.marshallAsAttribute(role, writer);
              this.writeListAsAttribute(writer, Attribute.PERMISSIONS, role, ModelKeys.PERMISSIONS);
              writer.writeEndElement();
            }

            writer.writeEndElement();
          }

          writer.writeEndElement();
        }

        // write any existent cache types
        if (container.get(ModelKeys.LOCAL_CACHE).isDefined()) {
          for (Property localCacheEntry : container.get(ModelKeys.LOCAL_CACHE).asPropertyList()) {
            String localCacheName = localCacheEntry.getName();
            ModelNode localCache = localCacheEntry.getValue();

            writer.writeStartElement(Element.LOCAL_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), localCacheName);

            processCommonCacheAttributesElements(writer, localCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.INVALIDATION_CACHE).isDefined()) {
          for (Property invalidationCacheEntry :
              container.get(ModelKeys.INVALIDATION_CACHE).asPropertyList()) {
            String invalidationCacheName = invalidationCacheEntry.getName();
            ModelNode invalidationCache = invalidationCacheEntry.getValue();

            writer.writeStartElement(Element.INVALIDATION_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), invalidationCacheName);

            processCommonClusteredCacheAttributes(writer, invalidationCache);
            processCommonCacheAttributesElements(writer, invalidationCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.REPLICATED_CACHE).isDefined()) {
          for (Property replicatedCacheEntry :
              container.get(ModelKeys.REPLICATED_CACHE).asPropertyList()) {
            String replicatedCacheName = replicatedCacheEntry.getName();
            ModelNode replicatedCache = replicatedCacheEntry.getValue();

            writer.writeStartElement(Element.REPLICATED_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), replicatedCacheName);

            processCommonClusteredCacheAttributes(writer, replicatedCache);
            processCommonCacheAttributesElements(writer, replicatedCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.DISTRIBUTED_CACHE).isDefined()) {
          for (Property distributedCacheEntry :
              container.get(ModelKeys.DISTRIBUTED_CACHE).asPropertyList()) {
            String distributedCacheName = distributedCacheEntry.getName();
            ModelNode distributedCache = distributedCacheEntry.getValue();

            writer.writeStartElement(Element.DISTRIBUTED_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), distributedCacheName);
            // distributed cache attributes
            this.writeOptional(writer, Attribute.OWNERS, distributedCache, ModelKeys.OWNERS);
            this.writeOptional(writer, Attribute.SEGMENTS, distributedCache, ModelKeys.SEGMENTS);
            this.writeOptional(
                writer, Attribute.CAPACITY_FACTOR, distributedCache, ModelKeys.CAPACITY_FACTOR);
            this.writeOptional(
                writer, Attribute.L1_LIFESPAN, distributedCache, ModelKeys.L1_LIFESPAN);

            processCommonClusteredCacheAttributes(writer, distributedCache);
            processCommonCacheAttributesElements(writer, distributedCache);

            writer.writeEndElement();
          }
        }
        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }
  private void writeConDef(
      XMLExtendedStreamWriter streamWriter,
      ModelNode conDef,
      final String poolName,
      final boolean isXa)
      throws XMLStreamException {
    streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITION.getLocalName());
    CLASS_NAME.marshallAsAttribute(conDef, streamWriter);
    JNDINAME.marshallAsAttribute(conDef, streamWriter);
    ENABLED.marshallAsAttribute(conDef, streamWriter);
    CONNECTABLE.marshallAsAttribute(conDef, streamWriter);
    TRACKING.marshallAsAttribute(conDef, streamWriter);
    USE_JAVA_CONTEXT.marshallAsAttribute(conDef, streamWriter);
    streamWriter.writeAttribute("pool-name", poolName);
    USE_CCM.marshallAsAttribute(conDef, streamWriter);
    SHARABLE.marshallAsAttribute(conDef, streamWriter);
    ENLISTMENT.marshallAsAttribute(conDef, streamWriter);

    writeNewConfigProperties(streamWriter, conDef);

    boolean poolRequired =
        INITIAL_POOL_SIZE.isMarshallable(conDef)
            || MAX_POOL_SIZE.isMarshallable(conDef)
            || MIN_POOL_SIZE.isMarshallable(conDef)
            || POOL_USE_STRICT_MIN.isMarshallable(conDef)
            || POOL_PREFILL.isMarshallable(conDef)
            || POOL_FLUSH_STRATEGY.isMarshallable(conDef);
    final boolean capacityRequired =
        CAPACITY_INCREMENTER_CLASS.isMarshallable(conDef)
            || CAPACITY_INCREMENTER_PROPERTIES.isMarshallable(conDef)
            || CAPACITY_DECREMENTER_CLASS.isMarshallable(conDef)
            || CAPACITY_DECREMENTER_PROPERTIES.isMarshallable(conDef);
    poolRequired = poolRequired || capacityRequired;

    if (poolRequired) {
      if (isXa) {

        streamWriter.writeStartElement(ConnectionDefinition.Tag.XA_POOL.getLocalName());
        MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        INITIAL_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        POOL_PREFILL.marshallAsElement(conDef, streamWriter);
        POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
        POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);

        SAME_RM_OVERRIDE.marshallAsElement(conDef, streamWriter);
        if (conDef.hasDefined(INTERLEAVING.getName())
            && conDef.get(INTERLEAVING.getName()).asBoolean()) {
          streamWriter.writeEmptyElement(INTERLEAVING.getXmlName());
        } else {
          INTERLEAVING.marshallAsElement(conDef, streamWriter);
        }
        if (conDef.hasDefined(NOTXSEPARATEPOOL.getName())
            && conDef.get(NOTXSEPARATEPOOL.getName()).asBoolean()) {
          streamWriter.writeEmptyElement(NOTXSEPARATEPOOL.getXmlName());
        } else {
          NOTXSEPARATEPOOL.marshallAsElement(conDef, streamWriter);
        }
        PAD_XID.marshallAsElement(conDef, streamWriter);
        WRAP_XA_RESOURCE.marshallAsElement(conDef, streamWriter);

      } else {
        streamWriter.writeStartElement(ConnectionDefinition.Tag.POOL.getLocalName());
        MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        INITIAL_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
        POOL_PREFILL.marshallAsElement(conDef, streamWriter);
        POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
        POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);
      }
      if (capacityRequired) {
        streamWriter.writeStartElement(Pool.Tag.CAPACITY.getLocalName());
        if (conDef.hasDefined(CAPACITY_INCREMENTER_CLASS.getName())) {
          streamWriter.writeStartElement(Capacity.Tag.INCREMENTER.getLocalName());
          CAPACITY_INCREMENTER_CLASS.marshallAsAttribute(conDef, streamWriter);
          CAPACITY_INCREMENTER_PROPERTIES.marshallAsElement(conDef, streamWriter);

          streamWriter.writeEndElement();
        }
        if (conDef.hasDefined(CAPACITY_DECREMENTER_CLASS.getName())) {
          streamWriter.writeStartElement(Capacity.Tag.DECREMENTER.getLocalName());
          CAPACITY_DECREMENTER_CLASS.marshallAsAttribute(conDef, streamWriter);
          CAPACITY_DECREMENTER_PROPERTIES.marshallAsElement(conDef, streamWriter);

          streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
      }
      streamWriter.writeEndElement();
    }

    if (conDef.hasDefined(APPLICATION.getName())
        || conDef.hasDefined(SECURITY_DOMAIN.getName())
        || conDef.hasDefined(SECURITY_DOMAIN_AND_APPLICATION.getName())) {
      streamWriter.writeStartElement(ConnectionDefinition.Tag.SECURITY.getLocalName());
      if (conDef.hasDefined(APPLICATION.getName())
          && conDef.get(APPLICATION.getName()).asBoolean()) {
        streamWriter.writeEmptyElement(APPLICATION.getXmlName());
      } else {
        APPLICATION.marshallAsElement(conDef, streamWriter);
      }
      SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
      SECURITY_DOMAIN_AND_APPLICATION.marshallAsElement(conDef, streamWriter);

      streamWriter.writeEndElement();
    }

    if (conDef.hasDefined(BLOCKING_TIMEOUT_WAIT_MILLIS.getName())
        || conDef.hasDefined(IDLETIMEOUTMINUTES.getName())
        || conDef.hasDefined(ALLOCATION_RETRY.getName())
        || conDef.hasDefined(ALLOCATION_RETRY_WAIT_MILLIS.getName())
        || conDef.hasDefined(XA_RESOURCE_TIMEOUT.getName())) {
      streamWriter.writeStartElement(ConnectionDefinition.Tag.TIMEOUT.getLocalName());
      BLOCKING_TIMEOUT_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
      IDLETIMEOUTMINUTES.marshallAsElement(conDef, streamWriter);
      ALLOCATION_RETRY.marshallAsElement(conDef, streamWriter);
      ALLOCATION_RETRY_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
      XA_RESOURCE_TIMEOUT.marshallAsElement(conDef, streamWriter);
      streamWriter.writeEndElement();
    }

    if (conDef.hasDefined(BACKGROUNDVALIDATION.getName())
        || conDef.hasDefined(BACKGROUNDVALIDATIONMILLIS.getName())
        || conDef.hasDefined(USE_FAST_FAIL.getName())
        || conDef.hasDefined(VALIDATE_ON_MATCH.getName())) {
      streamWriter.writeStartElement(ConnectionDefinition.Tag.VALIDATION.getLocalName());
      BACKGROUNDVALIDATION.marshallAsElement(conDef, streamWriter);
      BACKGROUNDVALIDATIONMILLIS.marshallAsElement(conDef, streamWriter);
      USE_FAST_FAIL.marshallAsElement(conDef, streamWriter);
      VALIDATE_ON_MATCH.marshallAsElement(conDef, streamWriter);
      streamWriter.writeEndElement();
    }

    if (conDef.hasDefined(RECOVERY_USERNAME.getName())
        || conDef.hasDefined(RECOVERY_PASSWORD.getName())
        || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName())
        || conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName())
        || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())
        || conDef.hasDefined(NO_RECOVERY.getName())) {

      streamWriter.writeStartElement(ConnectionDefinition.Tag.RECOVERY.getLocalName());
      NO_RECOVERY.marshallAsAttribute(conDef, streamWriter);

      if (conDef.hasDefined(RECOVERY_USERNAME.getName())
          || conDef.hasDefined(RECOVERY_PASSWORD.getName())
          || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName())) {
        streamWriter.writeStartElement(Recovery.Tag.RECOVER_CREDENTIAL.getLocalName());
        RECOVERY_USERNAME.marshallAsElement(conDef, streamWriter);
        RECOVERY_PASSWORD.marshallAsElement(conDef, streamWriter);
        RECOVERY_SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
      }
      if (conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName())
          || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
        streamWriter.writeStartElement(Recovery.Tag.RECOVER_PLUGIN.getLocalName());
        RECOVERLUGIN_CLASSNAME.marshallAsAttribute(conDef, streamWriter);
        if (conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
          for (Property property : conDef.get(RECOVERLUGIN_PROPERTIES.getName()).asPropertyList()) {
            writeProperty(
                streamWriter,
                conDef,
                property.getName(),
                property.getValue().asString(),
                org.jboss.jca.common.api.metadata.common.Extension.Tag.CONFIG_PROPERTY
                    .getLocalName());
          }
        }
        streamWriter.writeEndElement();
      }
      streamWriter.writeEndElement();
    }

    streamWriter.writeEndElement();
  }