-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathWaitingInternalChannelWorkflowState.java
More file actions
46 lines (39 loc) · 1.74 KB
/
WaitingInternalChannelWorkflowState.java
File metadata and controls
46 lines (39 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package io.iworkflow.integ.internalchannel;
import io.iworkflow.core.Context;
import io.iworkflow.core.StateDecision;
import io.iworkflow.core.WorkflowState;
import io.iworkflow.core.command.CommandRequest;
import io.iworkflow.core.command.CommandResults;
import io.iworkflow.core.communication.Communication;
import io.iworkflow.core.communication.InternalChannelCommand;
import io.iworkflow.core.communication.InternalChannelCommandResult;
import io.iworkflow.core.persistence.Persistence;
public class WaitingInternalChannelWorkflowState implements WorkflowState<Integer> {
@Override
public Class<Integer> getInputType() {
return Integer.class;
}
@Override
public CommandRequest waitUntil(
Context context,
Integer input,
Persistence persistence,
final Communication communication) {
return CommandRequest.forAllCommandCompleted(
InternalChannelCommand.create(WaitingInternalChannelWorkflow.INTER_STATE_CHANNEL_NAME),
InternalChannelCommand.create(WaitingInternalChannelWorkflow.INTER_STATE_CHANNEL_NAME)
);
}
@Override
public StateDecision execute(
Context context,
Integer input,
CommandResults commandResults,
Persistence persistence,
final Communication communication) {
final InternalChannelCommandResult result1 = commandResults.getAllInternalChannelCommandResult().get(0);
final InternalChannelCommandResult result2 = commandResults.getAllInternalChannelCommandResult().get(1);
Integer output = input + (Integer) result1.getValue().get() + (Integer) result2.getValue().get();
return StateDecision.gracefulCompleteWorkflow(output);
}
}