public class ForEvents<T> extends EventServiceBase<CompositeEvent<T>> implements Structural, ConfigurationOwner
<oddjob id="this">
<job>
<sequential>
<jobs>
<properties name="Properties">
<values>
<file file="${some.dir}" key="data.dir"/>
</values>
</properties>
<bean class="org.oddjob.events.example.FileFactStore" id="factStore" rootDir="${data.dir}"/>
<events:when id="whenBookList" name="When BookList Available" xmlns:events="oddjob:events">
<jobs>
<bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to BookList" query="BookList:GREENGROCERS"/>
<foreach id="forEachBook" name="For Each Book">
<values>
<value value="${whenBookList.trigger.of.books}"/>
</values>
<configuration>
<inline>
<foreach id="bookName">
<job>
<events:when id="whenBook" name="When ${bookName.current}">
<jobs>
<bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Book ${bookName.current}" query="Book:${bookName.current}"/>
<events:when id="priceMatch" name="When Prices for ${bookName.current}">
<jobs>
<events:for name="For Each Trade">
<configuration>
<inline>
<events id="trade">
<job>
<bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Price for ${trade.current.product}" query="Price:${trade.current.product}"/>
</job>
</events>
</inline>
</configuration>
<values>
<value value="${whenBook.trigger.of.trades}"/>
</values>
</events:for>
<sequential name="Run Calculation">
<jobs>
<bean class="org.oddjob.events.example.ValueCalculator" id="calculate">
<trades>
<value value="${whenBook.trigger.of.trades}"/>
</trades>
<prices>
<value value="${priceMatch.trigger.ofs}"/>
</prices>
</bean>
<echo>Value of ${bookName.current} is ${calculate.value}</echo>
</jobs>
</sequential>
</jobs>
</events:when>
</jobs>
</events:when>
</job>
</foreach>
</inline>
</configuration>
</foreach>
</jobs>
</events:when>
</jobs>
</sequential>
</job>
</oddjob>
| Modifier and Type | Class and Description |
|---|---|
class |
ForEvents.LocalBean
This provides a bean for current properties.
|
| Modifier and Type | Field and Description |
|---|---|
protected ChildHelper<java.lang.Object> |
childHelper
Track changes to children and notify listeners.
|
static ArooaElement |
FOREACH_ELEMENT
Root element for configuration.
|
| Constructor and Description |
|---|
ForEvents()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOwnerStateListener(OwnerStateListener listener)
Add a listener.
|
void |
addStructuralListener(StructuralListener listener)
Add a listener.
|
Restore |
doStart(java.util.function.Consumer<? super CompositeEvent<T>> consumer) |
ArooaConfiguration |
getConfiguration() |
EventOperator<T> |
getEventOperator() |
java.io.File |
getFile() |
int |
getIndex() |
CompositeEvent<T> |
getLast() |
int |
getPurgeAfter() |
protected java.lang.Object |
loadConfigFor(java.lang.Object value)
Load a configuration for a single value.
|
protected void |
onDestroy()
Subclasses override this method to clear up resources.
|
protected void |
onReset()
Allow sub classes to do something on reset.
|
protected void |
preLoad()
Setup and load the first jobs.
|
ConfigurationSession |
provideConfigurationSession()
Provide a
ConfigurationSession. |
void |
removeOwnerStateListener(OwnerStateListener listener)
Remove a listener.
|
void |
removeStructuralListener(StructuralListener listener)
Remove a listener.
|
SerializableDesignFactory |
rootDesignFactory()
Get the design factory for the configuration.
|
ArooaElement |
rootElement()
Get the root element.
|
void |
setConfiguration(ArooaConfiguration configuration) |
void |
setEventOperator(EventOperator<T> eventOperator) |
void |
setFile(java.io.File file) |
void |
setPurgeAfter(int purgeAfter) |
void |
setValues(java.util.stream.Stream<?> values)
Add a type.
|
fireDestroyedState, getStateChanger, hardReset, iconHelper, onHardReset, onSoftReset, run, setStateException, setTo, softReset, stateHandler, stopconfigure, getName, logger, logger, loggerName, save, setName, toStringaddIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddStateListener, lastStateEvent, removeStateListenerpublic static final ArooaElement FOREACH_ELEMENT
protected transient volatile ChildHelper<java.lang.Object> childHelper
public void setValues(java.util.stream.Stream<?> values)
values - The type.public void addStructuralListener(StructuralListener listener)
addStructuralListener in interface Structurallistener - The listener.public void removeStructuralListener(StructuralListener listener)
removeStructuralListener in interface Structurallistener - The listener.public ConfigurationSession provideConfigurationSession()
ConfigurationOwnerConfigurationSession.provideConfigurationSession in interface ConfigurationOwnerConfigurationSession. May be null if no session is available.public void addOwnerStateListener(OwnerStateListener listener)
ConfigurationOwneraddOwnerStateListener in interface ConfigurationOwnerpublic void removeOwnerStateListener(OwnerStateListener listener)
ConfigurationOwnerremoveOwnerStateListener in interface ConfigurationOwnerpublic SerializableDesignFactory rootDesignFactory()
ConfigurationOwner
Note that this is a SerializableDesignFactory so that
this interface can be represented remotely.
rootDesignFactory in interface ConfigurationOwnerConfigurationSession
is available.public ArooaElement rootElement()
ConfigurationOwnerrootElement in interface ConfigurationOwnerConfigurationSession is available.protected java.lang.Object loadConfigFor(java.lang.Object value)
throws ArooaParseException
value - ArooaParseExceptionprotected void preLoad()
throws ArooaParseException
if preLoad() is 0 all will be loaded otherwise up to
that number will be loaded.
ArooaParseExceptionpublic Restore doStart(java.util.function.Consumer<? super CompositeEvent<T>> consumer)
doStart in class EventServiceBase<CompositeEvent<T>>public int getIndex()
public EventOperator<T> getEventOperator()
public void setEventOperator(EventOperator<T> eventOperator)
public CompositeEvent<T> getLast()
protected void onReset()
EventServiceBaseonReset in class EventServiceBase<CompositeEvent<T>>protected void onDestroy()
BaseComponentonDestroy in class BaseComponentpublic void setFile(java.io.File file)
Property: file
Description: The name of the configuration file. to use for configuration.
Required: No.
public java.io.File getFile()
public ArooaConfiguration getConfiguration()
public void setConfiguration(ArooaConfiguration configuration)
public int getPurgeAfter()
public void setPurgeAfter(int purgeAfter)