Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
8e2242ca
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8e2242ca
编写于
9月 10, 2014
作者:
T
Tijs Rademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'TASK_TIMEOUT' of
https://github.com/martin-grofcik/Activiti
上级
976312e9
a49c04d7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
160 addition
and
22 deletion
+160
-22
modules/activiti-engine/src/main/java/org/activiti/engine/impl/jobexecutor/TimerExecuteNestedActivityJobHandler.java
...mpl/jobexecutor/TimerExecuteNestedActivityJobHandler.java
+33
-13
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/event/ActivityEventsTest.java
...rg/activiti/engine/test/api/event/ActivityEventsTest.java
+79
-9
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/event/ActivityEventsTest.testActivityTimeOutEventInCallActivity.bpmn20.xml
...ntsTest.testActivityTimeOutEventInCallActivity.bpmn20.xml
+48
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/impl/jobexecutor/TimerExecuteNestedActivityJobHandler.java
浏览文件 @
8e2242ca
...
...
@@ -72,20 +72,40 @@ public class TimerExecuteNestedActivityJobHandler implements JobHandler {
if
(
boundaryActivityBehavior
instanceof
BoundaryEventActivityBehavior
)
{
BoundaryEventActivityBehavior
boundaryEventActivityBehavior
=
(
BoundaryEventActivityBehavior
)
boundaryActivityBehavior
;
if
(
boundaryEventActivityBehavior
.
isInterrupting
())
{
ActivityImpl
activity
=
execution
.
getActivity
();
if
(
activity
!=
null
&&
activity
.
getActivityBehavior
()
!=
null
)
{
commandContext
.
getEventDispatcher
().
dispatchEvent
(
ActivitiEventBuilder
.
createActivityEvent
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
execution
.
getActivity
().
getId
(),
(
String
)
activity
.
getProperties
().
get
(
"name"
),
execution
.
getId
(),
execution
.
getProcessInstanceId
(),
execution
.
getProcessDefinitionId
(),
(
String
)
activity
.
getProperties
().
get
(
"type"
),
activity
.
getActivityBehavior
().
getClass
().
getCanonicalName
()));
}
dispatchExecutionTimeOut
(
execution
,
commandContext
);
}
}
}
protected
void
dispatchExecutionTimeOut
(
ExecutionEntity
execution
,
CommandContext
commandContext
)
{
// subprocesses
for
(
ExecutionEntity
subExecution
:
execution
.
getExecutions
())
{
dispatchExecutionTimeOut
(
subExecution
,
commandContext
);
}
// call activities
ExecutionEntity
subProcessInstance
=
commandContext
.
getExecutionEntityManager
().
findSubProcessInstanceBySuperExecutionId
(
execution
.
getId
());
if
(
subProcessInstance
!=
null
)
{
dispatchExecutionTimeOut
(
subProcessInstance
,
commandContext
);
}
// activity with timer boundary event
ActivityImpl
activity
=
execution
.
getActivity
();
if
(
activity
!=
null
&&
activity
.
getActivityBehavior
()
!=
null
)
{
dispatchActivityTimeOut
(
activity
,
execution
,
commandContext
);
}
}
protected
void
dispatchActivityTimeOut
(
ActivityImpl
activity
,
ExecutionEntity
execution
,
CommandContext
commandContext
)
{
commandContext
.
getEventDispatcher
().
dispatchEvent
(
ActivitiEventBuilder
.
createActivityEvent
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
activity
.
getId
(),
(
String
)
activity
.
getProperties
().
get
(
"name"
),
execution
.
getId
(),
execution
.
getProcessInstanceId
(),
execution
.
getProcessDefinitionId
(),
(
String
)
activity
.
getProperties
().
get
(
"type"
),
activity
.
getActivityBehavior
().
getClass
().
getCanonicalName
())
);
}
}
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/event/ActivityEventsTest.java
100644 → 100755
浏览文件 @
8e2242ca
...
...
@@ -12,19 +12,17 @@
*/
package
org.activiti.engine.test.api.event
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.List
;
import
org.activiti.engine.delegate.event.ActivitiActivityEvent
;
import
org.activiti.engine.delegate.event.ActivitiErrorEvent
;
import
org.activiti.engine.delegate.event.ActivitiEvent
;
import
org.activiti.engine.delegate.event.ActivitiEventType
;
import
org.activiti.engine.delegate.event.ActivitiMessageEvent
;
import
org.activiti.engine.delegate.event.ActivitiSignalEvent
;
import
org.activiti.engine.delegate.event.*
;
import
org.activiti.engine.delegate.event.impl.ActivitiActivityEventImpl
;
import
org.activiti.engine.event.EventLogEntry
;
import
org.activiti.engine.impl.event.logger.EventLogger
;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.runtime.Execution
;
import
org.activiti.engine.runtime.Job
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.test.Deployment
;
...
...
@@ -472,9 +470,81 @@ public class ActivityEventsTest extends PluggableActivitiTestCase {
assertEquals
(
processInstance
.
getProcessDefinitionId
(),
errorEvent
.
getProcessDefinitionId
());
assertFalse
(
processInstance
.
getId
().
equals
(
errorEvent
.
getExecutionId
()));
}
protected
void
assertDatabaseEventPresent
(
ActivitiEventType
eventType
)
{
@Deployment
(
resources
=
"org/activiti/engine/test/api/event/JobEventsTest.testJobEntityEvents.bpmn20.xml"
)
public
void
testActivityTimeOutEvent
(){
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"testJobEvents"
);
Job
theJob
=
managementService
.
createJobQuery
().
processInstanceId
(
processInstance
.
getId
()).
singleResult
();
assertNotNull
(
theJob
);
// Force timer to fire
Calendar
tomorrow
=
Calendar
.
getInstance
();
tomorrow
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
processEngineConfiguration
.
getClock
().
setCurrentTime
(
tomorrow
.
getTime
());
waitForJobExecutorToProcessAllJobs
(
2000
,
100
);
// Check timeout has been dispatched
assertEquals
(
1
,
listener
.
getEventsReceived
().
size
());
ActivitiEvent
timeOutEvent
=
listener
.
getEventsReceived
().
get
(
0
);
assertEquals
(
"ACTIVITY_TIMEOUT evet expected"
,
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
}
@Deployment
(
resources
=
"org/activiti/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testTimerOnNestingOfSubprocesses.bpmn20.xml"
)
public
void
testActivityTimeOutEventInSubProcess
()
{
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"timerOnNestedSubprocesses"
);
Job
theJob
=
managementService
.
createJobQuery
().
processInstanceId
(
processInstance
.
getId
()).
singleResult
();
assertNotNull
(
theJob
);
// Force timer to fire
Calendar
timeToFire
=
Calendar
.
getInstance
();
timeToFire
.
add
(
Calendar
.
HOUR
,
2
);
timeToFire
.
add
(
Calendar
.
SECOND
,
5
);
processEngineConfiguration
.
getClock
().
setCurrentTime
(
timeToFire
.
getTime
());
waitForJobExecutorToProcessAllJobs
(
2000
,
100
);
// Check timeout-events have been dispatched
assertEquals
(
3
,
listener
.
getEventsReceived
().
size
());
ActivitiActivityEventImpl
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
0
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerTask1"
,
timeOutEvent
.
getActivityId
());
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
1
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerTask2"
,
timeOutEvent
.
getActivityId
());
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
2
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerFork"
,
timeOutEvent
.
getActivityId
());
}
@Deployment
public
void
testActivityTimeOutEventInCallActivity
()
{
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"timerOnCallActivity"
);
Job
theJob
=
managementService
.
createJobQuery
().
processInstanceId
(
processInstance
.
getId
()).
singleResult
();
assertNotNull
(
theJob
);
// Force timer to fire
Calendar
timeToFire
=
Calendar
.
getInstance
();
timeToFire
.
add
(
Calendar
.
HOUR
,
2
);
timeToFire
.
add
(
Calendar
.
SECOND
,
5
);
processEngineConfiguration
.
getClock
().
setCurrentTime
(
timeToFire
.
getTime
());
waitForJobExecutorToProcessAllJobs
(
200000
,
100
);
// Check timeout-events have been dispatched
assertEquals
(
4
,
listener
.
getEventsReceived
().
size
());
ActivitiActivityEventImpl
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
0
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerTask1"
,
timeOutEvent
.
getActivityId
());
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
1
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerTask2"
,
timeOutEvent
.
getActivityId
());
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
2
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"innerFork"
,
timeOutEvent
.
getActivityId
());
timeOutEvent
=
(
ActivitiActivityEventImpl
)
listener
.
getEventsReceived
().
get
(
3
);
assertEquals
(
ActivitiEventType
.
ACTIVITY_TIMEOUT
,
timeOutEvent
.
getType
());
assertEquals
(
"callActivity"
,
timeOutEvent
.
getActivityId
());
}
protected
void
assertDatabaseEventPresent
(
ActivitiEventType
eventType
)
{
String
eventTypeString
=
eventType
.
name
();
List
<
EventLogEntry
>
eventLogEntries
=
managementService
.
getEventLogEntries
(
0L
,
100000L
);
boolean
found
=
false
;
...
...
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/event/ActivityEventsTest.testActivityTimeOutEventInCallActivity.bpmn20.xml
0 → 100755
浏览文件 @
8e2242ca
<?xml version="1.0" encoding="UTF-8"?>
<definitions
id=
"definitions"
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"Examples"
>
<process
id=
"timerOnCallActivity"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"callActivity"
/>
<sequenceFlow
id=
"flow3"
sourceRef=
"callActivity"
targetRef=
"theEnd"
/>
<callActivity
id=
"callActivity"
calledElement=
"subprocess"
/>
<boundaryEvent
id=
"boundaryTimer"
cancelActivity=
"true"
attachedToRef=
"callActivity"
>
<timerEventDefinition>
<timeDuration>
PT2H
</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow
id=
"flow2"
sourceRef=
"boundaryTimer"
targetRef=
"taskAfterCatch"
/>
<userTask
id=
"taskAfterCatch"
name=
"task outside subprocess"
/>
<endEvent
id=
"theEnd"
/>
</process>
<process
id=
"subprocess"
>
<startEvent
id=
"subprocessStart"
/>
<sequenceFlow
id=
"subFlow1"
sourceRef=
"subprocessStart"
targetRef=
"innerSubprocess"
/>
<subProcess
id=
"innerSubprocess"
>
<startEvent
id=
"innerSubprocessStart"
/>
<sequenceFlow
id=
"innerSubFlow1"
sourceRef=
"innerSubprocessStart"
targetRef=
"innerFork"
/>
<parallelGateway
id=
"innerFork"
/>
<sequenceFlow
id=
"innerSubFlow2"
sourceRef=
"innerFork"
targetRef=
"innerTask1"
/>
<sequenceFlow
id=
"innerSubFlow3"
sourceRef=
"innerFork"
targetRef=
"innerTask2"
/>
<userTask
id=
"innerTask1"
name=
"Inner subprocess task 1"
/>
<userTask
id=
"innerTask2"
name=
"Inner subprocess task 2"
/>
</subProcess>
</process>
</definitions>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录