private void writePool(XMLExtendedStreamWriter streamWriter, CommonPool pool)
      throws XMLStreamException {
    if (pool != null) {
      if (pool.getMinPoolSize() != null) {
        streamWriter.writeStartElement(CommonPool.Tag.MIN_POOL_SIZE.getLocalName());
        streamWriter.writeCharacters(pool.getMinPoolSize().toString());
        streamWriter.writeEndElement();
      }

      if (pool.getMaxPoolSize() != null) {
        streamWriter.writeStartElement(CommonPool.Tag.MAXPOOLSIZE.getLocalName());
        streamWriter.writeCharacters(pool.getMaxPoolSize().toString());
        streamWriter.writeEndElement();
      }

      if (pool.isPrefill() != null) {
        streamWriter.writeStartElement(CommonPool.Tag.PREFILL.getLocalName());
        streamWriter.writeCharacters(pool.isPrefill().toString());
        streamWriter.writeEndElement();
      }

      if (pool.isUseStrictMin() != null) {
        streamWriter.writeStartElement(CommonPool.Tag.USE_STRICT_MIN.getLocalName());
        streamWriter.writeCharacters(pool.isUseStrictMin().toString());
        streamWriter.writeEndElement();
      }
    }
  }
  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();
    }
  }
  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 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();
    }
  }
Exemplo n.º 5
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);
   }
 }
Exemplo n.º 6
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);
   }
 }
Exemplo n.º 7
0
  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();
  }
Exemplo n.º 8
0
  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();
   }
 }
  /** {@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 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 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();
    }
  }
 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();
 }
Exemplo n.º 14
0
  private void writeXaPool(XMLExtendedStreamWriter streamWriter, CommonXaPool xaPool)
      throws XMLStreamException {
    if (xaPool != null) {
      if (xaPool.getMinPoolSize() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.MIN_POOL_SIZE.getLocalName());
        streamWriter.writeCharacters(xaPool.getMinPoolSize().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.getMaxPoolSize() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.MAXPOOLSIZE.getLocalName());
        streamWriter.writeCharacters(xaPool.getMaxPoolSize().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isPrefill() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.PREFILL.getLocalName());
        streamWriter.writeCharacters(xaPool.isPrefill().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isUseStrictMin() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.USE_STRICT_MIN.getLocalName());
        streamWriter.writeCharacters(xaPool.isUseStrictMin().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isSameRmOverride() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.ISSAMERMOVERRIDEVALUE.getLocalName());
        streamWriter.writeCharacters(xaPool.isSameRmOverride().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isInterleaving() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.INTERLEAVING.getLocalName());
        streamWriter.writeCharacters(xaPool.isInterleaving().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isNoTxSeparatePool() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.NO_TX_SEPARATE_POOLS.getLocalName());
        streamWriter.writeCharacters(xaPool.isNoTxSeparatePool().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isPadXid() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.PAD_XID.getLocalName());
        streamWriter.writeCharacters(xaPool.isPadXid().toString());
        streamWriter.writeEndElement();
      }

      if (xaPool.isWrapXaDataSource() != null) {
        streamWriter.writeStartElement(CommonXaPool.Tag.WRAP_XA_RESOURCE.getLocalName());
        streamWriter.writeCharacters(xaPool.isWrapXaDataSource().toString());
        streamWriter.writeEndElement();
      }
    }
  }
Exemplo n.º 15
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();
  }
  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 writeNodeTypes(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    boolean started = false;

    if (has(repository, ModelKeys.NODE_TYPES)) {
      started = startIfNeeded(writer, Element.NODE_TYPES, started);
      List<ModelNode> nodeTypes = repository.get(ModelKeys.NODE_TYPES).asList();
      for (ModelNode nodeType : nodeTypes) {
        writer.writeStartElement(Element.NODE_TYPE.getLocalName());
        writer.writeCharacters(nodeType.asString());
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
  }
Exemplo n.º 18
0
  private void writeSecurity(XMLExtendedStreamWriter streamWriter, CommonSecurity security)
      throws XMLStreamException {
    if (security != null) {
      if (security.getUserName() != null) {
        streamWriter.writeStartElement(CommonSecurity.Tag.USERNAME.getLocalName());
        streamWriter.writeCharacters(security.getUserName());
        streamWriter.writeEndElement();
      }

      if (security.getPassword() != null) {
        streamWriter.writeStartElement(CommonSecurity.Tag.PASSWORD.getLocalName());
        streamWriter.writeCharacters(security.getPassword());
        streamWriter.writeEndElement();
      }
    }
  }
 private void writeJournaling(XMLExtendedStreamWriter writer, ModelNode repository)
     throws XMLStreamException {
   boolean started = false;
   // Write these model attributes of 'repository' onto the 'journaling' XML element ...
   if (ModelAttributes.JOURNAL_PATH.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.JOURNAL_PATH.marshallAsAttribute(repository, writer);
   }
   if (ModelAttributes.JOURNAL_RELATIVE_TO.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.JOURNAL_RELATIVE_TO.marshallAsAttribute(repository, writer);
   }
   if (ModelAttributes.MAX_DAYS_TO_KEEP_RECORDS.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.MAX_DAYS_TO_KEEP_RECORDS.marshallAsAttribute(repository, writer);
   }
   if (ModelAttributes.ASYNC_WRITES.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.ASYNC_WRITES.marshallAsAttribute(repository, writer);
   }
   if (ModelAttributes.JOURNAL_GC_INITIAL_TIME.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.JOURNAL_GC_INITIAL_TIME.marshallAsAttribute(repository, writer);
   }
   if (ModelAttributes.JOURNAL_GC_THREAD_POOL.isMarshallable(repository, false)) {
     started = startIfNeeded(writer, Element.JOURNALING, started);
     ModelAttributes.JOURNAL_GC_THREAD_POOL.marshallAsAttribute(repository, writer);
   }
   if (started) {
     writer.writeEndElement();
   }
 }
 /* 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();
 }
Exemplo n.º 21
0
  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();
    }
  }
 @Override
 public void writeContent(
     XMLExtendedStreamWriter streamWriter, SubsystemMarshallingContext context)
     throws XMLStreamException {
   context.startSubsystemElement(namespace, false);
   streamWriter.writeEndElement();
 }
Exemplo n.º 23
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();
    }
Exemplo n.º 24
0
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(CURRENT.getUriString(), false);
    final ModelNode node = context.getModelNode();

    if (node.hasDefined(HORNETQ_SERVER)) {
      final ModelNode servers = node.get(HORNETQ_SERVER);
      boolean first = true;
      for (Property prop : servers.asPropertyList()) {
        writeHornetQServer(writer, prop.getName(), prop.getValue());
        if (!first) {
          writeNewLine(writer);
        } else {
          first = false;
        }
      }
    }

    if (node.hasDefined(JMS_BRIDGE)) {
      final ModelNode jmsBridges = node.get(JMS_BRIDGE);
      boolean first = true;
      for (Property prop : jmsBridges.asPropertyList()) {
        writeJmsBridge(writer, prop.getName(), prop.getValue());
        if (!first) {
          writeNewLine(writer);
        } else {
          first = false;
        }
      }
    }
    writer.writeEndElement();
  }
Exemplo n.º 25
0
 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 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();
 }
Exemplo n.º 27
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();
   }
 }
Exemplo n.º 28
0
 /** {@inheritDoc} */
 @Override
 public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
     throws XMLStreamException {
   // TODO seems to be a problem with empty elements cleaning up the queue in
   // FormattingXMLStreamWriter.runAttrQueue
   // context.startSubsystemElement(NewNamingExtension.NAMESPACE, true);
   context.startSubsystemElement(NamingExtension.NAMESPACE, false);
   writer.writeEndElement();
 }
 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();
   }
 }
    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();
    }