|
23 | 23 | import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
24 | 24 | import org.flowable.engine.impl.delegate.ActivityBehavior;
|
25 | 25 | import org.flowable.engine.impl.delegate.TriggerableActivityBehavior;
|
| 26 | +import org.flowable.engine.impl.delegate.TriggerableJavaDelegate; |
| 27 | +import org.flowable.engine.impl.delegate.TriggerableJavaDelegateContextImpl; |
26 | 28 | import org.flowable.engine.impl.delegate.invocation.JavaDelegateInvocation;
|
27 | 29 | import org.flowable.engine.impl.util.BpmnLoggingSessionUtil;
|
28 | 30 | import org.flowable.engine.impl.util.CommandContextUtil;
|
29 | 31 |
|
30 | 32 | /**
|
31 | 33 | * @author Tom Baeyens
|
32 | 34 | */
|
33 |
| -public class ServiceTaskJavaDelegateActivityBehavior extends TaskActivityBehavior implements ActivityBehavior, ExecutionListener { |
| 35 | +public class ServiceTaskJavaDelegateActivityBehavior extends TaskActivityBehavior implements ActivityBehavior, ExecutionListener, TriggerableJavaDelegate { |
34 | 36 |
|
35 | 37 | private static final long serialVersionUID = 1L;
|
36 | 38 |
|
@@ -65,8 +67,19 @@ public void trigger(DelegateExecution execution, String signalName, Object signa
|
65 | 67 | "Triggered service task with java class " + javaDelegate.getClass().getName(), execution);
|
66 | 68 | }
|
67 | 69 |
|
68 |
| - leave(execution); |
69 |
| - |
| 70 | + } else if (triggerable && javaDelegate instanceof TriggerableJavaDelegate triggerableJavaDelegate) { |
| 71 | + TriggerableJavaDelegateContextImpl triggerableJavaDelegateContext = null; |
| 72 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 73 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_BEFORE_TRIGGER, |
| 74 | + "Triggering service task with java delegate " + triggerableJavaDelegate, execution); |
| 75 | + } |
| 76 | + triggerableJavaDelegateContext = new TriggerableJavaDelegateContextImpl(execution, signalName, signalData); |
| 77 | + triggerableJavaDelegate.trigger(triggerableJavaDelegateContext); |
| 78 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 79 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_AFTER_TRIGGER, |
| 80 | + "Triggered service task with delegate " + triggerableJavaDelegate, execution); |
| 81 | + } |
| 82 | + |
70 | 83 | } else {
|
71 | 84 | if (processEngineConfiguration.isLoggingSessionEnabled()) {
|
72 | 85 | if (!triggerable) {
|
@@ -132,4 +145,46 @@ public void execute(DelegateExecution execution) {
|
132 | 145 | public void notify(DelegateExecution execution) {
|
133 | 146 | execute(execution);
|
134 | 147 | }
|
| 148 | + |
| 149 | + @Override |
| 150 | + public void trigger(Context context) { |
| 151 | + CommandContext commandContext = CommandContextUtil.getCommandContext(); |
| 152 | + ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); |
| 153 | + |
| 154 | + if (triggerable && javaDelegate instanceof TriggerableJavaDelegate triggerableJavaDelegate) { |
| 155 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 156 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_BEFORE_TRIGGER, |
| 157 | + "Triggering service task with java delegate " + triggerableJavaDelegate, context.getExecution()); |
| 158 | + } |
| 159 | + triggerableJavaDelegate.trigger(context); |
| 160 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 161 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_AFTER_TRIGGER, |
| 162 | + "Triggered service task with delegate " + triggerableJavaDelegate, context.getExecution()); |
| 163 | + } |
| 164 | + } else if (triggerable && javaDelegate instanceof TriggerableActivityBehavior) { |
| 165 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 166 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_BEFORE_TRIGGER, |
| 167 | + "Triggering service task with java class " + javaDelegate.getClass().getName(), context.getExecution()); |
| 168 | + } |
| 169 | + |
| 170 | + ((TriggerableActivityBehavior) javaDelegate).trigger(context.getExecution(), context.getSignalName(), context.getSignalData()); |
| 171 | + |
| 172 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 173 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_AFTER_TRIGGER, |
| 174 | + "Triggered service task with java class " + javaDelegate.getClass().getName(), context.getExecution()); |
| 175 | + } |
| 176 | + } else { |
| 177 | + if (processEngineConfiguration.isLoggingSessionEnabled()) { |
| 178 | + if (!triggerable) { |
| 179 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_WRONG_TRIGGER, |
| 180 | + "Service task with java class triggered but not triggerable " + javaDelegate.getClass().getName(), context.getExecution()); |
| 181 | + |
| 182 | + } else { |
| 183 | + BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_WRONG_TRIGGER, |
| 184 | + "Service task with java class triggered but not implementing TriggerableActivityBehavior " + javaDelegate.getClass().getName(), |
| 185 | + context.getExecution()); |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + } |
135 | 190 | }
|
0 commit comments