Пример #1
0
  /**
   * @param objs
   * @return
   */
  private static String buildKey(String base, Object... objs) {
    // the getCaller thing is relatively expensive, as it might take
    // hundreds of us to complete.

    String caller = base;
    if (base == null) caller = StackTraceUtils.getCaller2(); // tricky and expensive
    for (Object o : objs) {
      caller += "-" + String.valueOf(o);
    }
    return caller;
  }
Пример #2
0
  /**
   * run a piece of rendering code with cache check and refilling
   *
   * @param runner
   * @param ttl
   * @param objects
   * @deprecated use CacheableRunner directly in actions
   */
  protected static void runWithCache(ActionRunner runner, String ttl, Object... objects) {
    if (ttl == null || ttl.trim().length() == 0)
      throw new RuntimeException("Cache expiration time must be defined.");

    ttl = ttl.trim();
    if (Character.isDigit(ttl.charAt(ttl.length() - 1))) {
      // assuming second
      ttl += "s";
    }

    String base = StackTraceUtils.getCaller();
    RenderResult rr = getFromCache(base, objects);
    if (rr == null) {
      rr = runner.run();
      cache(rr, ttl, base, objects);
    }
    // System.out.println("render show took ms: " + rr.getRenderTime());
    throw new JapidResult(rr);
  }
Пример #3
0
 private static String findTemplate() {
   String japidRenderInvoker = StackTraceUtils.getJapidRenderInvoker();
   return japidRenderInvoker;
 }