public class FlowBuilderSupport extends Object
| Modifier and Type | Field and Description |
|---|---|
protected FlowDefinition |
definition |
protected static ServiceCallInvocationSupport |
serviceCallInvocation |
| Constructor and Description |
|---|
FlowBuilderSupport() |
| Modifier and Type | Method and Description |
|---|---|
FlowPathDefinition |
after(Identifier id)
create a flow path for execution after of the node id
|
GoalDefinition |
check(Identifier id,
Predicate<?> goalPredicate) |
GoalDefinition |
check(Identifier id,
PredicateDefinition goalPredicate) |
static <T> Expression<T> |
constant(T constantValue) |
static EqualDefinition<Expression,Expression<Object>> |
eq(Expression actual,
Object expected) |
static EventDefinition |
event(Identifier id) |
StartTimerDefinition |
every(int interval,
TimeUnit intervalUnit)
creates a start timer with given interval and unit
|
static <T> Expression |
expression(T expression) |
protected static String |
generateId() |
GoalDefinition |
goal(Identifier id)
create a goal definition with the given id.
|
static Identifier |
id() |
static Identifier |
id(Enum id) |
static Identifier |
id(String id) |
static TrueDefinition<Expression> |
isTrue(Expression actual) |
FlowPathDefinition |
join(FlowNodeDefinition<?>... flowNodeDefinitions) |
FlowPathDefinition |
join(Identifier joinId,
FlowNodeDefinition<?>... flowNodeDefinitions) |
FlowPathDefinition |
join(Identifier joinId,
Identifier... ids)
create a flow path joining the execution after the given nodes
by introducing a new merge join to which the nodes connect.
|
FlowPathDefinition |
merge(FlowNodeDefinition<?>... nodeDefinitions) |
FlowPathDefinition |
merge(Identifier id,
FlowNodeDefinition<?>... nodeDefinitions) |
FlowPathDefinition |
merge(Identifier mergeId,
Identifier... ids)
create a flow path merging the execution after the given nodes
by introducing a new merge node to which the nodes connect.
|
static InvokeDefinition |
method(Class<?> clazz) |
CallDefinition |
method(Object returnValueOfProxyInvocation) |
FlowPathDefinition |
on(Identifier id)
create a flow path for execution after of the given event id
|
static <T extends Predicate> |
predicate(T predicate) |
static Property |
property(Identifier id) |
static <T> T |
property(Identifier id,
Class<T> clazz) |
PredicateBuilder<CallDefinition> |
resultOf(CallDefinition methodCall) |
static <T> T |
service(Class<T> clazz)
create a service proxy to be used for type-safe call definitions.
|
FlowPathDefinition |
start(AbstractEventDefinition event) |
FlowPathDefinition |
start(AbstractEventDefinition event,
StartTimerDefinition startTimerDefinition)
create a start event with the given event,
which will be started every interval with
the duration given in the timer definition.
|
FlowPathDefinition |
start(AbstractTaskDefinition task)
define task as first node in the flow
|
FlowPathDefinition |
start(Identifier startId)
create a start event with the given id.
|
FlowPathDefinition |
start(Identifier id,
AbstractTaskDefinition task,
StartTimerDefinition startTimerDefinition) |
FlowPathDefinition |
start(Identifier startId,
StartTimerDefinition startTimerDefinition)
create a start event with the given id,
which will be started every interval with
the duration given in the timer definition.
|
protected AbstractEventDefinition |
startEvent(AbstractEventDefinition<?> event) |
static TaskDefinition |
task(Identifier id) |
static TaskDefinition |
task(Identifier id,
Task callee)
create a task definition with the given task to be executed
Example:
|
protected AbstractEventDefinition |
timerEvent(AbstractEventDefinition event,
StartTimerDefinition startTimerDefinition) |
static <T> T |
val(Expression<T> expression)
add a parameter to the invocation arguments of a proxy method call definition.
|
FlowBuilderSupport |
withDefinition(FlowDefinition definition) |
protected FlowDefinition definition
protected static ServiceCallInvocationSupport serviceCallInvocation
public FlowBuilderSupport withDefinition(FlowDefinition definition)
public static Identifier id(Enum id)
public static Identifier id(String id)
public static Identifier id()
protected static String generateId()
public StartTimerDefinition every(int interval, TimeUnit intervalUnit)
interval - the intervalintervalUnit - the unitpublic FlowPathDefinition start(Identifier startId)
startId - the start event idpublic FlowPathDefinition start(Identifier startId, StartTimerDefinition startTimerDefinition)
startId - the start event idstartTimerDefinition - the timer definition defining the intervalpublic FlowPathDefinition start(AbstractEventDefinition event)
public FlowPathDefinition start(AbstractEventDefinition event, StartTimerDefinition startTimerDefinition)
event - the start event idstartTimerDefinition - the timer definition defining the intervalprotected AbstractEventDefinition startEvent(AbstractEventDefinition<?> event)
protected AbstractEventDefinition timerEvent(AbstractEventDefinition event, StartTimerDefinition startTimerDefinition)
public FlowPathDefinition start(AbstractTaskDefinition task)
task - the taskpublic FlowPathDefinition start(Identifier id, AbstractTaskDefinition task, StartTimerDefinition startTimerDefinition)
public FlowPathDefinition after(Identifier id)
id - of the node to continue afterpublic FlowPathDefinition on(Identifier id)
id - of the event to continue afterpublic FlowPathDefinition merge(Identifier mergeId, Identifier... ids)
{@literal @}Override public void define() {
start(event(id(START)))
.choice(id(CHOICE))
.when(eq(constant(x) ,"test")).execute(task(id(TASK)))
.or()
.when(eq(constant(x), "test2")).execute(task(id(TASK2)));
merge(id(MERGE), id(TASK), id(TASK2))
.end(event(id(END)));
}
mergeId - the id of the new merge nodeids - of the nodes to be mergedpublic FlowPathDefinition merge(FlowNodeDefinition<?>... nodeDefinitions)
public FlowPathDefinition merge(Identifier id, FlowNodeDefinition<?>... nodeDefinitions)
public FlowPathDefinition join(Identifier joinId, Identifier... ids)
{@literal @}Override public void define() {
start(event(id(StartEvent)))
.parallel(id(Parallel))
.execute(task(id(SecondTask)))
.and()
.execute(task(id(ThirdTask)));
join(id(Join), id(SecondTask), id(ThirdTask))
.end(event(id(EndEvent2)));
}
joinId - the id of the new join nodeids - of the nodes to be mergedpublic FlowPathDefinition join(FlowNodeDefinition<?>... flowNodeDefinitions)
public FlowPathDefinition join(Identifier joinId, FlowNodeDefinition<?>... flowNodeDefinitions)
public static TaskDefinition task(Identifier id)
public static TaskDefinition task(Identifier id, Task callee)
{@literal @}Override
public void define() {
Task callee = new Task() {
{@literal @}Override
public void execute(ExecutionContext o) {
}
};
start(event(id("start")), every(5, TimeUnit.SECONDS))
.execute(task(id("task"), callee));
}
id - the task idcallee - the callee taskpublic static EventDefinition event(Identifier id)
public static <T> Expression expression(T expression)
public static <T> Expression<T> constant(T constantValue)
public static Property property(Identifier id)
public static <T> T property(Identifier id, Class<T> clazz)
public static <T> T val(Expression<T> expression)
T - the type of the expressionexpression - the parameter expression to addpublic static EqualDefinition<Expression,Expression<Object>> eq(Expression actual, Object expected)
public static TrueDefinition<Expression> isTrue(Expression actual)
public static <T extends Predicate> PredicateDefinition<T> predicate(T predicate)
public static InvokeDefinition method(Class<?> clazz)
public CallDefinition method(Object returnValueOfProxyInvocation)
public static <T> T service(Class<T> clazz)
{@literal @}Override
public void define() {
TestService testService = service(TestService.class);
start(event(id(START)))
.execute(task(id(TASK)).call(method(testService.echo(testService.getString()))))
.end(event(id(END)));
}
T - the type of the interfaceclazz - the interface type to proxypublic PredicateBuilder<CallDefinition> resultOf(CallDefinition methodCall)
public GoalDefinition goal(Identifier id)
{@literal @}Override
public void define() {
start(id("start"))
.execute(task(id("simpleTask"))
.retryAsync(true)
.goal(id("taskExecuted")))
.end(id("end"));
goal(id("taskExecuted")).check(predicate(new GoalPredicate<Void>() {
{@literal @}Override
public boolean isFulfilled(Void aVoid) {
return true;
}
}));
}
id - the goal idpublic GoalDefinition check(Identifier id, PredicateDefinition goalPredicate)
public GoalDefinition check(Identifier id, Predicate<?> goalPredicate)
Copyright © 2015. All rights reserved.