RuntimeService runtimeService = engine.getRuntimeService();
TokenQuery tokenQuery = runtimeService.createTokenQuery();
String processInstanceId = StringUtil.getString(params.get("processInstanceId"));
if(StringUtil.isNotEmpty(processInstanceId))
tokenQuery.processInstanceId(processInstanceId);
List<Token> tokenList = tokenQuery.list();
List<Map<String,Object>> result = new ArrayList<Map<String,Object>>();
for(Token tmp : tokenList){
result.add(tmp.getPersistentState());