Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
41d8d22d
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,发现更多精彩内容 >>
提交
41d8d22d
编写于
1月 30, 2013
作者:
J
Joram Barrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACT-1553: allow to override the default bpmn parser with a custom one
上级
3612d3bf
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
192 addition
and
15 deletion
+192
-15
modules/activiti-cdi/src/main/java/org/activiti/cdi/impl/event/CdiEventSupportBpmnParseHandler.java
...iviti/cdi/impl/event/CdiEventSupportBpmnParseHandler.java
+2
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/EventSubProcessParseHandler.java
...impl/bpmn/parser/handler/EventSubProcessParseHandler.java
+28
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/SubProcessParseHandler.java
...gine/impl/bpmn/parser/handler/SubProcessParseHandler.java
+2
-12
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl.java
...iviti/engine/impl/cfg/ProcessEngineConfigurationImpl.java
+41
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/history/parse/FlowNodeHistoryParseHandler.java
...ngine/impl/history/parse/FlowNodeHistoryParseHandler.java
+2
-0
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/BPMNParseHandlerTest.java
...org/activiti/standalone/parsing/BPMNParseHandlerTest.java
+2
-2
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/CustomDefaultBpmnParseHandlerTest.java
...standalone/parsing/CustomDefaultBpmnParseHandlerTest.java
+41
-0
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/CustomUserTaskBpmnParseHandler.java
...ti/standalone/parsing/CustomUserTaskBpmnParseHandler.java
+36
-0
modules/activiti-engine/src/test/resources/org/activiti/standalone/parsing/CustomDefaultBpmnParseHandlerTest.testCustomDefaultUserTaskParsing.bpmn20.xml
...seHandlerTest.testCustomDefaultUserTaskParsing.bpmn20.xml
+14
-0
modules/activiti-engine/src/test/resources/org/activiti/standalone/parsing/custom.default.parse.handler.activiti.cfg.xml
...one/parsing/custom.default.parse.handler.activiti.cfg.xml
+24
-0
未找到文件。
modules/activiti-cdi/src/main/java/org/activiti/cdi/impl/event/CdiEventSupportBpmnParseHandler.java
浏览文件 @
41d8d22d
...
...
@@ -21,6 +21,7 @@ import org.activiti.bpmn.model.CallActivity;
import
org.activiti.bpmn.model.EndEvent
;
import
org.activiti.bpmn.model.ErrorEventDefinition
;
import
org.activiti.bpmn.model.EventGateway
;
import
org.activiti.bpmn.model.EventSubProcess
;
import
org.activiti.bpmn.model.ExclusiveGateway
;
import
org.activiti.bpmn.model.InclusiveGateway
;
import
org.activiti.bpmn.model.ManualTask
;
...
...
@@ -70,6 +71,7 @@ public class CdiEventSupportBpmnParseHandler implements BpmnParseHandler {
supportedTypes
.
add
(
UserTask
.
class
);
supportedTypes
.
add
(
EndEvent
.
class
);
supportedTypes
.
add
(
SubProcess
.
class
);
supportedTypes
.
add
(
EventSubProcess
.
class
);
supportedTypes
.
add
(
CallActivity
.
class
);
supportedTypes
.
add
(
SendTask
.
class
);
supportedTypes
.
add
(
ReceiveTask
.
class
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/EventSubProcessParseHandler.java
0 → 100644
浏览文件 @
41d8d22d
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.engine.impl.bpmn.parser.handler
;
import
org.activiti.bpmn.model.BaseElement
;
import
org.activiti.bpmn.model.EventSubProcess
;
/**
* @author Joram Barrez
*/
public
class
EventSubProcessParseHandler
extends
SubProcessParseHandler
{
protected
Class
<
?
extends
BaseElement
>
getHandledType
()
{
return
EventSubProcess
.
class
;
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/SubProcessParseHandler.java
浏览文件 @
41d8d22d
...
...
@@ -12,9 +12,6 @@
*/
package
org.activiti.engine.impl.bpmn.parser.handler
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.activiti.bpmn.constants.BpmnXMLConstants
;
import
org.activiti.bpmn.model.BaseElement
;
import
org.activiti.bpmn.model.EventSubProcess
;
...
...
@@ -29,15 +26,8 @@ import org.activiti.engine.impl.pvm.process.ActivityImpl;
*/
public
class
SubProcessParseHandler
extends
AbstractActivityBpmnParseHandler
<
SubProcess
>
{
protected
static
Set
<
Class
<?
extends
BaseElement
>>
supportedTypes
=
new
HashSet
<
Class
<?
extends
BaseElement
>>();
static
{
supportedTypes
.
add
(
SubProcess
.
class
);
supportedTypes
.
add
(
EventSubProcess
.
class
);
}
public
Set
<
Class
<
?
extends
BaseElement
>>
getHandledTypes
()
{
return
supportedTypes
;
protected
Class
<
?
extends
BaseElement
>
getHandledType
()
{
return
SubProcess
.
class
;
}
protected
void
executeParse
(
BpmnParse
bpmnParse
,
SubProcess
subProcess
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl.java
浏览文件 @
41d8d22d
...
...
@@ -287,6 +287,7 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
// Bpmn parser
protected
List
<
BpmnParseHandler
>
preBpmnParseHandlers
;
protected
List
<
BpmnParseHandler
>
postBpmnParseHandlers
;
protected
List
<
BpmnParseHandler
>
customDefaultBpmnParseHandlers
;
protected
ActivityBehaviorFactory
activityBehaviorFactory
;
protected
ListenerFactory
listenerFactory
;
protected
BpmnParseFactory
bpmnParseFactory
;
...
...
@@ -785,6 +786,7 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
}
protected
List
<
BpmnParseHandler
>
getDefaultBpmnParseHandlers
()
{
// Alpabetic list of default parse handler classes
List
<
BpmnParseHandler
>
bpmnParserHandlers
=
new
ArrayList
<
BpmnParseHandler
>();
bpmnParserHandlers
.
add
(
new
BoundaryEventParseHandler
());
...
...
@@ -816,6 +818,37 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
bpmnParserHandlers
.
add
(
new
TransactionParseHandler
());
bpmnParserHandlers
.
add
(
new
UserTaskParseHandler
());
// Replace any default handler if the user wants to replace them
if
(
customDefaultBpmnParseHandlers
!=
null
)
{
Map
<
Class
<?>,
BpmnParseHandler
>
customParseHandlerMap
=
new
HashMap
<
Class
<?>,
BpmnParseHandler
>();
for
(
BpmnParseHandler
bpmnParseHandler
:
customDefaultBpmnParseHandlers
)
{
for
(
Class
<?>
handledType
:
bpmnParseHandler
.
getHandledTypes
())
{
customParseHandlerMap
.
put
(
handledType
,
bpmnParseHandler
);
}
}
for
(
int
i
=
0
;
i
<
bpmnParserHandlers
.
size
();
i
++)
{
// All the default handlers support only one type
BpmnParseHandler
defaultBpmnParseHandler
=
bpmnParserHandlers
.
get
(
i
);
if
(
defaultBpmnParseHandler
.
getHandledTypes
().
size
()
!=
1
)
{
StringBuilder
supportedTypes
=
new
StringBuilder
();
for
(
Class
<?>
type
:
defaultBpmnParseHandler
.
getHandledTypes
())
{
supportedTypes
.
append
(
" "
+
type
.
getCanonicalName
()
+
" "
);
}
throw
new
ActivitiException
(
"The default BPMN parse handlers should only support one type, but "
+
defaultBpmnParseHandler
.
getClass
()
+
" supports "
+
supportedTypes
.
toString
()
+
". This is likely a programmatic error"
);
}
else
{
Class
<?>
handledType
=
defaultBpmnParseHandler
.
getHandledTypes
().
iterator
().
next
();
if
(
customParseHandlerMap
.
containsKey
(
handledType
))
{
BpmnParseHandler
newBpmnParseHandler
=
customParseHandlerMap
.
get
(
handledType
);
log
.
info
(
"Replacing default BpmnParseHandler "
+
defaultBpmnParseHandler
.
getClass
().
getName
()
+
" with "
+
newBpmnParseHandler
.
getClass
().
getName
());
bpmnParserHandlers
.
set
(
i
,
newBpmnParseHandler
);
}
}
}
}
// History
for
(
BpmnParseHandler
handler
:
getDefaultHistoryParseHandlers
())
{
bpmnParserHandlers
.
add
(
handler
);
...
...
@@ -1482,6 +1515,14 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
this
.
preBpmnParseHandlers
=
preBpmnParseHandlers
;
}
public
List
<
BpmnParseHandler
>
getCustomDefaultBpmnParseHandlers
()
{
return
customDefaultBpmnParseHandlers
;
}
public
void
setCustomDefaultBpmnParseHandlers
(
List
<
BpmnParseHandler
>
customDefaultBpmnParseHandlers
)
{
this
.
customDefaultBpmnParseHandlers
=
customDefaultBpmnParseHandlers
;
}
public
List
<
BpmnParseHandler
>
getPostBpmnParseHandlers
()
{
return
postBpmnParseHandlers
;
}
...
...
@@ -1872,7 +1913,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
this
.
knowledgeBaseCacheLimit
=
knowledgeBaseCacheLimit
;
}
public
DeploymentCache
<
Object
>
getKnowledgeBaseCache
()
{
return
knowledgeBaseCache
;
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/history/parse/FlowNodeHistoryParseHandler.java
浏览文件 @
41d8d22d
...
...
@@ -20,6 +20,7 @@ import org.activiti.bpmn.model.BusinessRuleTask;
import
org.activiti.bpmn.model.CallActivity
;
import
org.activiti.bpmn.model.EndEvent
;
import
org.activiti.bpmn.model.EventGateway
;
import
org.activiti.bpmn.model.EventSubProcess
;
import
org.activiti.bpmn.model.ExclusiveGateway
;
import
org.activiti.bpmn.model.InclusiveGateway
;
import
org.activiti.bpmn.model.IntermediateCatchEvent
;
...
...
@@ -71,6 +72,7 @@ public class FlowNodeHistoryParseHandler implements BpmnParseHandler {
supportedElementClasses
.
add
(
CallActivity
.
class
);
supportedElementClasses
.
add
(
SubProcess
.
class
);
supportedElementClasses
.
add
(
EventSubProcess
.
class
);
}
public
Set
<
Class
<
?
extends
BaseElement
>>
getHandledTypes
()
{
...
...
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/BPMNParse
Listen
erTest.java
→
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/BPMNParse
Handl
erTest.java
浏览文件 @
41d8d22d
...
...
@@ -20,9 +20,9 @@ import org.activiti.engine.test.Deployment;
* @author Frederik Heremans
* @author Joram Barrez
*/
public
class
BPMNParse
Listen
erTest
extends
ResourceActivitiTestCase
{
public
class
BPMNParse
Handl
erTest
extends
ResourceActivitiTestCase
{
public
BPMNParse
Listen
erTest
()
{
public
BPMNParse
Handl
erTest
()
{
super
(
"org/activiti/standalone/parsing/bpmn.parse.listener.activiti.cfg.xml"
);
}
...
...
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/CustomDefaultBpmnParseHandlerTest.java
0 → 100644
浏览文件 @
41d8d22d
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.standalone.parsing
;
import
org.activiti.engine.impl.test.ResourceActivitiTestCase
;
import
org.activiti.engine.test.Deployment
;
/**
* @author Frederik Heremans
* @author Joram Barrez
*/
public
class
CustomDefaultBpmnParseHandlerTest
extends
ResourceActivitiTestCase
{
public
CustomDefaultBpmnParseHandlerTest
()
{
super
(
"org/activiti/standalone/parsing/custom.default.parse.handler.activiti.cfg.xml"
);
}
@Deployment
public
void
testCustomDefaultUserTaskParsing
()
throws
Exception
{
// The task which is created after process instance start should be async
runtimeService
.
startProcessInstanceByKey
(
"customDefaultBpmnParseHandler"
);
assertEquals
(
0
,
taskService
.
createTaskQuery
().
count
());
assertEquals
(
1
,
managementService
.
createJobQuery
().
count
());
managementService
.
executeJob
(
managementService
.
createJobQuery
().
singleResult
().
getId
());
assertEquals
(
1
,
taskService
.
createTaskQuery
().
count
());
}
}
modules/activiti-engine/src/test/java/org/activiti/standalone/parsing/CustomUserTaskBpmnParseHandler.java
0 → 100644
浏览文件 @
41d8d22d
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.activiti.standalone.parsing
;
import
org.activiti.bpmn.model.UserTask
;
import
org.activiti.engine.impl.bpmn.parser.BpmnParse
;
import
org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
/**
* @author Joram Barrez
*/
public
class
CustomUserTaskBpmnParseHandler
extends
UserTaskParseHandler
{
protected
void
executeParse
(
BpmnParse
bpmnParse
,
UserTask
userTask
)
{
// Do the regular stuff
super
.
executeParse
(
bpmnParse
,
userTask
);
// Make user tasks always async
ActivityImpl
activity
=
findActivity
(
bpmnParse
,
userTask
.
getId
());
activity
.
setAsync
(
true
);
}
}
modules/activiti-engine/src/test/resources/org/activiti/standalone/parsing/CustomDefaultBpmnParseHandlerTest.testCustomDefaultUserTaskParsing.bpmn20.xml
0 → 100644
浏览文件 @
41d8d22d
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti=
"http://activiti.org/bpmn"
xmlns:bpmndi=
"http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc=
"http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi=
"http://www.omg.org/spec/DD/20100524/DI"
typeLanguage=
"http://www.w3.org/2001/XMLSchema"
expressionLanguage=
"http://www.w3.org/1999/XPath"
targetNamespace=
"http://www.activiti.org/test"
>
<process
id=
"customDefaultBpmnParseHandler"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theTask"
/>
<userTask
id=
"theTask"
name=
"my task"
/>
<sequenceFlow
id=
"flow2"
sourceRef=
"theTask"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
modules/activiti-engine/src/test/resources/org/activiti/standalone/parsing/custom.default.parse.handler.activiti.cfg.xml
0 → 100644
浏览文件 @
41d8d22d
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
>
<bean
id=
"processEngineConfiguration"
class=
"org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"
>
<!-- Database configurations -->
<property
name=
"history"
value=
"audit"
/>
<property
name=
"databaseSchemaUpdate"
value=
"true"
/>
<!-- job executor configurations -->
<property
name=
"jobExecutorActivate"
value=
"false"
/>
<property
name=
"customDefaultBpmnParseHandlers"
>
<list>
<bean
class=
"org.activiti.standalone.parsing.CustomUserTaskBpmnParseHandler"
/>
</list>
</property>
</bean>
</beans>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录