Class TransformerScript<F,T>

java.lang.Object
org.oddjob.beanbus.AbstractFilter<F,T>
org.oddjob.beanbus.destinations.TransformerScript<F,T>
Type Parameters:
F - The from type.
T - The to type.
All Implemented Interfaces:
Consumer<F>, BusFilter<F,T>, Outbound<T>

public class TransformerScript<F,T> extends AbstractFilter<F,T>
Author:
rob

Description

Provide a Script as an BusFilter. This is a work in progress and probably isn't really necessary as the existing Map Component can be used with a script passed in as a function.

Example

A simple example.
<oddjob>

    <job>

        <bus:bus id="bean-bus" xmlns:bus="oddjob:beanbus">

            <of>

                <bus:driver>

                    <values>

                        <list>

                            <values>

                                <bean class="org.oddjob.beanbus.example.Fruit" quantity="42" type="Apple"/>

                                <bean class="org.oddjob.beanbus.example.Fruit" quantity="24" type="Banana"/>

                                <bean class="org.oddjob.beanbus.example.Fruit" quantity="15" type="Pear"/>

                            </values>

                        </list>

                    </values>

                </bus:driver>

                <bean class="org.oddjob.beanbus.destinations.TransformerScript">function apply(from) {

  if (from.quantity > 25) {

    return null;

  }

  else {

    return from;

  }

}</bean>

                <bus:collect id="results"/>

            </of>

        </bus:bus>

    </job>

</oddjob>
  • Constructor Details

    • TransformerScript

      public TransformerScript()
  • Method Details