activiti自定义函数解析juel表达式

更新时间:2023-07-04 14:42:24 阅读: 评论:0

activiti⾃定义函数解析juel表达式
activiti是⽀持juel表达式的,这个也很好⽤,但实际过程中需要⽀持类⽅法及变量。   
原来项⽬中解析juel,这边有⾃定义⼀个⽅法的
代码如下:
public String getStringByELAndFormData(String el, Map formData) throws Exception {
ExpressionFactory factory = new ExpressionFactoryImpl();
SimpleContext context = new SimpleContext();
for (Object k : formData.keySet()) {
if ((k) != null) {
context.String(),
<(k), (k).getClass()));
}
}
ValueExpression e = ateValueExpression(context, el, String.class);
return (String) e.getValue(context);
}
这种办法没有问题,但只局限于变量执⾏。但如果增加⽅法类调⽤就有问题!
如现在我有⼀个juely变量表达式,表达式为${JiebaoPost('','','')}。
该表达式需要调⽤以下类
public class FunctionOrgService {
public String getJiebaoPost(String id,String nodeFlag,String exParams){
return "82301111111";
}
}
原来解析的代码就有问题了,因为他没办法识别该函数.
解决办法如下
1. 先在processEngine初始化时,增加函数的引⼊
Map map=new HashMap();
map.put("fn_test", new FunctionOrgService());
processEngineConfiguration.tBeans(map);
李逵的绰号是什么
1. 构造变量类VariableScope 
特别说明⼀下,这个如果流程未结束,可以直接⽤流程实例对象ExecutionEntity代替,因为该类也继承了VariableScope。  这边项⽬需要流程结束也要计算juel表达式,所以只能⾃⼰构造该对象
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import ine.delegate.VariableScope;
import ine.ity.VariableInstance;
import ine.ity.VariableInstance;
public class TestVariableScope implements VariableScope{
private Map<String, Object> variables=new HashMap<String, Object>();
public TestVariableScope(Map<String, Object> variables){
this.variables=variables;
}
@Override
public Map<String, Object> getVariables() {
// TODO Auto-generated method stub
return variables;
}
@Override
public Map<String, VariableInstance> getVariableInstances() {
/*// TODO Auto-generated method stub
Map<String, VariableInstance> variableInstanceMap=new HashMap();
System.out.println("通过Set遍历key和value");
for (Map.Entry<String, Object> entry : Set()) {
VariableInstanceEntity ate( Key(), type, Value())
}*/
return null;
}
@Override
public Map<String, Object> getVariables(Collection<String> variableNames) {
// TODO Auto-generated method stub
return variables;
}
@Override
工作扩大化public Map<String, VariableInstance> getVariableInstances(Collection<String> variableNames) {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> getVariables(Collection<String> variableNames, boolean fetchAllVariables) {
// TODO Auto-generated method stub
return variables;
}
@Override
public Map<String, VariableInstance> getVariableInstances(Collection<String> variableNames,
boolean fetchAllVariables) {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> getVariablesLocal() {
// TODO Auto-generated method stub
return variables;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal() {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> getVariablesLocal(Collection<String> variableNames) {
// TODO Auto-generated method stub
return variables;
return variables;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> variableNames) {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> getVariablesLocal(Collection<String> variableNames, boolean fetchAllVariables) {        // TODO Auto-generated method stub
return variables;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> variableNames,
boolean fetchAllVariables) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getVariable(String variableName) {
// TODO Auto-generated method stub
(variableName);
}
@Override
public VariableInstance getVariableInstance(String variableName) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getVariable(String variableName, boolean fetchAllVariables) {
// TODO Auto-generated method stub
Variable(variableName);
}
@Override
public VariableInstance getVariableInstance(String variableName, boolean fetchAllVariables) {
// TODO Auto-generated method stub
return null;
}
蒸发结晶设备@Override
public Object getVariableLocal(String variableName) {
// TODO Auto-generated method stub
Variable(variableName);
}
@Override
public VariableInstance getVariableInstanceLocal(String variableName) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getVariableLocal(String variableName, boolean fetchAllVariables) {
/
/ TODO Auto-generated method stub
Variable(variableName);
}
@Override
public VariableInstance getVariableInstanceLocal(String variableName, boolean fetchAllVariables) {
public VariableInstance getVariableInstanceLocal(String variableName, boolean fetchAllVariables) {        // TODO Auto-generated method stub
return null;
}
@Override易如反掌的意思
public <T> T getVariable(String variableName, Class<T> variableClass) {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T getVariableLocal(String variableName, Class<T> variableClass) {
// TODO Auto-generated method stub
return null;
虾仁馄饨怎么做
}
@Override
public Set<String> getVariableNames() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<String> getVariableNamesLocal() {
// TODO Auto-generated method stub
return null;
}
@Override绿豆薏米
public void tVariable(String variableName, Object value) {
// TODO Auto-generated method stub
variables.put(variableName,value);
}
新生儿败血病
@Override
public void tVariable(String variableName, Object value, boolean fetchAllVariables) {
// TODO Auto-generated method stub
this.tVariable(variableName, value);
}
@Override
public Object tVariableLocal(String variableName, Object value) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object tVariableLocal(String variableName, Object value, boolean fetchAllVariables) {
// TODO Auto-generated method stub
return null;
}
@Override
public void tVariables(Map<String, ? extends Object> variables) {
// TODO Auto-generated method stub
this.variables=(Map<String, Object>) variables;
}
@Override
public void tVariablesLocal(Map<String, ? extends Object> variables) {
/
/ TODO Auto-generated method stub
this.variables=(Map<String, Object>) variables;
}
@Override
@Override
public boolean hasVariables() {
// TODO Auto-generated method stub
return variables.size()>0;
}
@Override
public boolean hasVariablesLocal() {
/
/ TODO Auto-generated method stub
return variables.size()>0;
}
@Override
public boolean hasVariable(String variableName) {
// TODO Auto-generated method stub
ainsKey(variableName);
}
@Override
public boolean hasVariableLocal(String variableName) {
// TODO Auto-generated method stub
ainsKey(variableName);
}
@Override
public void createVariableLocal(String variableName, Object value) {        // TODO Auto-generated method stub
}
@Override
public void removeVariable(String variableName) {
// TODO Auto-generated method stub
}
@Override
public void removeVariableLocal(String variableName) {
// TODO Auto-generated method stub
}
@Override
public void removeVariables(Collection<String> variableNames) {
// TODO Auto-generated method stub
}
@Override
public void removeVariablesLocal(Collection<String> variableNames) {        // TODO Auto-generated method stub
}
@Override
public void removeVariables() {
// TODO Auto-generated method stub
小兔子壁纸}
@Override
public void removeVariablesLocal() {
// TODO Auto-generated method stub
}

本文发布于:2023-07-04 14:42:24,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1078082.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:表达式   函数   需要   流程   变量   问题   办法   解析
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图