Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-7999 Camel Toolbox - Easy information about all Camel components and the release for tooling
  3. CAMEL-8197

Create Maven plugin to inject EIP documentation into the spring and blueprint XML DSL

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.15.0
    • eip, tooling
    • None
    • Unknown

    Description

      So we can include documentation out of the box in the XSD schema files, which allows end users to better work with Camel, as their IDE editors can show the documentation in the IDE.

      To do this we need to

      1)
      Create a new Maven plugin at
      https://github.com/apache/camel/tree/master/tooling/maven

      which can be inspired by
      https://github.com/apache/camel/tree/master/tooling/maven/camel-package-maven-plugin

      2)
      Run this plugin in camel-spring and camel-blueprint, so it can read the camel-spring.xsd, camel-blueprint.xsd file, and inject documentation.

      3)
      Parse the XSD maybe using SAX, and inject the documentation.

      For each xs:element in the top of the schema file
      http://camel.apache.org/schema/spring/camel-spring.xsd

      Then use the name, eg (name=split)

      <xs:element name="split" type="tns:splitDefinition"/>
      

      To find the split.json file in camel-core. Then the json file has the documentation for that type (including inherited types).

      So for the split definition

      <xs:complexType name="splitDefinition">
      <xs:complexContent>
      <xs:extension base="tns:expressionNode">
      <xs:sequence/>
      <xs:attribute name="parallelProcessing" type="xs:boolean"/>
      <xs:attribute name="strategyRef" type="xs:string"/>
      <xs:attribute name="strategyMethodName" type="xs:string"/>
      <xs:attribute name="strategyMethodAllowNull" type="xs:boolean"/>
      <xs:attribute name="executorServiceRef" type="xs:string"/>
      <xs:attribute name="streaming" type="xs:boolean"/>
      <xs:attribute name="stopOnException" type="xs:boolean"/>
      <xs:attribute name="timeout" type="xs:long"/>
      <xs:attribute name="onPrepareRef" type="xs:string"/>
      <xs:attribute name="shareUnitOfWork" type="xs:boolean"/>
      <xs:anyAttribute namespace="##other" processContents="skip"/>
      </xs:extension>
      </xs:complexContent>
      </xs:complexType>
      

      We can find the description of these attributes, and elements from the json file.

      For example for the streaming attribute we have

       "streaming": { "kind": "attribute": "required": "false", "type": "boolean", "javaType": "java.lang.Boolean", "description": "The splitter should use streaming -- exchanges are being sent as the data for them becomes available. This improves throughput and memory usage but it has a drawback: - the sent exchanges will no longer contain the link org.apache.camel.ExchangeSPLIT_SIZE header property"
      

      Then add the needed xs:annotation to document it.
      http://www.w3schools.com/schema/el_annotation.asp

      Which should be

      <xs:annotation>
        <xs:documentation xml:lang="en">
      The splitter should use streaming -- exchanges are being sent as the data for them becomes available. This improves throughput and memory usage but it has a drawback: - the sent exchanges will no longer contain the link org.apache.camel.ExchangeSPLIT_SIZE header property  
        </xs:documentation>
      </xs:annotation>
      

      Notice that the xsd will become bigger due the verbosity of how to annotate xsd fields.

      Mind that sometimes there is not yet documentation, so check for not empty value.

      To parse the json file, then use this class from camel-core

      List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("properties", json, true);
      

      Then you have a map with key/value for all those values.

      Attachments

        Issue Links

          Activity

            People

              njiang Willem Jiang
              davsclaus Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: