Package cn.bran.japid.rendererloader

Examples of cn.bran.japid.rendererloader.TemplateClassLoader


    // the template may refer to model classes etc available only from the
    // parent class loader
    ClassLoader cl = _parentClassLoader == null ? JapidRenderer.class.getClassLoader() : _parentClassLoader;
    // do I need to new instance of TemplateClassLoader for each invocation?
    // likely...
    TemplateClassLoader classReloader = new TemplateClassLoader(cl);
    try {
      Class<JapidTemplateBaseWithoutPlay> loadClass = (Class<JapidTemplateBaseWithoutPlay>) classReloader
          .loadClass(rc.getClassName());
      rc.setClz(loadClass);
      return loadClass;
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
View Full Code Here


       
        // shall I load them right away?
        // let's try
        ClassLoader cl = _parentClassLoader == null ? JapidRenderer.class.getClassLoader() : _parentClassLoader;
        TemplateClassLoader classReloader = new TemplateClassLoader(cl);
        for (RendererClass rc: classes.values()) {
          try {
            if (isDevMode())
              rc.setClz(null); // to enable JIT loading in dev mode
            else
              rc.setClz((Class<JapidTemplateBaseWithoutPlay>) classReloader.loadClass(rc.getClassName()));
          } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
          }
        }
        howlong("compile/load time for " + names.length + " classes", t);
View Full Code Here

    setRefreshInterval(refreshInterval);
    _parentClassLoader = parentClassLoader;
    if (_parentClassLoader == null) {
      _parentClassLoader = JapidRenderer.class.getClassLoader();
    }
    crlr = new TemplateClassLoader(parentClassLoader);
    compiler = new RendererCompiler(classes, crlr);
    JapidRenderer.usePlay = usePlay;
    refreshClasses();
    inited = true;
    System.out.println("[Japid] initialized version " + VERSION + " in " + getOpMode() + " mode");
View Full Code Here

    // always clear the mark to reload all
    for (String c : classes.keySet()) {
      RendererClass rendererClass = classes.get(c);
      rendererClass.setLastUpdated(0);
    }
    TemplateClassLoader classReloader = new TemplateClassLoader();
    try {
      Class<JapidTemplateBaseWithoutPlay> loadClass = (Class<JapidTemplateBaseWithoutPlay>) classReloader.loadClass(name);
      rc.setClz(loadClass);
      return loadClass;
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

    if (parentClassLoader == null)
      throw new RuntimeException("parentClassLoader is null");
    long now = System.currentTimeMillis();
    if (now - newClassLoaderCreated > 2000 || lastClassLoader == null) {
      newClassLoaderCreated = now;
      lastClassLoader = new TemplateClassLoader(parentClassLoader);
    }
    return lastClassLoader;
  }
View Full Code Here

        for (String k : japidClasses.keySet()) {
          japidClasses.get(k).setClz(null);
        }

        TemplateClassLoader loader = getClassLoader();
        for (String cname : updatedClasses) {
          loader.loadClass(cname);
        }
      }
    } catch (Exception e) {
      if (e instanceof JapidTemplateException)
        throw (JapidTemplateException) e;
View Full Code Here

        long t = System.currentTimeMillis();
        compiler.compile(names.toArray(new String[] {}));
        howlong("compile time for " + names.size() + " classes", t);

        TemplateClassLoader loader = getClassLoader();
        for (String cname : names) {
          loader.loadClass(cname);
        }
      }
    } catch (Exception e) {
      if (e instanceof JapidTemplateException)
        throw (JapidTemplateException) e;
View Full Code Here

    JapidTemplateBaseWithoutPlay.globalTraceFileJson = yesno;

    // System.out.println("parent classloader: " + clr);
    parentClassLoader = clr;

    TemplateClassLoader classLoader = getClassLoader();

    compiler = new RendererCompiler(japidClasses, classLoader);

    // if (usePlay)
    // initErrorRenderer();
View Full Code Here

      japidClasses.put(key, rc); // remember the current impl of class
                    // refresh will erase dynamic template
                    // class from this container.
      compiler.compile(new String[] { key });
      dynamicClasses.put(key, rc);
      TemplateClassLoader loader = getClassLoader();
      loader.loadClass(key);
    } catch (Exception e) {
      if (e instanceof JapidTemplateException)
        throw (JapidTemplateException) e;
      throw new RuntimeException(e);
    }
View Full Code Here

    if (parentClassLoader == null)
      throw new RuntimeException("parentClassLoader is null");
    long now = System.currentTimeMillis();
    if (now - newClassLoaderCreated > 2000 || lastClassLoader == null) {
      newClassLoaderCreated = now;
      lastClassLoader = new TemplateClassLoader(parentClassLoader);
    }
    return lastClassLoader;
  }
View Full Code Here

TOP

Related Classes of cn.bran.japid.rendererloader.TemplateClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.