private void writeIndexProviders(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    if (has(repository, ModelKeys.INDEX_PROVIDER)) {
      writer.writeStartElement(Element.INDEX_PROVIDERS.getLocalName());
      ModelNode providerNode = repository.get(ModelKeys.INDEX_PROVIDER);
      for (Property provider : providerNode.asPropertyList()) {
        writer.writeStartElement(Element.INDEX_PROVIDER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), provider.getName());
        ModelNode prop = provider.getValue();
        ModelAttributes.CLASSNAME.marshallAsAttribute(prop, writer);
        ModelAttributes.MODULE.marshallAsAttribute(prop, writer);
        ModelAttributes.RELATIVE_TO.marshallAsAttribute(prop, writer);
        ModelAttributes.PATH.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();
    }
  }
 /* (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));
   }
 }
  private void writeIndexes(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    if (has(repository, ModelKeys.INDEX)) {
      writer.writeStartElement(Element.INDEXES.getLocalName());
      ModelNode providerNode = repository.get(ModelKeys.INDEX);
      for (Property index : providerNode.asPropertyList()) {
        writer.writeStartElement(Element.INDEX.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), index.getName());
        ModelNode prop = index.getValue();
        ModelAttributes.PROVIDER_NAME.marshallAsAttribute(prop, writer);
        ModelAttributes.INDEX_KIND.marshallAsAttribute(prop, writer);
        ModelAttributes.SYNCHRONOUS.marshallAsAttribute(prop, writer);
        ModelAttributes.NODE_TYPE_NAME.marshallAsAttribute(prop, writer);
        ModelAttributes.INDEX_COLUMNS.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();
    }
  }
  private static void writeChildren(
      final XMLExtendedStreamWriter writer, final Collection<DistributionContentItem> items)
      throws XMLStreamException {
    if (items == null || items.size() == 0) {
      return;
    }

    for (final DistributionContentItem item : items) {

      writer.writeStartElement(Element.NODE.name);
      writer.writeAttribute(Attribute.NAME.name, item.getName());
      if (item.isLeaf()) {
        writer.writeAttribute(
            Attribute.COMPARISON_HASH.name, HashUtils.bytesToHexString(item.getComparisonHash()));
        writer.writeAttribute(
            Attribute.METADATA_HASH.name, HashUtils.bytesToHexString(item.getMetadataHash()));
      }
      writer.writeAttribute(Attribute.DIRECTORY.name, String.valueOf(!item.isLeaf()));

      // Recurse
      final Collection<DistributionContentItem> children = item.getChildren();
      writeChildren(writer, children);

      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();
    }
  }
 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);
   }
 }
 /* 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();
 }
Beispiel #8
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 writeSequencing(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    if (has(repository, ModelKeys.SEQUENCER)) {
      writer.writeStartElement(Element.SEQUENCERS.getLocalName());
      if (repository.hasDefined(ModelKeys.SEQUENCERS_THREAD_POOL_NAME)) {
        writer.writeAttribute(
            Attribute.THREAD_POOL_NAME.getLocalName(),
            repository.get(ModelKeys.SEQUENCERS_THREAD_POOL_NAME).asString());
      }
      if (repository.hasDefined(ModelKeys.SEQUENCERS_MAX_POOL_SIZE)) {
        writer.writeAttribute(
            Attribute.MAX_POOL_SIZE.getLocalName(),
            repository.get(ModelKeys.SEQUENCERS_MAX_POOL_SIZE).asString());
      }

      ModelNode sequencerNode = repository.get(ModelKeys.SEQUENCER);

      for (Property sequencer : sequencerNode.asPropertyList()) {
        writer.writeStartElement(Element.SEQUENCER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), sequencer.getName());
        ModelNode prop = sequencer.getValue();
        ModelAttributes.SEQUENCER_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());
          }
        }
        if (has(prop, ModelKeys.PATH_EXPRESSIONS)) {
          List<ModelNode> pathExpressions = prop.get(ModelKeys.PATH_EXPRESSIONS).asList();
          switch (pathExpressions.size()) {
            case 0:
              break;
            case 1:
              ModelNode pathExpression = pathExpressions.iterator().next();
              writer.writeAttribute(
                  Attribute.PATH_EXPRESSION.getLocalName(), pathExpression.asString());
              break;
            default:
              for (ModelNode pathExpr : pathExpressions) {
                writer.writeStartElement(Element.PATH_EXPRESSION.getLocalName());
                writer.writeCharacters(pathExpr.asString());
                writer.writeEndElement();
              }
          }
        }
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
  }
Beispiel #10
0
  private void writeServerGroup(
      final XMLExtendedStreamWriter writer, final String groupName, final ModelNode group)
      throws XMLStreamException {
    writer.writeStartElement(Element.SERVER_GROUP.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), groupName);
    writer.writeAttribute(Attribute.PROFILE.getLocalName(), group.get(PROFILE).asString());

    // JVM
    if (group.hasDefined(JVM)) {
      for (final Property jvm : group.get(JVM).asPropertyList()) {
        JvmXml.writeJVMElement(writer, jvm.getName(), jvm.getValue());
        break; // TODO just write the first !?
      }
    }

    // Socket binding ref
    String bindingGroupRef =
        group.hasDefined(SOCKET_BINDING_GROUP) ? group.get(SOCKET_BINDING_GROUP).asString() : null;
    String portOffset =
        group.hasDefined(SOCKET_BINDING_PORT_OFFSET)
            ? group.get(SOCKET_BINDING_PORT_OFFSET).asString()
            : null;
    Boolean managementSubsystemEndpoint =
        group.hasDefined(MANAGEMENT_SUBSYSTEM_ENDPOINT)
            ? group.get(MANAGEMENT_SUBSYSTEM_ENDPOINT).asBoolean()
            : null;
    if (bindingGroupRef != null || portOffset != null) {
      writer.writeStartElement(Element.SOCKET_BINDING_GROUP.getLocalName());
      if (bindingGroupRef != null) {
        writeAttribute(writer, Attribute.REF, bindingGroupRef);
      }
      if (portOffset != null) {
        writeAttribute(writer, Attribute.PORT_OFFSET, portOffset);
      }
      if (managementSubsystemEndpoint != null) {
        writeAttribute(
            writer,
            Attribute.MANAGEMENT_SUBSYSTEM_ENDPOINT,
            managementSubsystemEndpoint.toString());
      }
      writer.writeEndElement();
    }

    if (group.hasDefined(DEPLOYMENT)) {
      writeServerGroupDeployments(writer, group.get(DEPLOYMENT));
    }
    // System properties
    if (group.hasDefined(SYSTEM_PROPERTY)) {
      writeProperties(writer, group.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
    }

    writer.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()));
 }
 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();
     }
   }
 }
 static void writeAttribute(
     final XMLExtendedStreamWriter writer, final String name, ModelNode node)
     throws XMLStreamException {
   if (node.hasDefined(name)) {
     writer.writeAttribute(name, node.get(name).asString());
   }
 }
 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();
 }
  private static void writeLayer(
      final XMLExtendedStreamWriter writer,
      final Distribution.ProcessedLayer layer,
      final Element element)
      throws XMLStreamException {

    writer.writeStartElement(element.name);
    writer.writeAttribute(Attribute.NAME.name, layer.getName());

    final Set<DistributionModuleItem> bundles = layer.getBundles();
    final Set<DistributionModuleItem> modules = layer.getModules();

    if (!bundles.isEmpty()) {
      writer.writeStartElement(Element.BUNDLES.name);
      for (final DistributionModuleItem item : bundles) {
        writeModuleItem(writer, item, Element.BUNDLE);
      }
      writer.writeEndElement();
    }
    if (!modules.isEmpty()) {
      writer.writeStartElement(Element.MODULES.name);
      for (final DistributionModuleItem item : modules) {
        writeModuleItem(writer, item, Element.MODULE);
      }
      writer.writeEndElement();
    }
    writer.writeEndElement();
  }
  private void writeJmsBridge(XMLExtendedStreamWriter writer, String bridgeName, ModelNode value)
      throws XMLStreamException {
    writer.writeStartElement(Element.JMS_BRIDGE.getLocalName());

    if (!DEFAULT.equals(bridgeName)) {
      writer.writeAttribute(Attribute.NAME.getLocalName(), bridgeName);
    }

    JMSBridgeDefinition.MODULE.marshallAsAttribute(value, writer);

    writer.writeStartElement(SOURCE.getLocalName());
    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_SOURCE_ATTRIBUTES) {
      attr.marshallAsElement(value, writer);
    }
    writer.writeEndElement();

    writer.writeStartElement(TARGET.getLocalName());
    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_TARGET_ATTRIBUTES) {
      attr.marshallAsElement(value, writer);
    }
    writer.writeEndElement();

    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_BRIDGE_ATTRIBUTES) {
      if (attr == JMSBridgeDefinition.MODULE) {
        // handled as a XML attribute
        continue;
      }
      attr.marshallAsElement(value, writer);
    }

    writer.writeEndElement();
  }
 @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 writeOptional(
     XMLExtendedStreamWriter writer, Attribute attribute, ModelNode model, String key)
     throws XMLStreamException {
   if (model.hasDefined(key)) {
     writer.writeAttribute(attribute.getLocalName(), model.get(key).asString());
   }
 }
 // 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());
   }
 }
 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();
 }
    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 static void writePermission(
     final XMLExtendedStreamWriter writer, final String type, final List<String> roles)
     throws XMLStreamException {
   if (roles.size() == 0) {
     return;
   }
   writer.writeStartElement(Element.PERMISSION_ELEMENT_NAME.getLocalName());
   StringBuilder sb = new StringBuilder();
   for (String role : roles) {
     if (sb.length() > 0) {
       sb.append(" ");
     }
     sb.append(role);
   }
   writer.writeAttribute(Attribute.TYPE_ATTR_NAME.getLocalName(), type);
   writer.writeAttribute(Attribute.ROLES_ATTR_NAME.getLocalName(), sb.toString());
   writer.writeEndElement();
 }
  private void writeLocalOutboundConnection(
      final XMLExtendedStreamWriter writer, final String connectionName, final ModelNode model)
      throws XMLStreamException {
    // <local-outbound-connection>
    writer.writeStartElement(Element.LOCAL_OUTBOUND_CONNECTION.getLocalName());

    writer.writeAttribute(Attribute.NAME.getLocalName(), connectionName);

    final String outboundSocketRef = model.get(OUTBOUND_SOCKET_BINDING_REF).asString();
    writer.writeAttribute(Attribute.OUTBOUND_SOCKET_BINDING_REF.getLocalName(), outboundSocketRef);

    // write the connection-creation-options if any
    if (model.hasDefined(CommonAttributes.CONNECTION_CREATION_OPTIONS)) {
      this.writeConnectionCreationOptions(writer, model);
    }

    // </local-outbound-connection>
    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 writeOutboundConnection(
      final XMLExtendedStreamWriter writer, final String connectionName, final ModelNode model)
      throws XMLStreamException {
    // <outbound-connection>
    writer.writeStartElement(Element.OUTBOUND_CONNECTION.getLocalName());

    writer.writeAttribute(Attribute.NAME.getLocalName(), connectionName);

    final String uri = model.get(URI).asString();
    writer.writeAttribute(Attribute.URI.getLocalName(), uri);

    // write the connection-creation-options if any
    if (model.hasDefined(CommonAttributes.CONNECTION_CREATION_OPTIONS)) {
      this.writeConnectionCreationOptions(writer, model);
    }

    // </outbound-connection>
    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();
    }
  }
Beispiel #27
0
 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();
   }
 }
 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 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 static void writeAcceptorContent(
      final XMLExtendedStreamWriter writer, final Property property) throws XMLStreamException {
    writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    final ModelNode value = property.getValue();

    RemoteTransportDefinition.SOCKET_BINDING.marshallAsAttribute(value, writer);
    InVMTransportDefinition.SERVER_ID.marshallAsAttribute(value, writer);
    CommonAttributes.FACTORY_CLASS.marshallAsElement(value, writer);

    writeTransportParam(writer, value.get(PARAM));
  }