Beispiel #1
0
 public static String call(PageContext pc, double duration) throws FunctionException {
   if (duration >= 0) {
     SystemUtil.sleep((long) duration);
   } else
     throw new FunctionException(
         pc,
         "sleep",
         1,
         "duration",
         "attribute interval must be greater or equal to 0, now [" + (duration) + "]");
   return null;
 }
  @Override
  public void checkPermGenSpace(boolean check) {
    // print.e(Runtime.getRuntime().freeMemory());
    // Runtime.getRuntime().freeMemory()<200000 ||
    // long pgs=SystemUtil.getFreePermGenSpaceSize();
    int promille = SystemUtil.getFreePermGenSpacePromille();

    // Pen Gen Space info not available
    if (promille == -1) { // if(pgs==-1) {
      if (countLoadedPages() > 500) shrink();
    } else if (!check || promille < 50) { // else if(!check || pgs<1024*1024){
      SystemOut.printDate(
          getErrWriter(),
          "+Free Perm Gen Space is less than 1mb (free:"
              + ((SystemUtil.getFreePermGenSpaceSize()) / 1024)
              + "kb), shrink all template classloaders");
      // first just call GC and check if it help
      System.gc();
      // if(SystemUtil.getFreePermGenSpaceSize()>1024*1024)
      if (SystemUtil.getFreePermGenSpacePromille() > 50) return;

      shrink();
    }
  }
  @Override
  public Resource getSecurityDirectory() {
    Resource cacerts = null;
    // javax.net.ssl.trustStore
    String trustStore = SystemUtil.getPropertyEL("javax.net.ssl.trustStore");
    if (trustStore != null) {
      cacerts = ResourcesImpl.getFileResourceProvider().getResource(trustStore);
    }

    // security/cacerts
    if (cacerts == null || !cacerts.exists()) {
      cacerts = getConfigDir().getRealResource("security/cacerts");
      if (!cacerts.exists()) cacerts.mkdirs();
    }
    return cacerts;
  }