Class DataSonnetPipe

All Implemented Interfaces:
FrankElement, HasApplicationContext, HasName, HasTransactionAttribute, IConfigurable, IForwardTarget, IPipe, IScopeProvider, IWithParameters, NameAware, EventThrowing, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle

@EnterpriseIntegrationPattern(TRANSLATOR) public class DataSonnetPipe extends FixedForwardPipe

Using .jsonnet transformation files, the DataSonnetPipe uses JSonnet at its core to transform files from and to different file formats specified by supported outputTypes.

The pipe input message will be set to the JSON object called payload. It is required for the input message to have a correct MimeType; otherwise, the text will be interpreted as a String.

Input message (JSON) format:


 {
   "userId" : "123",
   "name" : "DataSonnet"
 }
 
Jsonnet stylesheet:

 {
   "uid": payload.userId,
   "uname": payload.name,
 }
 
Produces the following JSON output:

 {
   "uid": "123",
   "uname": "DataSonnet"
 }
 

This pipe can also call senders using their names as functions in the jsonnet file. For example:


 <DataSonnetPipe>
     <EchoSender name="myFunction" />
 </DataSonnetPipe>
 

 [
   {
     "number": sender.myFunction(x)
   } for x in [ 1, 2, 3, 4 ]
 ]
 
results in [{"number":"1"},{"number":"2"},{"number":"3"},{"number":"4"}].

See Also:
Parameters
All parameters are added to the .jsonnet stylesheet. Parameter names must be unique.
  • Constructor Details

    • DataSonnetPipe

      public DataSonnetPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from class: FixedForwardPipe
      Checks for correct configuration of forward.
      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class FixedForwardPipe
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • start

      public void start()
      Description copied from interface: IPipe
      Perform necessary action to start the pipe. This method is executed after the IConfigurable.configure() method, for each start and stop command of the adapter.
      Specified by:
      start in interface IPipe
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class AbstractPipe
    • stop

      public void stop()
      Description copied from interface: IPipe
      Perform necessary actions to stop the Pipe.
      For instance, closing JMS connections, DBMS connections etc.
      Specified by:
      stop in interface IPipe
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class AbstractPipe
    • doPipe

      public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException
      Description copied from interface: IPipe
      This is where the action takes place. Pipes may only throw a PipeRunException, to be handled by the caller of this object. Implementations must either consume the message, or pass it on to the next Pipe in the PipeRunResult.
      Throws:
      PipeRunException
    • setStyleSheetName

      @Mandatory public void setStyleSheetName(String stylesheetName)
      Location of the stylesheet to apply to the input message.
    • setOutputFileFormat

      public void setOutputFileFormat(DataSonnetOutputType outputType)
      DataSonnet is semi-capable of converting the converted JSON to a different format.
      Default value
      JSON
    • setOutputType

      @Deprecated @ConfigurationWarning("for documentation purposes we\'ve renamed this field to [outputFileFormat]") public void setOutputType(DataSonnetOutputType outputType)
      Deprecated.
    • addSender

      public void addSender(ISender sender)