Package org.apache.camel.yaml.io
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String name, Object value) protected voiddoStart()protected voiddoStop()voidendElement(String name) voidendExpressionElement(String name) org.apache.camel.CamelContextvoidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetUriAsParameters(boolean uriAsParameters) voidstartElement(String name) voidstartExpressionElement(String name) toYaml()voidvoidwriteValue(String value) 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
YamlWriter
-
-
Method Details
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
setUriAsParameters
public void setUriAsParameters(boolean uriAsParameters) -
startElement
- Throws:
IOException
-
startExpressionElement
- Throws:
IOException
-
endExpressionElement
- Throws:
IOException
-
endElement
- Throws:
IOException
-
writeText
- Throws:
IOException
-
writeValue
- Throws:
IOException
-
addAttribute
- Throws:
IOException
-
toYaml
-