Пример #1
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();
  }
Пример #2
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);
   }
 }
Пример #3
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);
   }
 }
  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 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 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();
    }
  }
Пример #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();
  }
 @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 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();
    }
  }
Пример #10
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 writeStartElement(
     XMLExtendedStreamWriter writer, String namespaceURI, String localName)
     throws XMLStreamException {
   if (namespaceURI != null) {
     writer.writeStartElement(namespaceURI, localName);
   } else {
     writer.writeStartElement(localName);
   }
 }
  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 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 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();
    }
  }
Пример #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();
  }
Пример #16
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();
      }
    }
  }
Пример #17
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();
      }
    }
  }
Пример #18
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();
    }
  }
Пример #19
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();
 }
 /* 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();
 }
Пример #21
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();
    }
 private boolean startIfNeeded(
     XMLExtendedStreamWriter writer, Element name, boolean alreadyStarted)
     throws XMLStreamException {
   if (!alreadyStarted) {
     writer.writeStartElement(name.getLocalName());
   }
   return true;
 }
 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();
 }
  /** {@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();
  }
Пример #25
0
 private void writeRef(
     final XMLExtendedStreamWriter writer, final ModelNode node, Element element, String name)
     throws XMLStreamException {
   if (node.hasDefined(name)) {
     writer.writeStartElement(element.getLocalName());
     writeAttribute(writer, Attribute.NAME, node.get(name));
     writer.writeEndElement();
   }
 }
 private void writeStoreCompression(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.get(ModelKeys.COMPRESSION, ModelKeys.COMPRESSION_NAME).isDefined()) {
     ModelNode compression = store.get(ModelKeys.COMPRESSION, ModelKeys.COMPRESSION_NAME);
     writer.writeStartElement(Element.COMPRESSION.getLocalName());
     this.writeOptional(writer, Attribute.TYPE, compression, ModelKeys.TYPE);
     writer.writeEndElement();
   }
 }
 private void 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();
    }
Пример #29
0
  private void writeValidation(XMLExtendedStreamWriter streamWriter, Validation validation)
      throws XMLStreamException {
    if (validation != null) {
      if (validation.getValidConnectionCheckerClassName() != null) {
        streamWriter.writeStartElement(
            Validation.Tag.VALIDCONNECTIONCHECKERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getValidConnectionCheckerClassName());
        streamWriter.writeEndElement();
      }

      if (validation.getCheckValidConnectionSql() != null) {
        streamWriter.writeStartElement(Validation.Tag.CHECKVALIDCONNECTIONSQL.getLocalName());
        streamWriter.writeCharacters(validation.getCheckValidConnectionSql());
        streamWriter.writeEndElement();
      }

      if (validation.isValidateOnMatch() != null) {
        streamWriter.writeStartElement(Validation.Tag.VALIDATEONMATCH.getLocalName());
        streamWriter.writeCharacters(validation.isValidateOnMatch().toString());
        streamWriter.writeEndElement();
      }

      if (validation.isBackgroundValidation() != null) {
        streamWriter.writeStartElement(Validation.Tag.BACKGROUNDVALIDATION.getLocalName());
        streamWriter.writeCharacters(validation.isBackgroundValidation().toString());
        streamWriter.writeEndElement();
      }

      if (validation.getBackgroundValidationMinutes() != null) {
        streamWriter.writeStartElement(Validation.Tag.BACKGROUNDVALIDATIONMINUTES.getLocalName());
        streamWriter.writeCharacters(validation.getBackgroundValidationMinutes().toString());
        streamWriter.writeEndElement();
      }

      if (validation.isUseFastFail() != null) {
        streamWriter.writeStartElement(Validation.Tag.USEFASTFAIL.getLocalName());
        streamWriter.writeCharacters(validation.isUseFastFail().toString());
        streamWriter.writeEndElement();
      }

      if (validation.getStaleConnectionCheckerClassName() != null) {
        streamWriter.writeStartElement(
            Validation.Tag.STALECONNECTIONCHECKERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getStaleConnectionCheckerClassName());
        streamWriter.writeEndElement();
      }

      if (validation.getExceptionSorterClassName() != null) {
        streamWriter.writeStartElement(Validation.Tag.EXCEPTIONSORTERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getExceptionSorterClassName().toString());
        streamWriter.writeEndElement();
      }
    }
  }
Пример #30
0
 private boolean writeJspConfigAttribute(
     XMLExtendedStreamWriter writer,
     String attribute,
     ModelNode config,
     boolean startWritten,
     boolean containerConfigStartWritten)
     throws XMLStreamException {
   if (DefaultJspConfig.hasNotDefault(config, attribute)) {
     if (!startWritten) {
       if (!containerConfigStartWritten) {
         writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       }
       writer.writeStartElement(Element.JSP_CONFIGURATION.getLocalName());
     }
     writer.writeAttribute(attribute, config.get(attribute).asString());
     return true;
   }
   return false;
 }