Class SmooksDataFormat

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.dataformat.smooks.SmooksDataFormat
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.DataFormat, org.apache.camel.spi.HasCamelContext, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@Dataformat("smooks") public class SmooksDataFormat extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.DataFormat, org.apache.camel.CamelContextAware
SmooksDataFormat is a Camel data format which is a pluggable transformer capable of transforming from one dataformat to another and back again. This means that what is marshaled can be unmarshalled by an instance of this class.

A smooks configuration for a SmooksDataFormat should not utilize Smooks features such as routing that might allocate system resources. The reason for this is that there is no functionality in the SmooksDataFormat which will close those resources. If you need to use these Smooks features please take a look at the SmooksComponent or SmooksProcessor as they hook into Camels lifecycle management and will close resources correctly.

  • 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
     
    void
     
    org.apache.camel.CamelContext
     
    protected Object
    getResult(org.smooks.io.payload.Exports exports, org.smooks.api.io.Sink[] sinks, org.apache.camel.Exchange exchange)
     
     
    void
    marshal(org.apache.camel.Exchange exchange, Object fromBody, OutputStream toStream)
    Marshals the Object 'fromBody' to an OutputStream 'toStream'
    void
    setCamelContext(org.apache.camel.CamelContext camelContext)
     
    void
    setSmooksConfig(String smooksConfig)
     
    unmarshal(org.apache.camel.Exchange exchange, InputStream fromStream)
    Unmarshals the fromStream to an Object.

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

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, 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.spi.DataFormat

    unmarshal

    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

    • SmooksDataFormat

      public SmooksDataFormat()
  • Method Details

    • marshal

      public void marshal(org.apache.camel.Exchange exchange, Object fromBody, OutputStream toStream) throws Exception
      Marshals the Object 'fromBody' to an OutputStream 'toStream'

      The Camel framework will call this method from AsyncProcessorSupport.process(Exchange) and it will take care of setting the Out Message's body to the bytes written to the toStream OutputStream.

      Specified by:
      marshal in interface org.apache.camel.spi.DataFormat
      Parameters:
      exchange - The Camel Exchange.
      fromBody - The object to be marshalled into the output stream.
      toStream - The output stream that will be written to.
      Throws:
      Exception
    • unmarshal

      public Object unmarshal(org.apache.camel.Exchange exchange, InputStream fromStream)
      Unmarshals the fromStream to an Object.

      The Camel framework will call this method from AsyncProcessorSupport.process(Exchange) and it will take care of setting the returned Object on the Out Message's body.
      Specified by:
      unmarshal in interface org.apache.camel.spi.DataFormat
      Parameters:
      exchange - The Camel Exchange.
      fromStream - The InputStream that will be unmarshalled into an Object instance.
    • getResult

      protected Object getResult(org.smooks.io.payload.Exports exports, org.smooks.api.io.Sink[] sinks, org.apache.camel.Exchange exchange)
    • setCamelContext

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

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.spi.HasCamelContext
    • doStart

      public void doStart()
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
    • doStop

      public void doStop()
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
    • getSmooksConfig

      public String getSmooksConfig()
    • setSmooksConfig

      public void setSmooksConfig(String smooksConfig)