Class BusQueue<E>

java.lang.Object
org.oddjob.beanbus.destinations.BusQueue<E>
Type Parameters:
E - The type of element on the queue.
All Implemented Interfaces:
Iterable<E>, Consumer<E>, Service, Stoppable

public class BusQueue<E> extends Object implements Consumer<E>, Iterable<E>, Service
Author:
rob

Description

A Queue for beans. A work in progress.

Example

A simple example.

<oddjob>

    <job>

        <sequential>

            <jobs>

                <variables id="vars">

                    <results>

                        <list/>

                    </results>

                </variables>

                <bean class="org.oddjob.beanbus.destinations.BusQueue" id="queue"/>

                <parallel id="parallel">

                    <jobs>

                        <sequential>

                            <jobs>

                                <bean class="org.oddjob.beanbus.drivers.IterableBusDriver" id="producer" name="Producer">

                                    <values>

                                        <list>

                                            <values>

                                                <value value="apple"/>

                                                <value value="orange"/>

                                                <value value="pear"/>

                                            </values>

                                        </list>

                                    </values>

                                    <to>

                                        <value value="${queue}"/>

                                    </to>

                                </bean>

                                <stop job="${queue}" name="Stop Queue"/>

                            </jobs>

                        </sequential>

                        <bean class="org.oddjob.beanbus.drivers.IterableBusDriver" id="consumer" name="Consumer">

                            <values>

                                <value value="${queue}"/>

                            </values>

                            <to>

                                <value value="${vars.results}"/>

                            </to>

                        </bean>

                    </jobs>

                </parallel>

            </jobs>

        </sequential>

    </job>

</oddjob>
An example in BeanBus.

<oddjob>

    <job>

        <parallel id="parallel" join="true">

            <jobs>

                <bus:bus xmlns:bus="oddjob:beanbus">

                    <of>

                        <bus:driver>

                            <values>

                                <list>

                                    <values>

                                        <value value="Apple"/>

                                        <value value="Orange"/>

                                        <value value="Banana"/>

                                        <value value="Pear"/>

                                        <value value="Kiwi"/>

                                    </values>

                                </list>

                            </values>

                        </bus:driver>

                        <bus:queue id="queue"/>

                    </of>

                </bus:bus>

                <bus:bus xmlns:bus="oddjob:beanbus">

                    <of>

                        <bus:driver>

                            <values>

                                <value value="${queue}"/>

                            </values>

                        </bus:driver>

                        <bus:collect id="results"/>

                    </of>

                </bus:bus>

            </jobs>

        </parallel>

    </job>

</oddjob>
  • Constructor Details

    • BusQueue

      public BusQueue()
  • Method Details

    • start

      public void start()
      Description copied from interface: Service
      Start the service.
      Specified by:
      start in interface Service
    • stop

      public void stop()
      Description copied from interface: Stoppable
      Stop executing. This method should not return until the Stoppable has actually stopped.
      Specified by:
      stop in interface Stoppable
    • accept

      public void accept(E bean)
      Specified by:
      accept in interface Consumer<E>
    • iterator

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Iterable<E>
    • onReset

      public void onReset()
    • getSize

      public int getSize()
      Reference Property:

      Description

      The size of the queue.
      Required:
      Read only.
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getTaken

      public int getTaken()
    • setPut

      public void setPut(E item)
      Allows an item to be place on the queue with set property.
      Parameters:
      item - An item.
    • getCapacity

      public int getCapacity()
    • setCapacity

      public void setCapacity(int capacity)
    • getWaitingConsumers

      public int getWaitingConsumers()
    • toString

      public String toString()
      Overrides:
      toString in class Object