
public final class StepBuilder extends Object
StepBuilder
instance should not be reused to build another step.
This class tries to model the jsl:Step element in job XML, while keeping a somewhat flattened structure.
Methods for setting step sub-elements resides directly under StepBuilder where possible, avoiding the need
for drilling down to sub-elements and popping back to parent context. For instance,
batchlet(String, java.util.Properties) and
batchlet(String, java.util.Properties) are directly in StepBuilder;
reader(String, java.util.Properties), processor(String, java.util.Properties),
#writer(String, String[]...), etc are directly in StepBuilder, with no intermediary chunk builder;
partitionPlan(int, int, List), #partitionMapper(String, String[]...),
partitionReducer(String, java.util.Properties), #partitionCollector(String, String[]...), etc
are directly in StepBuilder, with no intermediary partition builder.
endOn(String), stopOn(String), failOn(String),
and nextOn(String) will drill down to Transition.End,
Transition.Stop, Transition.Fail,
and Transition.Next respectively. These classes all contain a terminating method, which
pops the context back to the current StepBuilder.
This class does not support multi-threaded access or modification. Usage example,
Step step1 = new StepBuilder(step1Name).batchlet(batchlet1Name).build();
Step step2 = new StepBuilder(step2Name)
.properties(new String[]{"stepk1", "S"}, new String[]{"stepk2", "S"})
.batchlet(batchlet1Name, new String[]{"batchletk1", "B"}, new String[]{"batchletk2", "B"})
.listener("stepListener1", stepListenerProps)
.stopOn("STOP").restartFrom(step1Name).exitStatus()
.endOn("END").exitStatus("new status for end")
.failOn("FAIL").exitStatus()
.nextOn("*").to(step3Name)
.build());
Step step3 = new StepBuilder(step3Name)
.reader("integerArrayReader", new String[]{"data.count", "30"})
.writer("integerArrayWriter", new String[]{"fail.on.values", "-1"}, new String[]{"writer.sleep.time", "0"})
.processor("integerProcessor")
.checkpointPolicy("item")
.listener("chunkListener1", new String[]{"stepExitStatus", stepExitStatusExpected})
.itemCount(10)
.allowStartIfComplete()
.startLimit(2)
.skipLimit(8)
.timeLimit(2, TimeUnit.MINUTES)
.build());
Step step4 = new StepBuilder(stepName)
.reader("integerArrayReader", new String[]{"data.count", "30"},
new String[]{"partition.start", "#{partitionPlan['partition.start']}"},
new String[]{"partition.end", "#{partitionPlan['partition.end']}"})
.writer("integerArrayWriter", new String[]{"fail.on.values", "-1"}, new String[]{"writer.sleep.time", "0"})
.partitionMapper("partitionMapper1", new String[]{"partitionCount", String.valueOf(partitionCount)})
.partitionCollector("partitionCollector1")
.partitionAnalyzer("partitionAnalyzer1")
.partitionReducer("partitionReducer1")
.build())
JobBuilder,
FlowBuilder,
SplitBuilder,
DecisionBuilder| Constructor and Description |
|---|
StepBuilder(String id)
Constructs a
StepBuilder for building the step with the specified id. |
| Modifier and Type | Method and Description |
|---|---|
StepBuilder |
allowStartIfComplete(boolean... b)
Sets the
allow-start-if-complete attribute value for the step. |
StepBuilder |
batchlet(String batchletRef,
Properties props)
Sets the
batchlet for the step, with batchlet properties. |
StepBuilder |
batchlet(String batchletRef,
String[]... pairsOfKeyValue)
Sets the
batchlet for the step. |
Step |
build()
Builds the step.
|
StepBuilder |
checkpointAlgorithm(String checkpointAlgorithmRef,
Properties props)
Sets checkpoint algorithm for a chunk-type step, with checkpoint algorithm properties.
|
StepBuilder |
checkpointAlgorithm(String checkpointAlgorithmRef,
String[]... pairsOfKeyValue)
Sets checkpoint algorithm for a chunk-type step.
|
StepBuilder |
checkpointPolicy(String checkpointPolicy)
Sets checkpoint policy for a chunk-type step.
|
Transition.End<StepBuilder> |
endOn(String exitStatusCondition)
Sets
end transition condition for the step. |
Transition.Fail<StepBuilder> |
failOn(String exitStatusCondition)
Sets
fail transition condition for the step. |
StepBuilder |
itemCount(int itemCount)
Sets
item-count attribue value for a chunk-type step. |
StepBuilder |
listener(String listenerRef,
Properties props)
Adds a step listener to the step, with listener properties.
|
StepBuilder |
listener(String listenerRef,
String[]... pairsOfKeyValue)
Adds a step listener to the step.
|
StepBuilder |
next(String next)
Sets the
next attribute value for the step. |
Transition.Next<StepBuilder> |
nextOn(String exitStatusCondition)
Sets
next transition condition for the step. |
StepBuilder |
noRollbackExceptionsExclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to exclude from no-rollback exceptions.
|
StepBuilder |
noRollbackExceptionsInclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to include as no-rollback exceptions.
|
StepBuilder |
partitionAnalyzer(String partitionAnalyzerRef,
Properties props)
Sets the partition analyzer for a partitioned step, with partition analyzer properties.
|
StepBuilder |
partitionAnalyzer(String partitionAnalyzerRef,
String[]... pairsOfKeyValue)
Sets the partition analyzer for a partitioned step.
|
StepBuilder |
partitionCollector(String partitionCollectorRef,
Properties props)
Sets the partition collector for a partitioned step, with partition collector properties.
|
StepBuilder |
partitionCollector(String partitionCollectorRef,
String[]... pairsOfKeyValue)
Sets the partition collector for a partitioned step.
|
StepBuilder |
partitionMapper(String partitionMapperRef,
Properties props)
Sets the partition mapper for a partitioned step, with partition mapper properties.
|
StepBuilder |
partitionMapper(String partitionMapperRef,
String[]... pairsOfKeyValue)
Sets the partition mapper for a partitioned step.
|
StepBuilder |
partitionPlan(int partitionCount,
int... threadCount)
Sets the partition plan for a partitioned step, with optional
threadCount and without partition properties. |
StepBuilder |
partitionPlan(int partitionCount,
int threadCount,
List<Properties> listOfPartitionProps)
Sets the partition plan for a partitioned step.
|
StepBuilder |
partitionPlan(int partitionCount,
List<Properties> listOfPartitionProps)
Sets the partition plan for a partitioned step.
|
StepBuilder |
partitionReducer(String partitionReducerRef,
Properties props)
Sets the partition reducer for a partitioned step, with partition reducer properties.
|
StepBuilder |
partitionReducer(String partitionReducerRef,
String[]... pairsOfKeyValue)
Sets the partition reducer for a partitioned step.
|
StepBuilder |
processor(String processorRef,
Properties props)
Sets item processor for a chunk-type step, with item processor properties.
|
StepBuilder |
processor(String processorRef,
String[]... pairsOfKeyValue)
Sets item processor for a chunk-type step.
|
T |
properties(Properties props)
Adds all properties in java.util.Properties to the current builder.
|
T |
properties(String[]... pairsOfKeyValue)
Adds 1 or multiple properties to the current builder.
|
T |
property(String k,
String v)
Adds one single property to the current builder.
|
StepBuilder |
reader(String readerRef,
Properties props)
Sets item reader for a chunk-type step, with item reader properties.
|
StepBuilder |
reader(String readerRef,
String[]... pairsOfKeyValue)
Sets item reader for a chunk-type step.
|
StepBuilder |
retryableExceptionsExclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to exclude from retryable exceptions.
|
StepBuilder |
retryableExceptionsInclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to include as retryable.
|
StepBuilder |
retryLimit(int retryLimit)
Sets
retry-limit attribute value for a chunk-type step. |
StepBuilder |
skipLimit(int skipLimit)
Sets
skip-limit attribute value for a chunk-type step. |
StepBuilder |
skippableExceptionsExclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to exclude from skippable exceptions.
|
StepBuilder |
skippableExceptionsInclude(Class<? extends Exception>... exceptionClasses)
Adds exception classes to the chunk-type step to include as skippable.
|
StepBuilder |
startLimit(int i)
Sets the
start-limit attribute value for the step. |
Transition.Stop<StepBuilder> |
stopOn(String exitStatusCondition)
Sets
stop transition condition for the step. |
StepBuilder |
timeLimit(int timeLimit,
TimeUnit... timeUnit)
Sets
time-limit attribute value for a chunk-type step. |
StepBuilder |
writer(String writerRef,
Properties props)
Sets item writer for a chunk-type step, with item writer properties.
|
StepBuilder |
writer(String writerRef,
String[]... pairsOfKeyValue)
Sets item writer for a chunk-type step.
|
public StepBuilder(String id)
StepBuilder for building the step with the specified id.id - the step id, corresponding to the id attribute of jsl:Step element in XMLpublic StepBuilder startLimit(int i)
start-limit attribute value for the step.i - start-limit valueStepBuilderpublic StepBuilder allowStartIfComplete(boolean... b)
allow-start-if-complete attribute value for the step. This method may be invoked with 0 or 1
boolean value. Invoking allowStartIfComplete() is equivalent to allowStartIfComplete(true).b - optional boolean value for allow-start-if-complete attributeStepBuilderpublic StepBuilder next(String next)
next attribute value for the step.next - next attribute valueStepBuilderpublic StepBuilder listener(String listenerRef, String[]... pairsOfKeyValue)
listener("listener1");
listener1("listener2", new String[]{"key1", "value1"});
listener1("listener3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
listener1("listener4", new String[]{"stepListenerk1", "#{jobParameters['stepListenerPropVal']}"}
listenerRef - step listener namepairsOfKeyValue - optional listener properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder listener(String listenerRef, Properties props)
listenerRef - step listener nameprops - step listener properties, null means no propertiesStepBuilderpublic StepBuilder batchlet(String batchletRef, String[]... pairsOfKeyValue)
batchlet for the step. The batchlet may carry 0 or more properties. Each batchlet
property is represented by a 2-element string array, whose 1st element is the property key, and 2nd element is
the property value. For example,
batchlet("batchlet1");
batchlet1("batchlet2", new String[]{"key1", "value1"});
batchlet1("batchlet3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
batchlet1("batchlet4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
batchletRef - batchlet namepairsOfKeyValue - optional batchlet properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder batchlet(String batchletRef, Properties props)
batchlet for the step, with batchlet properties.batchletRef - batchlet nameprops - batchlet properties, null means no propertiesStepBuilderpublic Transition.End<StepBuilder> endOn(String exitStatusCondition)
end transition condition for the step. This method does NOT return the current StepBuilder
instance; instead, it returns an instance of Transition.End, which can be further
operated on. Invoking Transition.Termination.exitStatus(String...) will end the operation on
Transition.End and return the current StepBuilder. For example,
endOn("END").exitStatus("new status for end").<other StepBuilder methods>
exitStatusCondition - exit status condition to trigger "end" action (may contain wildcard ? and *)Transition.End<StepBuilder>Transition.End,
DecisionBuilder.endOn(java.lang.String),
FlowBuilder.endOn(String)public Transition.Fail<StepBuilder> failOn(String exitStatusCondition)
fail transition condition for the step. This method does NOT return the current StepBuilder
instance; instead, it returns an instance of Transition.Fail, which can be further
operated on. Invoking Transition.Termination.exitStatus(String...) will end the operation on
Transition.Fail and return the current StepBuilder. For example,
failOn("FAIL").exitStatus("new status for fail").<other StepBuilder methods>
exitStatusCondition - exit status condition to trigger "fail" action (may contain wildcard ? and *)Transition.Fail<StepBuilder>Transition.Fail,
DecisionBuilder.failOn(java.lang.String),
FlowBuilder.failOn(String)public Transition.Stop<StepBuilder> stopOn(String exitStatusCondition)
stop transition condition for the step. This method does NOT return the current StepBuilder
instance; instead, it returns an instance of Transition.Stop, which can be further
operated on. Invoking Transition.Termination.exitStatus(String...) will end the operation on
Transition.Stop and return the current StepBuilder. For example,
stopOn("STOP").restartFrom("step1").exitStatus().<other StepBuilder methods>
exitStatusCondition - exit status condition to trigger "stop" action (may contain wildcard ? and *)Transition.Stop<StepBuilder>Transition.Stop,
DecisionBuilder.stopOn(java.lang.String),
FlowBuilder.stopOn(String)public Transition.Next<StepBuilder> nextOn(String exitStatusCondition)
next transition condition for the step. This method does NOT return the current StepBuilder
instance; instead, it returns an instance of Transition.Next, which can be further
operated on. Invoking Transition.Next.to(String) will end the operation on
Transition.Next and return the current StepBuilder. For example,
nextOn("*").to("step2").<other StepBuilder methods>
exitStatusCondition - exit status condition to trigger "next" action(may contain wildcard ? and *)Transition.Next<StepBuilder>Transition.Next,
DecisionBuilder.nextOn(java.lang.String),
FlowBuilder.nextOn(String)public StepBuilder partitionMapper(String partitionMapperRef, String[]... pairsOfKeyValue)
partitionMapper("mapper1");
partitionMapper("partitionMapper2", new String[]{"key1", "value1"});
partitionMapper("partitionMapper3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
partitionMapper("partitionMapper4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
partitionMapperRef - partition mapper namepairsOfKeyValue - optional partition mapper properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder partitionMapper(String partitionMapperRef, Properties props)
partitionMapperRef - partition mapper nameprops - partition mapper properties, null means no propertiesStepBuilderpublic StepBuilder partitionCollector(String partitionCollectorRef, String[]... pairsOfKeyValue)
partitionCollector("partitionCollector1");
partitionCollector("partitionCollector2", new String[]{"key1", "value1"});
partitionCollector("partitionCollector3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
partitionCollector("partitionCollector4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
partitionCollectorRef - partition collector namepairsOfKeyValue - optional partition collector properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder partitionCollector(String partitionCollectorRef, Properties props)
partitionCollectorRef - partition collector nameprops - partition collector properties, null means no propertiesStepBuilderpublic StepBuilder partitionAnalyzer(String partitionAnalyzerRef, String[]... pairsOfKeyValue)
partitionAnalyzer("partitionAnalyzer1");
partitionAnalyzer("partitionAnalyzer2", new String[]{"key1", "value1"});
partitionAnalyzer("partitionAnalyzer3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
partitionAnalyzer("partitionAnalyzer4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
partitionAnalyzerRef - partition analyzer namepairsOfKeyValue - optional partition analyzer properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder partitionAnalyzer(String partitionAnalyzerRef, Properties props)
partitionAnalyzerRef - partition analyzer nameprops - partition analyzer properties, null means no propertiesStepBuilderpublic StepBuilder partitionReducer(String partitionReducerRef, String[]... pairsOfKeyValue)
partitionReducer("partitionReducer1");
partitionReducer("partitionReducer2", new String[]{"key1", "value1"});
partitionReducer("partitionAnalyzer3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
partitionAnalyzer("partitionAnalyzer4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
partitionReducerRef - partition reducer namepairsOfKeyValue - optional partition reducer properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder partitionReducer(String partitionReducerRef, Properties props)
partitionReducerRef - partition reducer nameprops - partition reducer properties, null means no propertiesStepBuilderpublic StepBuilder partitionPlan(int partitionCount, int threadCount, List<Properties> listOfPartitionProps)
listOfPartitionProps should be
ordered by partition index, i.e., listOfPartitionProps.get(0) is the partition properties for partition
with index 0, listOfPartitionProps.get(1) is the partition properties for partition
with index 1, etc.partitionCount - number of partitionsthreadCount - max number of threads for partition executionlistOfPartitionProps - list of partition propertiesStepBuilderpartitionPlan(int, List),
partitionPlan(int, int...)public StepBuilder partitionPlan(int partitionCount, List<Properties> listOfPartitionProps)
listOfPartitionProps should be
ordered by partition index, i.e., listOfPartitionProps.get(0) is the partition properties for partition
with index 0, listOfPartitionProps.get(1) is the partition properties for partition
with index 1, etc.partitionCount - number of partitionslistOfPartitionProps - list of partition propertiesStepBuilderpartitionPlan(int, int, List),
partitionPlan(int, int...)public StepBuilder partitionPlan(int partitionCount, int... threadCount)
threadCount and without partition properties.partitionCount - number of partitionsthreadCount - max number of threads for partition executionStepBuilderpartitionPlan(int, int, List),
partitionPlan(int, List)public StepBuilder reader(String readerRef, String[]... pairsOfKeyValue)
reader("reader1");
reader("reader2", new String[]{"key1", "value1"});
reader("reader3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
reader("reader4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
readerRef - item reader namepairsOfKeyValue - optional reader properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder reader(String readerRef, Properties props)
readerRef - item reader nameprops - item reader properties, null means no propertiesStepBuilderpublic StepBuilder writer(String writerRef, String[]... pairsOfKeyValue)
writer("writer1");
writer("writer2", new String[]{"key1", "value1"});
writer("writer3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
writer("writer4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
writerRef - item writer namepairsOfKeyValue - optional writer properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder writer(String writerRef, Properties props)
writerRef - item writer nameprops - item writer properties, null means no propertiesStepBuilderpublic StepBuilder processor(String processorRef, String[]... pairsOfKeyValue)
processor("processor1");
processor("processor2", new String[]{"key1", "value1"});
processor("processor3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
processor("processor4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
processorRef - item processor namepairsOfKeyValue - optional processor properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder processor(String processorRef, Properties props)
processorRef - item processor nameprops - item processor properties, null means no propertiesStepBuilderpublic StepBuilder checkpointAlgorithm(String checkpointAlgorithmRef, String[]... pairsOfKeyValue)
checkpointAlgorithm("checkpointAlgorithm1");
checkpointAlgorithm("checkpointAlgorithm2", new String[]{"key1", "value1"});
checkpointAlgorithm("checkpointAlgorithm3", new String[]{"key1", "value1"}, new String[]{"key2", "value2"});
checkpointAlgorithm("checkpointAlgorithm4", new String[]{"key1", "#{jobParameters['PropVal1']}"}
checkpointAlgorithmRef - checkpoint algorithm artifact namepairsOfKeyValue - optional properties in the form of a series of 2-element string arraysStepBuilderpublic StepBuilder checkpointAlgorithm(String checkpointAlgorithmRef, Properties props)
checkpointAlgorithmRef - checkpoint algorithm artifact nameprops - checkpoint algorithm properties, null means no propertiesStepBuilderpublic StepBuilder checkpointPolicy(String checkpointPolicy)
checkpointPolicy - checkpoint policy value, either "item" or "custom"StepBuilderpublic StepBuilder itemCount(int itemCount)
item-count attribue value for a chunk-type step.itemCount - item-count valueStepBuilderpublic StepBuilder timeLimit(int timeLimit, TimeUnit... timeUnit)
time-limit attribute value for a chunk-type step.timeLimit - time-limit valuetimeUnit - time unit such as TimeUnit.SECONDStepBuilderpublic StepBuilder skipLimit(int skipLimit)
skip-limit attribute value for a chunk-type step.skipLimit - skip-limit valueStepBuilderpublic StepBuilder retryLimit(int retryLimit)
retry-limit attribute value for a chunk-type step.retryLimit - retry-limit valueStepBuilderpublic StepBuilder skippableExceptionsInclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to include as skippableStepBuilderskippableExceptionsExclude(Class[])public StepBuilder skippableExceptionsExclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to exclude from skippable exceptionsStepBuilderskippableExceptionsInclude(Class[])public StepBuilder retryableExceptionsInclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to include as retryableStepBuilderretryableExceptionsExclude(Class[])public StepBuilder retryableExceptionsExclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to exclude from retryable exceptionsStepBuilderretryableExceptionsInclude(Class[])public StepBuilder noRollbackExceptionsInclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to include as no-rollback exceptionsStepBuildernoRollbackExceptionsExclude(Class[])public StepBuilder noRollbackExceptionsExclude(Class<? extends Exception>... exceptionClasses)
exceptionClasses - exception classes to exclude from no-rollback exceptionsStepBuildernoRollbackExceptionsInclude(Class[])public Step build()
StepBuilder should not be reused to build another step.StepBuilderpublic T property(String k, String v)
k - property keyv - property valuepublic T properties(Properties props)
props - java.util.Propertiespublic T properties(String[]... pairsOfKeyValue)
properties(new String[]{"stepk1", "value1"}, new String[]{"stepk2", "value2"})
pairsOfKeyValue - a series of 2-element string array, whose 1st element is property key, and 2nd element is property valueCopyright © 2016 JBoss by Red Hat. All rights reserved.