You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2023/02/08 18:20:38 UTC

[camel] 02/02: [CAMEL-18305] New lightweight ModelToXMLDumper

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 701a15a2094116836c6fe49fc46f946086c8bb0c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Feb 8 16:12:53 2023 +0100

    [CAMEL-18305] New lightweight ModelToXMLDumper
---
 core/camel-core/pom.xml                            |   4 +
 .../java/org/apache/camel/xml/out/ModelWriter.java | 173 +++++++------
 .../services/org/apache/camel/modelxml-dumper      |   2 +
 .../org/apache/camel/xml/LwModelToXMLDumper.java   | 268 +++++++++++++++++++++
 .../java/org/apache/camel/xml/io/XMLWriter.java    |  49 +---
 .../java/org/apache/camel/xml/out/BaseWriter.java  |   6 +-
 .../packaging/ModelXmlWriterGeneratorMojo.java     |  15 ++
 7 files changed, 405 insertions(+), 112 deletions(-)

diff --git a/core/camel-core/pom.xml b/core/camel-core/pom.xml
index 7ed136fd9f0..d8ccffda633 100644
--- a/core/camel-core/pom.xml
+++ b/core/camel-core/pom.xml
@@ -146,6 +146,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-xslt</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-xml-io</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-xml-jaxb</artifactId>
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index 3f89b8b860e..074f96a8d56 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -1059,14 +1059,14 @@ public class ModelWriter extends BaseWriter {
         doWriteOptionalIdentifiedDefinitionElements(def);
         endElement();
     }
-    void doWriteBeanFactoryDefinitionAttributes(
+    protected void doWriteBeanFactoryDefinitionAttributes(
             BeanFactoryDefinition<?, ?> def)
             throws IOException {
         doWriteAttribute("name", def.getName());
         doWriteAttribute("type", def.getType());
         doWriteAttribute("beanType", def.getBeanType());
     }
-    void doWriteBeanFactoryDefinitionElements(
+    protected void doWriteBeanFactoryDefinitionElements(
             BeanFactoryDefinition<?, ?> def)
             throws IOException {
         doWriteElement("script", def.getScript(), this::doWriteString);
@@ -1154,7 +1154,7 @@ public class ModelWriter extends BaseWriter {
         doWriteOptionalIdentifiedDefinitionElements(def);
         endElement();
     }
-    void doWriteDataFormatDefinitionAttributes(
+    protected void doWriteDataFormatDefinitionAttributes(
             DataFormatDefinition def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -1234,10 +1234,14 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteExpressionNodeAttributes(ExpressionNode def) throws IOException {
+    protected void doWriteExpressionNodeAttributes(
+            ExpressionNode def)
+            throws IOException {
         doWriteProcessorDefinitionAttributes(def);
     }
-    void doWriteExpressionNodeElements(ExpressionNode def) throws IOException {
+    protected void doWriteExpressionNodeElements(
+            ExpressionNode def)
+            throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
         doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef);
     }
@@ -1258,7 +1262,7 @@ public class ModelWriter extends BaseWriter {
         doWriteElement(null, def.getExpressionType(), this::doWriteExpressionDefinitionRef);
         endElement();
     }
-    void doWriteFaultToleranceConfigurationCommonAttributes(
+    protected void doWriteFaultToleranceConfigurationCommonAttributes(
             FaultToleranceConfigurationCommon def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -1353,7 +1357,9 @@ public class ModelWriter extends BaseWriter {
         doWriteOutputExpressionNodeElements(def);
         endElement();
     }
-    void doWriteIdentifiedTypeAttributes(IdentifiedType def) throws IOException {
+    protected void doWriteIdentifiedTypeAttributes(
+            IdentifiedType def)
+            throws IOException {
         doWriteAttribute("id", def.getId());
     }
     protected void doWriteIdentifiedType(
@@ -1393,12 +1399,12 @@ public class ModelWriter extends BaseWriter {
         doWriteOptionalIdentifiedDefinitionElements(def);
         endElement();
     }
-    void doWriteInterceptDefinitionAttributes(
+    protected void doWriteInterceptDefinitionAttributes(
             InterceptDefinition def)
             throws IOException {
         doWriteProcessorDefinitionAttributes(def);
     }
-    void doWriteInterceptDefinitionElements(
+    protected void doWriteInterceptDefinitionElements(
             InterceptDefinition def)
             throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
@@ -1468,7 +1474,7 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteLoadBalancerDefinitionAttributes(
+    protected void doWriteLoadBalancerDefinitionAttributes(
             LoadBalancerDefinition def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -1641,13 +1647,13 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("maximumRetryDelay", def.getMaximumRetryDelay());
         endElement();
     }
-    void doWriteOptionalIdentifiedDefinitionAttributes(
+    protected void doWriteOptionalIdentifiedDefinitionAttributes(
             OptionalIdentifiedDefinition<?> def)
             throws IOException {
         doWriteAttribute("id", def.getId());
         doWriteAttribute("customId", toString(def.getCustomId()));
     }
-    void doWriteOptionalIdentifiedDefinitionElements(
+    protected void doWriteOptionalIdentifiedDefinitionElements(
             OptionalIdentifiedDefinition<?> def)
             throws IOException {
         doWriteElement("description", def.getDescription(), this::doWriteDescriptionDefinition);
@@ -1671,12 +1677,12 @@ public class ModelWriter extends BaseWriter {
         doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef);
         endElement();
     }
-    void doWriteOutputExpressionNodeAttributes(
+    protected void doWriteOutputExpressionNodeAttributes(
             OutputExpressionNode def)
             throws IOException {
         doWriteProcessorDefinitionAttributes(def);
     }
-    void doWriteOutputExpressionNodeElements(
+    protected void doWriteOutputExpressionNodeElements(
             OutputExpressionNode def)
             throws IOException {
         doWriteExpressionNodeElements(def);
@@ -1770,14 +1776,14 @@ public class ModelWriter extends BaseWriter {
         doWriteOptionalIdentifiedDefinitionElements(def);
         endElement();
     }
-    void doWriteProcessorDefinitionAttributes(
+    protected void doWriteProcessorDefinitionAttributes(
             ProcessorDefinition<?> def)
             throws IOException {
         doWriteOptionalIdentifiedDefinitionAttributes(def);
         doWriteAttribute("inheritErrorHandler", toString(def.isInheritErrorHandler()));
         doWriteAttribute("disabled", def.getDisabled());
     }
-    void doWriteProcessorDefinitionElements(
+    protected void doWriteProcessorDefinitionElements(
             ProcessorDefinition<?> def)
             throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
@@ -1931,7 +1937,7 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteResilience4jConfigurationCommonAttributes(
+    protected void doWriteResilience4jConfigurationCommonAttributes(
             Resilience4jConfigurationCommon def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -1949,7 +1955,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("slidingWindowType", def.getSlidingWindowType());
         doWriteAttribute("waitDurationInOpenState", def.getWaitDurationInOpenState());
     }
-    void doWriteResilience4jConfigurationCommonElements(
+    protected void doWriteResilience4jConfigurationCommonElements(
             Resilience4jConfigurationCommon def)
             throws IOException {
         doWriteElement("bulkheadMaxWaitDuration", def.getBulkheadMaxWaitDuration(), this::doWriteString);
@@ -2208,13 +2214,15 @@ public class ModelWriter extends BaseWriter {
         doWriteExpressionNodeElements(def);
         endElement();
     }
-    void doWriteSendDefinitionAttributes(
+    protected void doWriteSendDefinitionAttributes(
             SendDefinition<?> def)
             throws IOException {
         doWriteProcessorDefinitionAttributes(def);
         doWriteAttribute("uri", def.getUri());
     }
-    void doWriteSendDefinitionElements(SendDefinition<?> def) throws IOException {
+    protected void doWriteSendDefinitionElements(
+            SendDefinition<?> def)
+            throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
     }
     protected void doWriteSendDefinition(
@@ -2428,7 +2436,7 @@ public class ModelWriter extends BaseWriter {
         doWriteOptionalIdentifiedDefinitionElements(def);
         endElement();
     }
-    void doWriteToDynamicDefinitionAttributes(
+    protected void doWriteToDynamicDefinitionAttributes(
             ToDynamicDefinition def)
             throws IOException {
         doWriteProcessorDefinitionAttributes(def);
@@ -2439,7 +2447,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents());
         doWriteAttribute("uri", def.getUri());
     }
-    void doWriteToDynamicDefinitionElements(
+    protected void doWriteToDynamicDefinitionElements(
             ToDynamicDefinition def)
             throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
@@ -2735,12 +2743,12 @@ public class ModelWriter extends BaseWriter {
         doWriteServiceCallConfigurationElements(def);
         endElement();
     }
-    void doWriteServiceCallConfigurationAttributes(
+    protected void doWriteServiceCallConfigurationAttributes(
             ServiceCallConfiguration def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
     }
-    void doWriteServiceCallConfigurationElements(
+    protected void doWriteServiceCallConfigurationElements(
             ServiceCallConfiguration def)
             throws IOException {
         doWriteList(null, "properties", def.getProperties(), this::doWritePropertyDefinition);
@@ -2862,12 +2870,12 @@ public class ModelWriter extends BaseWriter {
         doWriteServiceCallConfigurationElements(def);
         endElement();
     }
-    void doWriteServiceCallServiceDiscoveryConfigurationAttributes(
+    protected void doWriteServiceCallServiceDiscoveryConfigurationAttributes(
             ServiceCallServiceDiscoveryConfiguration def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
     }
-    void doWriteServiceCallServiceDiscoveryConfigurationElements(
+    protected void doWriteServiceCallServiceDiscoveryConfigurationElements(
             ServiceCallServiceDiscoveryConfiguration def)
             throws IOException {
         doWriteServiceCallConfigurationElements(def);
@@ -2881,12 +2889,12 @@ public class ModelWriter extends BaseWriter {
         doWriteServiceCallServiceDiscoveryConfigurationElements(def);
         endElement();
     }
-    void doWriteServiceCallServiceFilterConfigurationAttributes(
+    protected void doWriteServiceCallServiceFilterConfigurationAttributes(
             ServiceCallServiceFilterConfiguration def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
     }
-    void doWriteServiceCallServiceFilterConfigurationElements(
+    protected void doWriteServiceCallServiceFilterConfigurationElements(
             ServiceCallServiceFilterConfiguration def)
             throws IOException {
         doWriteServiceCallConfigurationElements(def);
@@ -2900,12 +2908,12 @@ public class ModelWriter extends BaseWriter {
         doWriteServiceCallServiceFilterConfigurationElements(def);
         endElement();
     }
-    void doWriteServiceCallServiceLoadBalancerConfigurationAttributes(
+    protected void doWriteServiceCallServiceLoadBalancerConfigurationAttributes(
             ServiceCallServiceLoadBalancerConfiguration def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
     }
-    void doWriteServiceCallServiceLoadBalancerConfigurationElements(
+    protected void doWriteServiceCallServiceLoadBalancerConfigurationElements(
             ServiceCallServiceLoadBalancerConfiguration def)
             throws IOException {
         doWriteServiceCallConfigurationElements(def);
@@ -3183,7 +3191,9 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteFhirDataformatAttributes(FhirDataformat def) throws IOException {
+    protected void doWriteFhirDataformatAttributes(
+            FhirDataformat def)
+            throws IOException {
         doWriteIdentifiedTypeAttributes(def);
         doWriteAttribute("contentTypeHeader", def.getContentTypeHeader());
         doWriteAttribute("dontStripVersionsFromReferencesAtPaths", def.getDontStripVersionsFromReferencesAtPaths());
@@ -3531,7 +3541,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("dataObjectType", def.getDataObjectTypeName());
         endElement();
     }
-    void doWriteUniVocityAbstractDataFormatAttributes(
+    protected void doWriteUniVocityAbstractDataFormatAttributes(
             UniVocityAbstractDataFormat def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -3549,7 +3559,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("comment", def.getComment());
         doWriteAttribute("numberOfRecordsToRead", def.getNumberOfRecordsToRead());
     }
-    void doWriteUniVocityAbstractDataFormatElements(
+    protected void doWriteUniVocityAbstractDataFormatElements(
             UniVocityAbstractDataFormat def)
             throws IOException {
         doWriteList(null, null, def.getHeaders(), this::doWriteUniVocityHeaderRef);
@@ -3688,7 +3698,7 @@ public class ModelWriter extends BaseWriter {
         doWriteDefaultErrorHandlerDefinitionElements(def);
         endElement();
     }
-    void doWriteDefaultErrorHandlerDefinitionAttributes(
+    protected void doWriteDefaultErrorHandlerDefinitionAttributes(
             DefaultErrorHandlerDefinition def)
             throws IOException {
         doWriteIdentifiedTypeAttributes(def);
@@ -3704,7 +3714,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("onExceptionOccurredRef", def.getOnExceptionOccurredRef());
         doWriteAttribute("redeliveryPolicyRef", def.getRedeliveryPolicyRef());
     }
-    void doWriteDefaultErrorHandlerDefinitionElements(
+    protected void doWriteDefaultErrorHandlerDefinitionElements(
             DefaultErrorHandlerDefinition def)
             throws IOException {
         doWriteElement("redeliveryPolicy", def.getRedeliveryPolicy(), this::doWriteRedeliveryPolicyDefinition);
@@ -3753,14 +3763,14 @@ public class ModelWriter extends BaseWriter {
         doWriteDefaultErrorHandlerDefinitionElements(def);
         endElement();
     }
-    void doWriteTransactionErrorHandlerDefinitionAttributes(
+    protected void doWriteTransactionErrorHandlerDefinitionAttributes(
             TransactionErrorHandlerDefinition def)
             throws IOException {
         doWriteDefaultErrorHandlerDefinitionAttributes(def);
         doWriteAttribute("rollbackLoggingLevel", def.getRollbackLoggingLevel());
         doWriteAttribute("transactedPolicyRef", def.getTransactedPolicyRef());
     }
-    void doWriteTransactionErrorHandlerDefinitionElements(
+    protected void doWriteTransactionErrorHandlerDefinitionElements(
             TransactionErrorHandlerDefinition def)
             throws IOException {
         doWriteDefaultErrorHandlerDefinitionElements(def);
@@ -3812,7 +3822,7 @@ public class ModelWriter extends BaseWriter {
         doWriteValue(def.getExpression());
         endElement();
     }
-    void doWriteExpressionDefinitionAttributes(
+    protected void doWriteExpressionDefinitionAttributes(
             ExpressionDefinition def)
             throws IOException {
         doWriteAttribute("trim", def.getTrim());
@@ -3930,12 +3940,12 @@ public class ModelWriter extends BaseWriter {
         doWriteValue(def.getExpression());
         endElement();
     }
-    void doWriteNamespaceAwareExpressionAttributes(
+    protected void doWriteNamespaceAwareExpressionAttributes(
             NamespaceAwareExpression def)
             throws IOException {
         doWriteSingleInputExpressionDefinitionAttributes(def);
     }
-    void doWriteNamespaceAwareExpressionElements(
+    protected void doWriteNamespaceAwareExpressionElements(
             NamespaceAwareExpression def)
             throws IOException {
         doWriteList(null, "namespace", def.getNamespace(), this::doWritePropertyDefinition);
@@ -3986,7 +3996,7 @@ public class ModelWriter extends BaseWriter {
         doWriteValue(def.getExpression());
         endElement();
     }
-    void doWriteSingleInputExpressionDefinitionAttributes(
+    protected void doWriteSingleInputExpressionDefinitionAttributes(
             SingleInputExpressionDefinition def)
             throws IOException {
         doWriteExpressionDefinitionAttributes(def);
@@ -4002,7 +4012,7 @@ public class ModelWriter extends BaseWriter {
         doWriteValue(def.getExpression());
         endElement();
     }
-    void doWriteSingleInputTypedExpressionDefinitionAttributes(
+    protected void doWriteSingleInputTypedExpressionDefinitionAttributes(
             SingleInputTypedExpressionDefinition def)
             throws IOException {
         doWriteTypedExpressionDefinitionAttributes(def);
@@ -4045,7 +4055,7 @@ public class ModelWriter extends BaseWriter {
         doWriteValue(def.getExpression());
         endElement();
     }
-    void doWriteTypedExpressionDefinitionAttributes(
+    protected void doWriteTypedExpressionDefinitionAttributes(
             TypedExpressionDefinition def)
             throws IOException {
         doWriteExpressionDefinitionAttributes(def);
@@ -4426,7 +4436,7 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteRestSecurityDefinitionAttributes(
+    protected void doWriteRestSecurityDefinitionAttributes(
             RestSecurityDefinition def)
             throws IOException {
         doWriteAttribute("description", def.getDescription());
@@ -4459,7 +4469,9 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("key", def.getKey());
         endElement();
     }
-    void doWriteVerbDefinitionAttributes(VerbDefinition def) throws IOException {
+    protected void doWriteVerbDefinitionAttributes(
+            VerbDefinition def)
+            throws IOException {
         doWriteOptionalIdentifiedDefinitionAttributes(def);
         doWriteAttribute("enableCORS", def.getEnableCORS());
         doWriteAttribute("deprecated", def.getDeprecated());
@@ -4475,7 +4487,9 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("disabled", def.getDisabled());
         doWriteAttribute("consumes", def.getConsumes());
     }
-    void doWriteVerbDefinitionElements(VerbDefinition def) throws IOException {
+    protected void doWriteVerbDefinitionElements(
+            VerbDefinition def)
+            throws IOException {
         doWriteOptionalIdentifiedDefinitionElements(def);
         doWriteList(null, null, def.getParams(), this::doWriteParamDefinitionRef);
         doWriteList(null, null, def.getSecurity(), this::doWriteSecurityDefinitionRef);
@@ -4562,7 +4576,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("uri", def.getUri());
         endElement();
     }
-    void doWriteTransformerDefinitionAttributes(
+    protected void doWriteTransformerDefinitionAttributes(
             TransformerDefinition def)
             throws IOException {
         doWriteAttribute("toType", def.getToType());
@@ -4620,7 +4634,7 @@ public class ModelWriter extends BaseWriter {
         doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef);
         endElement();
     }
-    void doWriteValidatorDefinitionAttributes(
+    protected void doWriteValidatorDefinitionAttributes(
             ValidatorDefinition def)
             throws IOException {
         doWriteAttribute("type", def.getType());
@@ -4647,14 +4661,17 @@ public class ModelWriter extends BaseWriter {
         });
         endElement();
     }
-    void doWriteFromDefinitionRef(String n, FromDefinition v) throws IOException {
+    protected void doWriteFromDefinitionRef(
+            String n,
+            FromDefinition v)
+            throws IOException {
         if (v != null) {
             switch (v.getClass().getSimpleName()) {
                 case "FromDefinition" -> doWriteFromDefinition("from", (FromDefinition) v);
             }
         }
     }
-    void doWriteInputTypeDefinitionRef(
+    protected void doWriteInputTypeDefinitionRef(
             String n,
             InputTypeDefinition v)
             throws IOException {
@@ -4664,7 +4681,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteOutputTypeDefinitionRef(
+    protected void doWriteOutputTypeDefinitionRef(
             String n,
             OutputTypeDefinition v)
             throws IOException {
@@ -4674,7 +4691,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteProcessorDefinitionRef(
+    protected void doWriteProcessorDefinitionRef(
             String n,
             ProcessorDefinition<?> v)
             throws IOException {
@@ -4750,7 +4767,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteRouteConfigurationDefinitionRef(
+    protected void doWriteRouteConfigurationDefinitionRef(
             String n,
             RouteConfigurationDefinition v)
             throws IOException {
@@ -4760,7 +4777,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteRouteDefinitionRef(
+    protected void doWriteRouteDefinitionRef(
             String n,
             RouteDefinition v)
             throws IOException {
@@ -4770,7 +4787,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteRouteTemplateDefinitionRef(
+    protected void doWriteRouteTemplateDefinitionRef(
             String n,
             RouteTemplateDefinition v)
             throws IOException {
@@ -4780,7 +4797,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteTemplatedRouteDefinitionRef(
+    protected void doWriteTemplatedRouteDefinitionRef(
             String n,
             TemplatedRouteDefinition v)
             throws IOException {
@@ -4790,14 +4807,17 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteWhenDefinitionRef(String n, WhenDefinition v) throws IOException {
+    protected void doWriteWhenDefinitionRef(
+            String n,
+            WhenDefinition v)
+            throws IOException {
         if (v != null) {
             switch (v.getClass().getSimpleName()) {
                 case "WhenDefinition" -> doWriteWhenDefinition("when", (WhenDefinition) v);
             }
         }
     }
-    void doWriteUniVocityHeaderRef(
+    protected void doWriteUniVocityHeaderRef(
             String n,
             UniVocityHeader v)
             throws IOException {
@@ -4807,7 +4827,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteExpressionDefinitionRef(
+    protected void doWriteExpressionDefinitionRef(
             String n,
             ExpressionDefinition v)
             throws IOException {
@@ -4817,7 +4837,7 @@ public class ModelWriter extends BaseWriter {
                 case "ConstantExpression" -> doWriteConstantExpression("constant", (ConstantExpression) v);
                 case "DatasonnetExpression" -> doWriteDatasonnetExpression("datasonnet", (DatasonnetExpression) v);
                 case "ExchangePropertyExpression" -> doWriteExchangePropertyExpression("exchangeProperty", (ExchangePropertyExpression) v);
-                case "ExpressionDefinition" -> doWriteExpressionDefinition("##default", (ExpressionDefinition) v);
+                case "ExpressionDefinition" -> doWriteExpressionDefinition("expressionDefinition", (ExpressionDefinition) v);
                 case "GroovyExpression" -> doWriteGroovyExpression("groovy", (GroovyExpression) v);
                 case "HeaderExpression" -> doWriteHeaderExpression("header", (HeaderExpression) v);
                 case "Hl7TerserExpression" -> doWriteHl7TerserExpression("hl7terser", (Hl7TerserExpression) v);
@@ -4840,7 +4860,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteParamDefinitionRef(
+    protected void doWriteParamDefinitionRef(
             String n,
             ParamDefinition v)
             throws IOException {
@@ -4850,7 +4870,7 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteResponseMessageDefinitionRef(
+    protected void doWriteResponseMessageDefinitionRef(
             String n,
             ResponseMessageDefinition v)
             throws IOException {
@@ -4860,14 +4880,17 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteRestDefinitionRef(String n, RestDefinition v) throws IOException {
+    protected void doWriteRestDefinitionRef(
+            String n,
+            RestDefinition v)
+            throws IOException {
         if (v != null) {
             switch (v.getClass().getSimpleName()) {
                 case "RestDefinition" -> doWriteRestDefinition("rest", (RestDefinition) v);
             }
         }
     }
-    void doWriteSecurityDefinitionRef(
+    protected void doWriteSecurityDefinitionRef(
             String n,
             SecurityDefinition v)
             throws IOException {
@@ -4877,7 +4900,10 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteVerbDefinitionRef(String n, VerbDefinition v) throws IOException {
+    protected void doWriteVerbDefinitionRef(
+            String n,
+            VerbDefinition v)
+            throws IOException {
         if (v != null) {
             switch (v.getClass().getSimpleName()) {
                 case "DeleteDefinition" -> doWriteDeleteDefinition("delete", (DeleteDefinition) v);
@@ -4889,12 +4915,15 @@ public class ModelWriter extends BaseWriter {
             }
         }
     }
-    void doWriteAttribute(String attribute, String value) throws IOException {
+    protected void doWriteAttribute(
+            String attribute,
+            String value)
+            throws IOException {
         if (value != null) {
             attribute(attribute, value);
         }
     }
-    void doWriteValue(String value) throws IOException {
+    protected void doWriteValue(String value) throws IOException {
         if (value != null) {
             text(value);
         }
@@ -4917,19 +4946,19 @@ public class ModelWriter extends BaseWriter {
             elementSerializer.doWriteElement(name, v);
         }
     }
-    String toString(Boolean b) {
+    protected String toString(Boolean b) {
         return b != null ? b.toString() : null;
     }
-    String toString(Enum<?> e) {
+    protected String toString(Enum<?> e) {
         return e != null ? e.name() : null;
     }
-    String toString(Number n) {
+    protected String toString(Number n) {
         return n != null ? n.toString() : null;
     }
-    String toString(byte[] b) {
+    protected String toString(byte[] b) {
         return b != null ? Base64.getEncoder().encodeToString(b) : null;
     }
-    void doWriteString(String name, String value) throws IOException {
+    protected void doWriteString(String name, String value) throws IOException {
         if (value != null) {
             startElement(name);
             text(value);
diff --git a/core/camel-xml-io/src/generated/resources/META-INF/services/org/apache/camel/modelxml-dumper b/core/camel-xml-io/src/generated/resources/META-INF/services/org/apache/camel/modelxml-dumper
new file mode 100644
index 00000000000..6150df7d1c2
--- /dev/null
+++ b/core/camel-xml-io/src/generated/resources/META-INF/services/org/apache/camel/modelxml-dumper
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.xml.LwModelToXMLDumper
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/LwModelToXMLDumper.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/LwModelToXMLDumper.java
new file mode 100644
index 00000000000..3e6d9b25685
--- /dev/null
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/LwModelToXMLDumper.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.xml;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.function.Consumer;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.DelegateEndpoint;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Expression;
+import org.apache.camel.NamedNode;
+import org.apache.camel.model.ExpressionNode;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.OptionalIdentifiedDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.RouteTemplateDefinition;
+import org.apache.camel.model.RouteTemplatesDefinition;
+import org.apache.camel.model.RoutesDefinition;
+import org.apache.camel.model.SendDefinition;
+import org.apache.camel.model.ToDynamicDefinition;
+import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.spi.ModelToXMLDumper;
+import org.apache.camel.spi.NamespaceAware;
+import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.util.KeyValueHolder;
+import org.apache.camel.xml.out.ModelWriter;
+
+import static org.apache.camel.model.ProcessorDefinitionHelper.filterTypeInOutputs;
+
+/**
+ * Lightweight {@link ModelToXMLDumper} based on the generated {@link ModelWriter}.
+ */
+@JdkService(ModelToXMLDumper.FACTORY)
+public class LwModelToXMLDumper implements ModelToXMLDumper {
+
+    @Override
+    public String dumpModelAsXml(CamelContext context, NamedNode definition) throws Exception {
+        return dumpModelAsXml(context, definition, false, false);
+    }
+
+    @Override
+    public String dumpModelAsXml(
+            CamelContext context, NamedNode definition, boolean resolvePlaceholders, boolean resolveDelegateEndpoints)
+            throws Exception {
+
+        Properties properties = new Properties();
+        Map<String, String> namespaces = new LinkedHashMap<>();
+        Map<String, KeyValueHolder<Integer, String>> locations = new HashMap<>();
+        Consumer<RouteDefinition> extractor = route -> {
+            extractNamespaces(route, namespaces);
+            if (context.isDebugging()) {
+                extractSourceLocations(route, locations);
+            }
+            resolveEndpointDslUris(route);
+            if (Boolean.TRUE.equals(route.isTemplate())) {
+                Map<String, Object> parameters = route.getTemplateParameters();
+                if (parameters != null) {
+                    properties.putAll(parameters);
+                }
+            }
+        };
+
+        StringWriter buffer = new StringWriter();
+        ModelWriter writer = new ModelWriter(buffer, "http://camel.apache.org/schema/spring") {
+            @Override
+            protected void doWriteOptionalIdentifiedDefinitionAttributes(OptionalIdentifiedDefinition<?> def)
+                    throws IOException {
+                // write customId if not false
+                if (Boolean.TRUE.equals(def.getCustomId())) {
+                    doWriteAttribute("customId", toString(def.getCustomId()));
+                }
+                // write id
+                doWriteAttribute("id", def.getId());
+                // write location information
+                if (context.isDebugging()) {
+                    String id = def.getId();
+                    String loc = (def instanceof RouteDefinition ? ((RouteDefinition) def).getInput() : def).getLocation();
+                    int line = (def instanceof RouteDefinition ? ((RouteDefinition) def).getInput() : def).getLineNumber();
+                    if (line != -1) {
+                        writer.addAttribute("sourceLineNumber", Integer.toString(line));
+                        writer.addAttribute("sourceLocation", loc);
+                    }
+                }
+            }
+
+            @Override
+            protected void startElement(String name) throws IOException {
+                boolean namespaceWritten = this.namespaceWritten;
+                super.startElement(name);
+                if (!namespaceWritten) {
+                    for (Map.Entry<String, String> entry : namespaces.entrySet()) {
+                        // TODO: check duplicate xmlns="xxx" attribute ?
+                        String nsPrefix = entry.getKey();
+                        String prefix = nsPrefix.equals("xmlns") ? nsPrefix : "xmlns:" + nsPrefix;
+                        writer.addAttribute(prefix, entry.getValue());
+                    }
+                }
+            }
+
+            @Override
+            protected void doWriteValue(String value) throws IOException {
+                if (value != null && !value.isEmpty()) {
+                    super.doWriteValue(value);
+                }
+            }
+
+            @Override
+            protected void text(String text) throws IOException {
+                if (resolvePlaceholders) {
+                    text = resolve(text, properties);
+                }
+                super.text(text);
+            }
+
+            @Override
+            protected void attribute(String name, String value) throws IOException {
+                if (resolveDelegateEndpoints && "uri".equals(name)) {
+                    String uri = resolve(value, properties);
+                    Endpoint endpoint = context.hasEndpoint(uri);
+                    if (endpoint instanceof DelegateEndpoint) {
+                        endpoint = ((DelegateEndpoint) endpoint).getEndpoint();
+                        value = endpoint.getEndpointUri();
+                    }
+                }
+                if (resolvePlaceholders) {
+                    value = resolve(value, properties);
+                }
+                super.attribute(name, value);
+            }
+
+            String resolve(String value, Properties properties) {
+                context.getPropertiesComponent().setLocalProperties(properties);
+                try {
+                    return context.resolvePropertyPlaceholders(value);
+                } catch (Exception e) {
+                    return value;
+                } finally {
+                    // clear local after the route is dumped
+                    context.getPropertiesComponent().setLocalProperties(null);
+                }
+            }
+        };
+
+        // gather all namespaces from the routes or route which is stored on the expression nodes
+        if (definition instanceof RouteTemplatesDefinition templates) {
+            templates.getRouteTemplates().forEach(template -> extractor.accept(template.getRoute()));
+            writer.writeRouteTemplatesDefinition(templates);
+        } else if (definition instanceof RouteTemplateDefinition template) {
+            extractor.accept(template.getRoute());
+            writer.writeRouteTemplateDefinition(template);
+        } else if (definition instanceof RoutesDefinition routes) {
+            routes.getRoutes().forEach(extractor);
+            writer.writeRoutesDefinition(routes);
+        } else if (definition instanceof RouteDefinition route) {
+            extractor.accept(route);
+            writer.writeRouteDefinition(route);
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Extract all XML namespaces from the expressions in the route
+     *
+     * @param route      the route
+     * @param namespaces the map of namespaces to add discovered XML namespaces into
+     */
+    private static void extractNamespaces(RouteDefinition route, Map<String, String> namespaces) {
+        Collection<ExpressionNode> col = filterTypeInOutputs(route.getOutputs(), ExpressionNode.class);
+        for (ExpressionNode en : col) {
+            NamespaceAware na = getNamespaceAwareFromExpression(en);
+            if (na != null) {
+                Map<String, String> map = na.getNamespaces();
+                if (map != null && !map.isEmpty()) {
+                    namespaces.putAll(map);
+                }
+            }
+        }
+    }
+
+    /**
+     * Extract all source locations from the route
+     *
+     * @param route     the route
+     * @param locations the map of source locations for EIPs in the route
+     */
+    private static void extractSourceLocations(RouteDefinition route, Map<String, KeyValueHolder<Integer, String>> locations) {
+        // input
+        String id = route.getRouteId();
+        String loc = route.getInput().getLocation();
+        int line = route.getInput().getLineNumber();
+        if (id != null && line != -1) {
+            locations.put(id, new KeyValueHolder<>(line, loc));
+        }
+        // and then walk all nodes in the route graphs
+        for (var def : filterTypeInOutputs(route.getOutputs(), OptionalIdentifiedDefinition.class)) {
+            id = def.getId();
+            loc = def.getLocation();
+            line = def.getLineNumber();
+            if (id != null && line != -1) {
+                locations.put(id, new KeyValueHolder<>(line, loc));
+            }
+        }
+    }
+
+    /**
+     * If the route has been built with endpoint-dsl, then the model will not have uri set which then cannot be included
+     * in the JAXB model dump
+     */
+    @SuppressWarnings("rawtypes")
+    private static void resolveEndpointDslUris(RouteDefinition route) {
+        FromDefinition from = route.getInput();
+        if (from != null && from.getEndpointConsumerBuilder() != null) {
+            String uri = from.getEndpointConsumerBuilder().getRawUri();
+            from.setUri(uri);
+        }
+        Collection<SendDefinition> col = filterTypeInOutputs(route.getOutputs(), SendDefinition.class);
+        for (SendDefinition<?> to : col) {
+            if (to.getEndpointProducerBuilder() != null) {
+                String uri = to.getEndpointProducerBuilder().getRawUri();
+                to.setUri(uri);
+            }
+        }
+        Collection<ToDynamicDefinition> col2 = filterTypeInOutputs(route.getOutputs(), ToDynamicDefinition.class);
+        for (ToDynamicDefinition to : col2) {
+            if (to.getEndpointProducerBuilder() != null) {
+                String uri = to.getEndpointProducerBuilder().getRawUri();
+                to.setUri(uri);
+            }
+        }
+    }
+
+    private static NamespaceAware getNamespaceAwareFromExpression(ExpressionNode expressionNode) {
+        ExpressionDefinition ed = expressionNode.getExpression();
+
+        NamespaceAware na = null;
+        Expression exp = ed.getExpressionValue();
+        if (exp instanceof NamespaceAware) {
+            na = (NamespaceAware) exp;
+        } else if (ed instanceof NamespaceAware) {
+            na = (NamespaceAware) ed;
+        }
+
+        return na;
+    }
+
+}
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XMLWriter.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XMLWriter.java
index bdce1b84984..943bb9ff678 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XMLWriter.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XMLWriter.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayDeque;
 import java.util.Deque;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
@@ -28,12 +27,6 @@ import java.util.regex.Pattern;
  */
 public class XMLWriter {
 
-    private static final Pattern AMP = Pattern.compile("&");
-    private static final Pattern LT = Pattern.compile("<");
-    private static final Pattern GT = Pattern.compile(">");
-    private static final Pattern DQUOTE = Pattern.compile("\"");
-    private static final Pattern SQUOTE = Pattern.compile("\'");
-    private static final Pattern CRLF = Pattern.compile("\r\n");
     private static final Pattern LOWERS = Pattern.compile("([\000-\037])");
 
     private final Writer writer;
@@ -91,7 +84,7 @@ public class XMLWriter {
     public XMLWriter(Writer writer, String lineIndenter, String lineSeparator,
                      String encoding, String doctype) throws IOException {
         this.writer = writer;
-        this.lineIndenter = lineIndenter != null ? lineIndenter : "  ";
+        this.lineIndenter = lineIndenter != null ? lineIndenter : "    ";
         this.lineSeparator = validateLineSeparator(lineSeparator);
         this.encoding = encoding;
         this.docType = doctype;
@@ -177,39 +170,21 @@ public class XMLWriter {
     }
 
     private static String escapeXml(String text) {
-        if (text.indexOf('&') >= 0) {
-            text = AMP.matcher(text).replaceAll("&amp;");
-        }
-        if (text.indexOf('<') >= 0) {
-            text = LT.matcher(text).replaceAll("&lt;");
-        }
-        if (text.indexOf('>') >= 0) {
-            text = GT.matcher(text).replaceAll("&gt;");
-        }
-        if (text.indexOf('"') >= 0) {
-            text = DQUOTE.matcher(text).replaceAll("&quot;");
-        }
-        if (text.indexOf('\'') >= 0) {
-            text = SQUOTE.matcher(text).replaceAll("&apos;");
-        }
-
-        return text;
+        return text
+                .replace("&", "&amp;")
+                .replace("<", "&lt;")
+                .replace(">", "&gt;");
     }
 
     private static String escapeXmlAttribute(String text) {
-        text = escapeXml(text);
-
+        text = escapeXml(text)
+                .replace("\"", "&quot;")
+                .replace("'", "&apos;");
         // Windows
-        text = CRLF.matcher(text).replaceAll("&#10;");
-
-        StringBuilder b = new StringBuilder();
-        Matcher m = LOWERS.matcher(text);
-        while (m.find()) {
-            m.appendReplacement(b, "&#" + Integer.toString(m.group(1).charAt(0)) + ";");
-        }
-        m.appendTail(b);
-
-        return b.toString();
+        text = text.replace("\r\n", "&#10;");
+        // Non printable characters
+        text = LOWERS.matcher(text).replaceAll(r -> "&#" + Integer.toString(r.group(1).charAt(0)) + ";");
+        return text;
     }
 
     /**
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/out/BaseWriter.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/out/BaseWriter.java
index ba4cf52a033..ade6d9418d5 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/out/BaseWriter.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/out/BaseWriter.java
@@ -23,9 +23,9 @@ import org.apache.camel.xml.io.XMLWriter;
 
 public class BaseWriter {
 
-    private final XMLWriter writer;
-    private final String namespace;
-    private boolean namespaceWritten;
+    protected final XMLWriter writer;
+    protected final String namespace;
+    protected boolean namespaceWritten;
 
     public BaseWriter(Writer writer, String namespace) throws IOException {
         this.writer = new XMLWriter(writer);
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlWriterGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlWriterGeneratorMojo.java
index a833b9baebc..dbb76d1f48e 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlWriterGeneratorMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelXmlWriterGeneratorMojo.java
@@ -396,6 +396,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                 // Attributes
                 if (hasDerived && !attributes.isEmpty()) {
                     writer.addMethod()
+                            .setProtected()
                             .setReturnType(Void.TYPE)
                             .setName("doWrite" + name + "Attributes")
                             .addParameter(qgname, "def")
@@ -410,6 +411,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                 // Elements
                 if (hasDerived && !elements.isEmpty()) {
                     writer.addMethod()
+                            .setProtected()
                             .setReturnType(Void.TYPE)
                             .setName("doWrite" + name + "Elements")
                             .addParameter(qgname, "def")
@@ -441,6 +443,9 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                     .forEach(cl -> {
                         String t = cl.getSimpleName();
                         String n = cl.getAnnotation(XmlRootElement.class).name();
+                        if ("##default".equals(n)) {
+                            n = lowercase(t);
+                        }
                         elements.add("        case \"" + t + "\" -> doWrite" + t + "(\"" + n + "\", (" + t + ") v);");
                     });
             elements.add("    }");
@@ -451,6 +456,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                         .collect(Collectors.joining(", ")) + ">";
             }
             writer.addMethod()
+                    .setProtected()
                     .setReturnType(Void.TYPE)
                     .setName("doWrite" + clazz.getSimpleName() + "Ref")
                     .addParameter("String", "n")
@@ -460,6 +466,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
         });
 
         writer.addMethod()
+                .setProtected()
                 .setReturnType(Void.TYPE)
                 .setName("doWriteAttribute")
                 .addParameter(String.class, "attribute")
@@ -469,6 +476,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                         "    attribute(attribute, value);",
                         "}");
         writer.addMethod()
+                .setProtected()
                 .setReturnType(Void.TYPE)
                 .setName("doWriteValue")
                 .addParameter(String.class, "value")
@@ -477,6 +485,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                         "    text(value);",
                         "}");
         writer.addMethod()
+                .setProtected()
                 .setSignature("private <T> void doWriteList(String wrapperName, String name, List<T> list, ElementSerializer<T> elementSerializer) throws IOException")
                 .setBody("""
                             if (list != null) {
@@ -491,6 +500,7 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                                 }
                             }""");
         writer.addMethod()
+                .setProtected()
                 .setSignature("private <T> void doWriteElement(String name, T v, ElementSerializer<T> elementSerializer) throws IOException")
                 .setBody("""
                             if (v != null) {
@@ -505,28 +515,33 @@ public class ModelXmlWriterGeneratorMojo extends AbstractGeneratorMojo {
                         .setSignature("void doWriteElement(String name, T value) throws IOException");
 
         writer.addMethod()
+                .setProtected()
                 .setReturnType(String.class)
                 .setName("toString")
                 .addParameter("Boolean", "b")
                 .setBody("return b != null ? b.toString() : null;");
         writer.addMethod()
+                .setProtected()
                 .setReturnType(String.class)
                 .setName("toString")
                 .addParameter("Enum<?>", "e")
                 .setBody("return e != null ? e.name() : null;");
         writer.addMethod()
+                .setProtected()
                 .setReturnType(String.class)
                 .setName("toString")
                 .addParameter("Number", "n")
                 .setBody("return n != null ? n.toString() : null;");
         writer.addImport("java.util.Base64");
         writer.addMethod()
+                .setProtected()
                 .setReturnType(String.class)
                 .setName("toString")
                 .addParameter("byte[]", "b")
                 .setBody("return b != null ? Base64.getEncoder().encodeToString(b) : null;");
 
         writer.addMethod()
+                .setProtected()
                 .setReturnType(Void.TYPE)
                 .setName("doWriteString")
                 .addParameter(String.class, "name")