コード例 #1
0
  /**
   * Creates a GroovyPageMetaInfo instance from the given Parse object, and initialises it with the
   * the specified last modifed date and InputStream
   *
   * @param parse The Parse object
   * @param lastModified The last modified date
   * @param in The InputStream instance
   * @return A GroovyPageMetaInfo instance
   */
  private GroovyPageMetaInfo createPageMetaInfo(
      GroovyPageParser parse, long lastModified, InputStream in) {
    GroovyPageMetaInfo pageMeta = new GroovyPageMetaInfo();
    pageMeta.setJspTagLibraryResolver(jspTagLibraryResolver);
    pageMeta.setTagLibraryLookup(tagLibraryLookup);
    pageMeta.setContentType(parse.getContentType());
    pageMeta.setLineNumbers(parse.getLineNumberMatrix());
    pageMeta.setLastModified(lastModified);
    pageMeta.setJspTags(parse.getJspTags());
    pageMeta.setCodecName(parse.getDefaultCodecDirectiveValue());
    pageMeta.initCodec();
    // just return groovy and don't compile if asked
    if (isReloadEnabled() || GrailsUtil.isDevelopmentEnv()) {
      pageMeta.setGroovySource(in);
    }

    return pageMeta;
  }
コード例 #2
0
  private GroovyPageTemplate createTemplateFromPrecompiled(String originalUri, String uri) {
    if (precompiledGspMap != null) {
      GroovyPageMetaInfo meta = precompiledCache.get(uri);
      if (meta != null) {
        return new GroovyPageTemplate(meta);
      }
      String gspClassName = precompiledGspMap.get(uri);
      if (gspClassName != null) {
        Class<GroovyPage> gspClass = null;
        try {
          gspClass =
              (Class<GroovyPage>)
                  Class.forName(gspClassName, true, Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
          LOG.warn(
              "Cannot load class " + gspClassName + ". Resuming on non-precompiled implementation.",
              e);
        }
        if (gspClass != null) {
          meta = new GroovyPageMetaInfo(gspClass);
          meta.setJspTagLibraryResolver(jspTagLibraryResolver);
          meta.setTagLibraryLookup(tagLibraryLookup);
          if (LOG.isDebugEnabled()) {
            LOG.debug(
                "Adding GSP class GroovyPageMetaInfo in cache for uri "
                    + uri
                    + " classname is "
                    + gspClassName);
          }
          precompiledCache.put(uri, meta);
          precompiledCache.put(originalUri, meta);
          return new GroovyPageTemplate(meta);
        }
      }
      if (precompiledGspMap.size() > 0) {}

      if (LOG.isDebugEnabled()) {
        LOG.debug("No precompiled template found for uri '" + uri + "'");
      }
    }
    return null;
  }