org.jboss.as.controller.persistence.SubsystemMarshallingContext Java Examples

The following examples show how to use org.jboss.as.controller.persistence.SubsystemMarshallingContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BpmPlatformParser1_1.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void writeJobAcquisitionsContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context, ModelNode parentNode) throws XMLStreamException {
  writer.writeStartElement(Element.JOB_AQUISITIONS.getLocalName());

  ModelNode jobAcquisitionConfigurations = parentNode.get(Element.JOB_AQUISITIONS.getLocalName());
  if (jobAcquisitionConfigurations.isDefined()) {

    for (Property property : jobAcquisitionConfigurations.asPropertyList()) {
      // write each child element to xml
      writer.writeStartElement(Element.JOB_AQUISITION.getLocalName());

      for (AttributeDefinition jobAcquisitionAttribute : SubsystemAttributeDefinitons.JOB_ACQUISITION_ATTRIBUTES) {
        if (jobAcquisitionAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
          ((SimpleAttributeDefinition) jobAcquisitionAttribute).marshallAsAttribute(property.getValue(), writer);
        } else {
          jobAcquisitionAttribute.marshallAsElement(property.getValue(), writer);
        }
      }

      writer.writeEndElement();
    }
  }
  // end job-acquisitions
  writer.writeEndElement();
}
 
Example #2
Source File: CamelSubsystemWriter.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode node = context.getModelNode();

    if (node.hasDefined(ModelConstants.CONTEXT)) {
        ModelNode properties = node.get(ModelConstants.CONTEXT);
        for (String key : new TreeSet<String>(properties.keys())) {
            String val = properties.get(key).get(ModelConstants.VALUE).asString();
            writer.writeStartElement(Element.CAMEL_CONTEXT.getLocalName());
            writer.writeAttribute(Attribute.ID.getLocalName(), key);
            writer.writeCharacters(val);
            writer.writeEndElement();
        }
    }

    writer.writeEndElement();
}
 
Example #3
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {

    String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    try {
        ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
        if (subsystems.has(mainSubsystemName)) {
            ModelNode subsystem = subsystems.get(mainSubsystemName);
            //We might have been removed
            XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(mainSubsystemName);
            if (subsystemWriter != null) {
                subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
            }
        }else{
            writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
        }
    }catch (Throwable t){
        Assert.fail("could not marshal subsystem xml: "+t.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
    } finally {
        writer.setDefaultNamespace(defaultNamespace);
    }
    writer.writeEndDocument();
}
 
Example #4
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void writeSecureDeployments(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(SecureDeploymentDefinition.TAG_NAME).isDefined()) {
        return;
    }
    for (Property deployment : context.getModelNode().get(SecureDeploymentDefinition.TAG_NAME).asPropertyList()) {
        writer.writeStartElement(SecureDeploymentDefinition.TAG_NAME);
        writer.writeAttribute("name", deployment.getName());
        ModelNode deploymentElements = deployment.getValue();
        for (AttributeDefinition element : SecureDeploymentDefinition.ALL_ATTRIBUTES) {
            element.marshallAsElement(deploymentElements, writer);
        }

        ModelNode credentials = deploymentElements.get(CredentialDefinition.TAG_NAME);
        if (credentials.isDefined()) {
            writeCredentials(writer, credentials);
        }

        writer.writeEndElement();
    }
}
 
Example #5
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void writeSecureResource(String tagName, List<SimpleAttributeDefinition> attributes, XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(tagName).isDefined()) {
        return;
    }
    for (Property deployment : context.getModelNode().get(tagName).asPropertyList()) {
        writer.writeStartElement(tagName);
        writer.writeAttribute("name", deployment.getName());
        ModelNode deploymentElements = deployment.getValue();
        for (AttributeDefinition element : attributes) {
            element.marshallAsElement(deploymentElements, writer);
        }

        ModelNode credentials = deploymentElements.get(CredentialDefinition.TAG_NAME);
        if (credentials.isDefined()) {
            writeCredentials(writer, credentials);
        }

        ModelNode redirectRewriteRule = deploymentElements.get(RedirecRewritetRuleDefinition.TAG_NAME);
        if (redirectRewriteRule.isDefined()) {
            writeRedirectRules(writer, redirectRewriteRule);
        }

        writer.writeEndElement();
    }
}
 
Example #6
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ModelMarshallingContext sanitizeContext(final ModelMarshallingContext context) {
    if (writeSanitizers == null) {
        return context;
    }

    ModelNode model = context.getModelNode();
    for (ModelWriteSanitizer sanitizer : writeSanitizers) {
        model = sanitizer.sanitize(model);
    }

    final ModelNode theModel = model;
    return new ModelMarshallingContext() {

        @Override
        public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
            return context.getSubsystemWriter(subsystemName);
        }

        @Override
        public ModelNode getModelNode() {
            return theModel;
        }
    };
}
 
Example #7
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ModelMarshallingContext wrapPossibleHost(final ModelMarshallingContext context) {

        if (type == TestModelType.HOST) {
            return new ModelMarshallingContext() {

                @Override
                public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
                    return context.getSubsystemWriter(subsystemName);
                }

                @Override
                public ModelNode getModelNode() {
                    return context.getModelNode().get(ModelDescriptionConstants.HOST, "master");
                }
            };
        }

        return context;
    }
 
Example #8
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void writeThemeDefaults(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(ThemeResourceDefinition.TAG_NAME).isDefined()) {
        return;
    }
    
    writer.writeStartElement(ThemeResourceDefinition.TAG_NAME);
    ModelNode themeElements = context.getModelNode().get(ThemeResourceDefinition.TAG_NAME, ThemeResourceDefinition.RESOURCE_NAME);
    for (AttributeDefinition def : ThemeResourceDefinition.ALL_ATTRIBUTES) {
        if (themeElements.hasDefined(def.getName())) {
            if (def == MODULES) {
                ModelNode themeContext = context.getModelNode().get("theme", "defaults");
                writeList(writer, themeContext, def, "module");
            } else {
                def.marshallAsElement(themeElements, writer);
            }
        }
    }
    writer.writeEndElement();
}
 
Example #9
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
  ModelNode node = context.getModelNode();
  ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName());
  
  if (jobExecutorNode.isDefined()) { 
    writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName());
    
    for (Property property : jobExecutorNode.asPropertyList()) {
      ModelNode propertyValue = property.getValue();

      for (AttributeDefinition jobExecutorAttribute : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) {
        if (jobExecutorAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
          ((SimpleAttributeDefinition) jobExecutorAttribute).marshallAsAttribute(propertyValue, writer);
        } else {
          jobExecutorAttribute.marshallAsElement(propertyValue, writer);
        }
      }

      writeJobAcquisitionsContent(writer, context, propertyValue);
    }

    // end job-executor
    writer.writeEndElement();
  }
}
 
Example #10
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void writeJobAcquisitionsContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context, ModelNode parentNode) throws XMLStreamException {
  writer.writeStartElement(Element.JOB_AQUISITIONS.getLocalName());

  ModelNode jobAcquisitionConfigurations = parentNode.get(Element.JOB_AQUISITIONS.getLocalName());
  if (jobAcquisitionConfigurations.isDefined()) {
    for (Property property : jobAcquisitionConfigurations.asPropertyList()) {
      // write each child element to xml
      writer.writeStartElement(Element.JOB_AQUISITION.getLocalName());

      for (AttributeDefinition jobAcquisitionAttribute : SubsystemAttributeDefinitons.JOB_ACQUISITION_ATTRIBUTES) {
        if (jobAcquisitionAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
          ((SimpleAttributeDefinition) jobAcquisitionAttribute).marshallAsAttribute(property.getValue(), writer);
        } else {
          jobAcquisitionAttribute.marshallAsElement(property.getValue(), writer);
        }
      }

      writer.writeEndElement();
    }
  }
  // end job-acquisitions
  writer.writeEndElement();
}
 
Example #11
Source File: BpmPlatformParser1_1.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
  ModelNode node = context.getModelNode();
  ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName());

  if (jobExecutorNode.isDefined()) {

    writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName());

    for (Property property : jobExecutorNode.asPropertyList()) {
      ModelNode propertyValue = property.getValue();

      for (AttributeDefinition jobExecutorAttribute : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) {
        if (jobExecutorAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
          ((SimpleAttributeDefinition) jobExecutorAttribute).marshallAsAttribute(propertyValue, writer);
        } else {
          jobExecutorAttribute.marshallAsElement(propertyValue, writer);
        }
      }

      writeJobAcquisitionsContent(writer, context, propertyValue);
    }

    // end job-executor
    writer.writeEndElement();
  }
}
 
Example #12
Source File: AbstractMgmtTestBase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public String modelToXml(String subsystemName, String childType, XMLElementWriter<SubsystemMarshallingContext> parser) throws Exception {
    final ModelNode address = new ModelNode();
    address.add("subsystem", subsystemName);
    address.protect();

    final ModelNode operation = new ModelNode();
    operation.get(OP).set("read-children-resources");
    operation.get("child-type").set(childType);
    operation.get(RECURSIVE).set(true);
    operation.get(OP_ADDR).set(address);

    final ModelNode result = executeOperation(operation);
    Assert.assertNotNull(result);

    ModelNode dsNode = new ModelNode();
    dsNode.get(childType).set(result);

    StringWriter strWriter = new StringWriter();
    XMLExtendedStreamWriter writer = XMLExtendedStreamWriterFactory.create(XMLOutputFactory.newInstance()
            .createXMLStreamWriter(strWriter));
    parser.writeContent(writer, new SubsystemMarshallingContext(dsNode, writer));
    writer.flush();
    return strWriter.toString();
}
 
Example #13
Source File: LoggingSubsystemWriter.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

    ModelNode model = context.getModelNode();

    // Marshall attributes
    for (AttributeDefinition attribute : LoggingResourceDefinition.ATTRIBUTES) {
        attribute.marshallAsElement(model, false, writer);
    }

    writeContent(writer, model);

    if (model.hasDefined(LOGGING_PROFILE)) {
        final List<Property> profiles = model.get(LOGGING_PROFILE).asPropertyList();
        if (!profiles.isEmpty()) {
            writer.writeStartElement(LOGGING_PROFILES);
            for (Property profile : profiles) {
                final String name = profile.getName();
                writer.writeStartElement(LOGGING_PROFILE);
                writer.writeAttribute(Attribute.NAME.getLocalName(), name);
                writeContent(writer, profile.getValue());
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
    }
    writer.writeEndElement();
}
 
Example #14
Source File: GmlcSubsystemParser.java    From gmlc with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
  context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

  final ModelNode node = context.getModelNode();
  final ModelNode mbean = node.get(GmlcMbeanDefinition.MBEAN);

  for (Property mbeanProp : mbean.asPropertyList()) {
    writer.writeStartElement(GmlcMbeanDefinition.MBEAN);

    final ModelNode mbeanEntry = mbeanProp.getValue();

    GmlcMbeanDefinition.NAME_ATTR.marshallAsAttribute(mbeanEntry, true, writer);
    GmlcMbeanDefinition.TYPE_ATTR.marshallAsAttribute(mbeanEntry, true, writer);

    final ModelNode property = mbeanEntry.get(GmlcMbeanPropertyDefinition.PROPERTY);
    if (property != null && property.isDefined()) {
      for (Property propertyProp : property.asPropertyList()) {
        writer.writeStartElement(GmlcMbeanPropertyDefinition.PROPERTY);

        final ModelNode propertyEntry = propertyProp.getValue();

        GmlcMbeanPropertyDefinition.NAME_ATTR.marshallAsAttribute(propertyEntry, true, writer);
        GmlcMbeanPropertyDefinition.TYPE_ATTR.marshallAsAttribute(propertyEntry, true, writer);
        GmlcMbeanPropertyDefinition.VALUE_ATTR.marshallAsAttribute(propertyEntry, true, writer);

        writer.writeEndElement();
      }
    }

    writer.writeEndElement();
  }

  writer.writeEndElement();
}
 
Example #15
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakExtension.NAMESPACE, false);
    writeRealms(writer, context);
    writeSecureDeployments(writer, context);
    writer.writeEndElement();
}
 
Example #16
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeRealms(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(RealmDefinition.TAG_NAME).isDefined()) {
        return;
    }
    for (Property realm : context.getModelNode().get(RealmDefinition.TAG_NAME).asPropertyList()) {
        writer.writeStartElement(RealmDefinition.TAG_NAME);
        writer.writeAttribute("name", realm.getName());
        ModelNode realmElements = realm.getValue();
        for (AttributeDefinition element : RealmDefinition.ALL_ATTRIBUTES) {
            element.marshallAsElement(realmElements, writer);
        }

        writer.writeEndElement();
    }
}
 
Example #17
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakExtension.NAMESPACE, false);
    writeRealms(writer, context);
    writeSecureDeployments(writer, context);
    writeSecureServers(writer, context);
    writer.writeEndElement();
}
 
Example #18
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeRealms(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(RealmDefinition.TAG_NAME).isDefined()) {
        return;
    }
    for (Property realm : context.getModelNode().get(RealmDefinition.TAG_NAME).asPropertyList()) {
        writer.writeStartElement(RealmDefinition.TAG_NAME);
        writer.writeAttribute("name", realm.getName());
        ModelNode realmElements = realm.getValue();
        for (AttributeDefinition element : RealmDefinition.ALL_ATTRIBUTES) {
            element.marshallAsElement(realmElements, writer);
        }

        writer.writeEndElement();
    }
}
 
Example #19
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context)
        throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode node = context.getModelNode();
    writeThreadsElement(writer, node);
    writer.writeEndElement();
}
 
Example #20
Source File: BpmPlatformParser1_1.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void writeProcessEnginesContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {

      writer.writeStartElement(Element.PROCESS_ENGINES.getLocalName());

      ModelNode node = context.getModelNode();

      ModelNode processEngineConfigurations = node.get(Element.PROCESS_ENGINES.getLocalName());
      if (processEngineConfigurations.isDefined()) {
        for (Property property : processEngineConfigurations.asPropertyList()) {
          // write each child element to xml
          writer.writeStartElement(Element.PROCESS_ENGINE.getLocalName());

          ModelNode propertyValue = property.getValue();
          for (AttributeDefinition processEngineAttribute : SubsystemAttributeDefinitons.PROCESS_ENGINE_ATTRIBUTES) {
            if (processEngineAttribute.equals(SubsystemAttributeDefinitons.NAME) || processEngineAttribute.equals(SubsystemAttributeDefinitons.DEFAULT)) {
              ((SimpleAttributeDefinition) processEngineAttribute).marshallAsAttribute(propertyValue, writer);
            } else {
              processEngineAttribute.marshallAsElement(propertyValue, writer);
            }
          }

          writer.writeEndElement();
        }
      }
      // end process-engines
      writer.writeEndElement();
    }
 
Example #21
Source File: BpmPlatformParser1_1.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
  context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

  writeProcessEnginesContent(writer, context);
  writeJobExecutorContent(writer, context);

  // end subsystem
  writer.writeEndElement();
}
 
Example #22
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakSamlExtension.CURRENT_NAMESPACE, false);
    writeSecureDeployment(writer, context.getModelNode());
    writer.writeEndElement();
}
 
Example #23
Source File: DeploymentScannerParser_2_0.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@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()) {

            final String scannerName = scanner.getName();
            final ModelNode configuration = scanner.getValue();

            writer.writeEmptyElement(DEPLOYMENT_SCANNER);

            if (!DeploymentScannerExtension.DEFAULT_SCANNER_NAME.equals(scannerName)) {
                writer.writeAttribute(NAME, scannerName);
            }

            DeploymentScannerDefinition.PATH.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.RELATIVE_TO.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_ENABLED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_INTERVAL.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_XML.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.RUNTIME_FAILURE_CAUSES_ROLLBACK.marshallAsAttribute(configuration, writer);
        }
        writer.writeEndElement();
    }
}
 
Example #24
Source File: DeploymentScannerParser_1_1.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@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()) {

            final String scannerName = scanner.getName();
            final ModelNode configuration = scanner.getValue();

            writer.writeEmptyElement(DEPLOYMENT_SCANNER);

            if (!DeploymentScannerExtension.DEFAULT_SCANNER_NAME.equals(scannerName)) {
                writer.writeAttribute(NAME, scannerName);
            }

            DeploymentScannerDefinition.PATH.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.RELATIVE_TO.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_ENABLED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_INTERVAL.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_XML.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.marshallAsAttribute(configuration, writer);
        }
        writer.writeEndElement();
    }
}
 
Example #25
Source File: CommonXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static void writeSubsystems(final ModelNode profileNode, final XMLExtendedStreamWriter writer,
                                      final ModelMarshallingContext context) throws XMLStreamException {

    if (profileNode.hasDefined(SUBSYSTEM)) {
        Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
        if (subsystemNames.size() > 0) {
            // establish traditional 'logging then alphabetical' ordering
            // note that logging first is just tradition; it's not necessary technically
            Set<String> alphabetical = new TreeSet<>(subsystemNames);
            if (alphabetical.contains("logging")) {
                subsystemNames = new LinkedHashSet<>();
                subsystemNames.add("logging");
                subsystemNames.addAll(alphabetical);
            } else {
                subsystemNames = alphabetical;
            }

            String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
            for (String subsystemName : subsystemNames) {
                try {
                    ModelNode subsystem = profileNode.get(SUBSYSTEM, subsystemName);
                    XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(subsystemName);
                    if (subsystemWriter != null) { // FIXME -- remove when extensions are doing the registration
                        subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
                    }
                } finally {
                    writer.setDefaultNamespace(defaultNamespace);
                }
            }
        }
    }
}
 
Example #26
Source File: PersistentResourceXMLParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    PersistentResourceXMLDescription description = getParserDescription();
    ModelNode model = new ModelNode();
    model.get(description.getPathElement().getKeyValuePair()).set(context.getModelNode());
    description.persist(writer, model);
}
 
Example #27
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakSamlExtension.CURRENT_NAMESPACE, false);
    writeSecureDeployment(writer, context.getModelNode());
    writer.writeEndElement();
}
 
Example #28
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakExtension.NAMESPACE, false);
    writeWebContext(writer, context);
    writeList(writer, context.getModelNode(), PROVIDERS, "provider");
    writeAdmin(writer, context);
    writeScheduledTaskInterval(writer, context);
    writeThemeDefaults(writer, context);
    writeSpis(writer, context);
    writer.writeEndElement();
}
 
Example #29
Source File: OrderedChildResourceExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
    context.startSubsystemElement(OrderedChildResourceExtension.NAMESPACE, false);
    final ModelNode node = context.getModelNode();
    if (node.hasDefined("child")) {
        for (Property prop : node.get("child").asPropertyList()) {
            writer.writeStartElement("child");
            writer.writeAttribute("name", prop.getName());
            writer.writeEndElement();
        }
    }
    writer.writeEndElement();
}
 
Example #30
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeSpis(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(SpiResourceDefinition.TAG_NAME).isDefined()) {
        return;
    }
    
    for (Property spi : context.getModelNode().get(SpiResourceDefinition.TAG_NAME).asPropertyList()) {
        writer.writeStartElement(SpiResourceDefinition.TAG_NAME);
        writer.writeAttribute("name", spi.getName());
        ModelNode spiElements = spi.getValue();
        DEFAULT_PROVIDER.marshallAsElement(spiElements, writer);
        writeProviders(writer, spiElements);
        writer.writeEndElement();
    }
}