|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ElementGenerator
A interface to be implemented by objects which encapsulate a workflow process template that generates elements for processing. For example, a template process might produce records from a file for processing.
A user-provided closure call back is passed in on process execution and is called to insert custom processing within the template.
For example, the following code snippet demonstrates a generator that
produces parsed csv records from an underlying file resource. In this case,
this recordGenerator encapsulates required resource management
(opening/closing resources) and the algorithm to parse / iterate over
records. The results (a single parsed record) are passed to the callback for
processing.
ElementGenerator recordGenerator = new CsvRecordGenerator(new FileSystemResource(file));
recordGenerator.run(new Block() {
protected void handle(Object csvRecord) {
// process each record
}
});
This is a generic equivalent to approaches used throughout The Spring
Framework, including Spring's JDBC Template for processing DB query result
sets. In addition to providing a common callback interface, it is intended
for convenience in situations where defining a separate callback hierarchy to
support a template callback approach is overkill.
| Method Summary | |
|---|---|
boolean |
allTrue(Constraint constraint)
Does this process produce all elements matching the given criteria? |
boolean |
anyTrue(Constraint constraint)
Does this process produce an element matching the given criteria? |
ElementGenerator |
findAll(Constraint constraint)
Find all elements produced by ths template that match the specified criteria. |
Object |
findFirst(Constraint constraint)
Find the first element that matches the given criteria. |
Object |
findFirst(Constraint constraint,
Object defaultIfNoneFound)
Find the first element that matches the given criteria, return defaultIfNoneFound if none found. |
void |
runUntil(Closure templateCallback,
Constraint constraint)
Execute the template until the specified condition is true |
void |
stop()
Stop this process after it has started. |
| Methods inherited from interface org.springframework.rules.closure.ClosureTemplate |
|---|
run |
| Method Detail |
|---|
boolean anyTrue(Constraint constraint)
constraint - the criteria
true if yes, false otherwiseboolean allTrue(Constraint constraint)
constraint - the criteria
true if yes, false otherwiseObject findFirst(Constraint constraint)
constraint - the criteria
Object findFirst(Constraint constraint,
Object defaultIfNoneFound)
defaultIfNoneFound if none found.
constraint - the constraintdefaultIfNoneFound - none found object
ElementGenerator findAll(Constraint constraint)
constraint - the criteria
void runUntil(Closure templateCallback,
Constraint constraint)
templateCallback - the callbackconstraint - the constraint condition
void stop()
throws IllegalStateException
IllegalStateException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||