Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
z_stack
Activiti
提交
47dc61c0
A
Activiti
项目概览
z_stack
/
Activiti
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
Activiti
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
47dc61c0
编写于
12月 15, 2021
作者:
R
Rubén Barroso
提交者:
GitHub
12月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new custom juel function: list (#3783)
上级
81151c75
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
56 addition
and
5 deletion
+56
-5
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/ELContextBuilder.java
.../src/main/java/org/activiti/core/el/ELContextBuilder.java
+4
-2
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/JuelExpressionResolver.java
...ain/java/org/activiti/core/el/JuelExpressionResolver.java
+1
-1
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/ListResolverHelper.java
...rc/main/java/org/activiti/core/el/ListResolverHelper.java
+35
-0
activiti-core-common/activiti-expression-language/src/test/java/org/activiti/core/el/JuelResolverTest.java
.../src/test/java/org/activiti/core/el/JuelResolverTest.java
+14
-0
activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/el/ExpressionManager.java
...n/java/org/activiti/engine/impl/el/ExpressionManager.java
+2
-2
未找到文件。
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/ELContextBuilder.java
浏览文件 @
47dc61c0
...
...
@@ -16,6 +16,7 @@
package
org.activiti.core.el
;
import
static
org
.
activiti
.
core
.
el
.
DateResolverHelper
.
addDateFunctions
;
import
static
org
.
activiti
.
core
.
el
.
ListResolverHelper
.
addListFunctions
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
...
...
@@ -54,13 +55,14 @@ public class ELContextBuilder {
return
new
ActivitiElContext
(
elResolver
);
}
public
ELContext
buildWith
Date
Functions
()
{
public
ELContext
buildWith
Custom
Functions
()
{
CompositeELResolver
elResolver
=
createCompositeResolver
();
ActivitiElContext
elContext
=
new
ActivitiElContext
(
elResolver
);
try
{
addDateFunctions
(
elContext
);
addListFunctions
(
elContext
);
}
catch
(
NoSuchMethodException
e
)
{
logger
.
error
(
"Error setting up EL
date
functions"
,
e
);
logger
.
error
(
"Error setting up EL
custom
functions"
,
e
);
}
return
elContext
;
}
...
...
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/JuelExpressionResolver.java
浏览文件 @
47dc61c0
...
...
@@ -58,6 +58,6 @@ public class JuelExpressionResolver implements ExpressionResolver {
beanResolver
()
)
.
withVariables
(
variables
)
.
buildWith
Date
Functions
();
.
buildWith
Custom
Functions
();
}
}
activiti-core-common/activiti-expression-language/src/main/java/org/activiti/core/el/ListResolverHelper.java
0 → 100644
浏览文件 @
47dc61c0
/*
* Copyright 2010-2020 Alfresco Software, Ltd.
*
* 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.core.el
;
import
java.util.List
;
public
class
ListResolverHelper
{
private
static
final
String
LIST_FUNCTION_NAME
=
"list"
;
private
static
final
String
LIST_INVOKE_METHOD
=
"list"
;
public
static
List
<
Object
>
list
(
Object
...
objects
)
{
return
List
.
of
(
objects
);
}
private
ListResolverHelper
()
{
}
public
static
void
addListFunctions
(
ActivitiElContext
elContext
)
throws
NoSuchMethodException
{
elContext
.
setFunction
(
""
,
LIST_FUNCTION_NAME
,
ListResolverHelper
.
class
.
getMethod
(
LIST_INVOKE_METHOD
,
Object
[].
class
));
}
}
activiti-core-common/activiti-expression-language/src/test/java/org/activiti/core/el/JuelResolverTest.java
浏览文件 @
47dc61c0
...
...
@@ -21,6 +21,7 @@ import static org.hamcrest.Matchers.is;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
javax.el.ELException
;
import
javax.el.PropertyNotFoundException
;
...
...
@@ -121,4 +122,17 @@ public class JuelResolverTest {
.
isThrownBy
(()
->
expressionResolver
.
resolveExpression
(
expressionString
,
Collections
.
emptyMap
(),
Date
.
class
))
.
withMessage
(
"Could not resolve function 'current'"
);
}
@Test
public
void
should_returnList_when_expressionIsListFunction
()
{
//given
String
expressionString
=
"${list(1,'item',3)}"
;
ExpressionResolver
expressionResolver
=
new
JuelExpressionResolver
();
//when
List
result
=
expressionResolver
.
resolveExpression
(
expressionString
,
Collections
.
emptyMap
(),
List
.
class
);
//then
assertThat
(
result
).
contains
(
1
l
,
"item"
,
3
l
);
}
}
activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/el/ExpressionManager.java
浏览文件 @
47dc61c0
...
...
@@ -108,7 +108,7 @@ public class ExpressionManager {
}
protected
ActivitiElContext
createElContext
(
VariableScope
variableScope
)
{
return
(
ActivitiElContext
)
new
ELContextBuilder
().
withResolvers
(
createElResolver
(
variableScope
)).
buildWith
Date
Functions
();
return
(
ActivitiElContext
)
new
ELContextBuilder
().
withResolvers
(
createElResolver
(
variableScope
)).
buildWith
Custom
Functions
();
}
protected
ELResolver
createElResolver
(
VariableScope
variableScope
)
{
...
...
@@ -150,6 +150,6 @@ public class ExpressionManager {
public
ELContext
getElContext
(
Map
<
String
,
Object
>
availableVariables
)
{
CompositeELResolver
elResolver
=
new
CompositeELResolver
();
addBaseResolvers
(
elResolver
);
return
new
ELContextBuilder
().
withResolvers
(
elResolver
).
withVariables
(
availableVariables
).
buildWith
Date
Functions
();
return
new
ELContextBuilder
().
withResolvers
(
elResolver
).
withVariables
(
availableVariables
).
buildWith
Custom
Functions
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录