Example #1
0
 public static boolean doGuardsPass(Object actionBean, Method method, @Nullable GuardType type) {
   List<Guard> guards = getGuards(method, type);
   boolean pass = true;
   OgnlContext ognlContext = ElementsThreadLocals.getOgnlContext();
   for (Guard guard : guards) {
     Object result = OgnlUtils.getValueQuietly(guard.test(), ognlContext, actionBean);
     pass &= result instanceof Boolean && ((Boolean) result);
   }
   return pass;
 }
Example #2
0
 public static List<Guard> getGuards(Method method, GuardType type) {
   List<Guard> guardList = new ArrayList<Guard>();
   Guard guard = method.getAnnotation(Guard.class);
   if (guard != null && (type == null || type == guard.type())) {
     guardList.add(guard);
   } else {
     Guards guards = method.getAnnotation(Guards.class);
     if (guards != null) {
       for (Guard g : guards.value()) {
         if (type == null || type == g.type()) {
           guardList.add(g);
         }
       }
     }
   }
   return guardList;
 }