Package freemarker.cache

Examples of freemarker.cache.FileTemplateLoader


            // substring(7) is intentional as we "reuse" the last slash
            return new ClassTemplateLoader(getClass(), templatePath.substring(7));
        } else {
            if (templatePath.startsWith("file://")) {
                templatePath = templatePath.substring(7);
                return new FileTemplateLoader(new File(templatePath));
            } else {
                return new WebappTemplateLoader(this.getServletContext(), templatePath);
            }
        }
    }
View Full Code Here


        if (tl instanceof FileTemplateLoader) {
            String path = ((FileTemplateLoader) tl).baseDir.getCanonicalPath();
            if (path.equals(dir.getCanonicalPath()))
                return;
        }
        setTemplateLoaderNoCheck(new FileTemplateLoader(dir));
    }
View Full Code Here

        try {
            if (servletContext != null) {

                WebappTemplateLoader webappTemplateLoader = new WebappTemplateLoader(servletContext);

                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl, webappTemplateLoader };

            } else {
                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl };
            }
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
View Full Code Here

    this.syntax = syntax;
    this.changeLogTableName = changeLogTableName;
    this.writer = writer;
    this.configuration = new Configuration();

    FileTemplateLoader fileTemplateLoader = createFileTemplateLoader(templateDirectory);
    this.configuration.setTemplateLoader(
        new MultiTemplateLoader(new TemplateLoader[]{
            fileTemplateLoader,
            new ClassTemplateLoader(getClass(), "/"),
        }));
View Full Code Here

        }));
  }

  private FileTemplateLoader createFileTemplateLoader(File templateDirectory) throws IOException {
    if (templateDirectory == null) {
      return new FileTemplateLoader();
    } else {
      return new FileTemplateLoader(templateDirectory, true);
    }
  }
View Full Code Here

        File file = path.getFile()// will fail if not resolvable in the file system
        if (logger.isDebugEnabled()) {
          logger.debug(
              "Template loader path [" + path + "] resolved to file path [" + file.getAbsolutePath() + "]");
        }
        return new FileTemplateLoader(file);
      }
      catch (IOException ex) {
        if (logger.isDebugEnabled()) {
          logger.debug("Cannot resolve template loader path [" + templateLoaderPath +
              "] to [java.io.File]: using SpringTemplateLoader as fallback", ex);
View Full Code Here

        try {
            if (servletContext != null) {

                WebappTemplateLoader webappTemplateLoader = new WebappTemplateLoader(servletContext);

                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl, webappTemplateLoader };

            } else {
                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl };
            }
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
View Full Code Here

             if(templatePath!=null){
                 if (templatePath.startsWith("class://")) {
                     // substring(7) is intentional as we "reuse" the last slash
                     templatePathLoader = new ClassTemplateLoader(getClass(), templatePath.substring(7));
                 } else if (templatePath.startsWith("file://")) {
                     templatePathLoader = new FileTemplateLoader(new File(templatePath.substring(7)));
                 }
             }
         } catch (IOException e) {
             LOG.error("Invalid template path specified: " + e.getMessage(), e);
         }
View Full Code Here

        File file = path.getFile()// will fail if not resolvable in the file system
        if (logger.isDebugEnabled()) {
          logger.debug(
              "Template loader path [" + path + "] resolved to file path [" + file.getAbsolutePath() + "]");
        }
        return new FileTemplateLoader(file);
      }
      catch (IOException ex) {
        if (logger.isDebugEnabled()) {
          logger.debug("Cannot resolve template loader path [" + templateLoaderPath +
              "] to [java.io.File]: using SpringTemplateLoader as fallback");
View Full Code Here

            // also add superclass because of generated code
            loaders.add(new ClassTemplateLoader(value.getClass().getSuperclass()));
          }
        }
        loaders.add(new FileTemplateLoader());
        loaders.add(new FileTemplateLoader(new File("/")));

        // ClassTemplateLoader loader1 = new ClassTemplateLoader(
        // Object.class, "");
        // ClassTemplateLoader loader2 = new ClassTemplateLoader(
        // getClass().getSuperclass(), "");
View Full Code Here

TOP

Related Classes of freemarker.cache.FileTemplateLoader

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.