Ejemplo n.º 1
0
 /**
  * 在这个处理方法中,一个Policy包含了 组合的Conditions和组合的Actions, 所以返回是执行的结果集列表
  *
  * @param policyContext
  * @return List<PolicyResult>
  */
 private List<PolicyResult> processPolicyAction(PolicyContext policyContext) {
   List<PolicyAction> policyActions = policyContext.getPolicyActions();
   List<PolicyResult> policyResults = new ArrayList<>();
   for (PolicyAction policyAction : policyActions) {
     String actionId = policyAction.getId();
     ActionEntry actionEntry = policyXmlManager.queryActionById(actionId);
     if (actionEntry != null) {
       String classPath = actionEntry.getClassPath();
       try {
         Policy policy = getPolicy(actionId, classPath);
         PolicyResult policyResult = policy.execute(policyContext);
         // 一个Policy执行结果放入结果集里
         policyResults.add(policyResult);
       } catch (Exception en) {
         LOG.error("锻造对象失败{}", en.getMessage());
       }
     }
   }
   return policyResults;
 }