public final class JobBuilder extends Object
JobBuilder
instance
should not be reused to build another job.
Unlike XML JSL, jobs built programmatically with this builder and other related builder classes do not support
JSL inheritance, nor artifacts written in scripting languages.
This class does not support multi-threaded access or modification. Usage example,
Job job = new JobBuilder(jobName) .restartable(false) .property("jobk1", "J") .property("jobk2", "J") .listener("jobListener1", new String[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"}, new String[]{"jobListenerk2", "#{jobParameters['jobListenerPropVal']}"}) .step(new StepBuilder(stepName) .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(stepName).exitStatus() .endOn("END").exitStatus("new status for end") .failOn("FAIL").exitStatus() .nextOn("*").to(step2Name) .build()) .step(new StepBuilder(step2Name) .batchlet(batchlet1Name) .build()) .build();
StepBuilder
,
FlowBuilder
,
SplitBuilder
,
DecisionBuilder
Constructor and Description |
---|
JobBuilder(String id)
Constructs a
JobBuilder for building the job with the specified id . |
Modifier and Type | Method and Description |
---|---|
Job |
build()
Builds the job.
|
JobBuilder |
decision(Decision decision)
Adds a decision to the job.
|
JobBuilder |
flow(Flow flow)
Adds a flow to the job.
|
JobBuilder |
listener(String listenerRef,
Properties props)
Adds a job listener to the job, with listener properties.
|
JobBuilder |
listener(String listenerRef,
String[]... pairsOfKeyValue)
Adds a job listener to the job.
|
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.
|
JobBuilder |
restartable(boolean... b)
Sets the
restartable attribute value on the job. |
JobBuilder |
split(Split split)
Adds a split to the job.
|
JobBuilder |
step(Step step)
Adds a step to the job.
|
public JobBuilder(String id)
JobBuilder
for building the job with the specified id
.id
- the job id, corresponding to the id attribute of jsl:Job element in XMLpublic JobBuilder restartable(boolean... b)
restartable
attribute value on the job. This method may be invoked with 0 or 1 boolean parameter.
restartable()
is equivalent to restartable(true)
.b
- optional restartable value (true or false)JobBuilder
public JobBuilder 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[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"}
listenerRef
- job listener namepairsOfKeyValue
- optional listener properties in the form of a series of 2-element string arraysJobBuilder
public JobBuilder listener(String listenerRef, Properties props)
listenerRef
- job listener nameprops
- job listener properties, null means no propertiesJobBuilder
public JobBuilder step(Step step)
StepBuilder
.step
- a pre-built stepJobBuilder
public JobBuilder decision(Decision decision)
DecisionBuilder
.decision
- a pre-built decisionJobBuilder
public JobBuilder flow(Flow flow)
FlowBuilder
.flow
- a pre-built flowJobBuilder
public JobBuilder split(Split split)
SplitBuilder
.split
- a pre-built splitJobBuilder
public Job build()
JobBuilder
should not be used to build another job.JobBuilder
public 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 © 2015 JBoss by Red Hat. All rights reserved.