Class YamlWriter

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.yaml.io.YamlWriter
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class YamlWriter extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.CamelContextAware
YAML writer which uses Jackson to dump to yaml format. Implementation notes: This writer is based on the same principle for the XML writer which parses the Camel routes (model classes) and emit a StAX based events for start/end elements. However since the YAML DSL is not as easy to dump as XML, then we need to enrich with additional metadata from the runtime catalog (EipModel). We then abuse the EipModel and store the route details in its metadata. After this we transform from EipModel to EipNode to have a List/Map structure that we then transform to JSon, and then from JSon to YAML.
  • Field Summary

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttribute(String name, Object value)
     
    protected void
     
    protected void
     
    void
     
    void
     
    org.apache.camel.CamelContext
     
    void
    setCamelContext(org.apache.camel.CamelContext camelContext)
     
    void
    setUriAsParameters(boolean uriAsParameters)
     
    void
     
    void
     
     
    void
    writeText(String name, String text)
     
    void
     

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • YamlWriter

      public YamlWriter(Writer writer)
  • Method Details

    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.CamelContextAware
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.apache.camel.CamelContextAware
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • setUriAsParameters

      public void setUriAsParameters(boolean uriAsParameters)
    • startElement

      public void startElement(String name) throws IOException
      Throws:
      IOException
    • startExpressionElement

      public void startExpressionElement(String name) throws IOException
      Throws:
      IOException
    • endExpressionElement

      public void endExpressionElement(String name) throws IOException
      Throws:
      IOException
    • endElement

      public void endElement(String name) throws IOException
      Throws:
      IOException
    • writeText

      public void writeText(String name, String text) throws IOException
      Throws:
      IOException
    • writeValue

      public void writeValue(String value) throws IOException
      Throws:
      IOException
    • addAttribute

      public void addAttribute(String name, Object value) throws IOException
      Throws:
      IOException
    • toYaml

      public String toYaml()