Package freemarker.cache

Examples of freemarker.cache.MultiTemplateLoader


        WebappTemplateLoader webloader = new WebappTemplateLoader(servletContext);

        // Templates are stored in the root of the classpath.
        ClassTemplateLoader classLoader = new ClassTemplateLoader(getClass(), "/");
        TemplateLoader[] loaders = new TemplateLoader[] { webloader, classLoader };
        MultiTemplateLoader multiLoader = new MultiTemplateLoader(loaders);

        configuration.setTemplateLoader(multiLoader);

        // Set the template cache duration in seconds
        if (configService.isProductionMode() | configService.isProfileMode()) {
View Full Code Here


        WebappTemplateLoader webloader = new WebappTemplateLoader(servletContext);

        // Templates are stored in the root of the classpath.
        ClassTemplateLoader classLoader = new ClassTemplateLoader(getClass(), "/");
        TemplateLoader[] loaders = new TemplateLoader[] { webloader, classLoader };
        MultiTemplateLoader multiLoader = new MultiTemplateLoader(loaders);

        configuration.setTemplateLoader(multiLoader);

        // Set the template cache duration in seconds
        if (configService.isProductionMode() | configService.isProfileMode()) {
View Full Code Here

    // 带有固定前缀的类模板加载器
    PrefixClassTemplateLoader prefixClassTemplateLoader = new PrefixClassTemplateLoader(
        webappTemplatePath);
    // presume that most apps will require the class and
    // webapp template loader if people wish to
    return templatePathLoader != null ? new MultiTemplateLoader(new TemplateLoader[] {
        templatePathLoader, wtl, strutsClassTemplateLoader, prefixClassTemplateLoader })
        : new MultiTemplateLoader(new TemplateLoader[] { wtl, strutsClassTemplateLoader,
            prefixClassTemplateLoader });
  }
View Full Code Here

        throw new RuntimeException("templatePath: " + path
            + " is not well-formed. Use [classpath:|file:|webapp:] seperated with ,");
      }

    }
    return new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()]));
  }
View Full Code Here

   
    private Configuration fmConfig = new Configuration();
   
    public SharedFreemarker() {
        fmConfig.setTemplateLoader(
                new MultiTemplateLoader(
                        new TemplateLoader[]{
                                new ClassTemplateLoader( getClass(), "/")}) );
        fmConfig.setNumberFormat( "0" );
        fmConfig.setLocalizedLookup( false );
        fmConfig.setTemplateUpdateDelay(0);
View Full Code Here

         }

         // presume that most apps will require the class and webapp template loader
         // if people wish to
         return templatePathLoader != null ?
                 new MultiTemplateLoader(new TemplateLoader[]{
                         templatePathLoader,
                         new WebappTemplateLoader(servletContext),
                         new StrutsClassTemplateLoader()
                 })
                 : new MultiTemplateLoader(new TemplateLoader[]{
                 new WebappTemplateLoader(servletContext),
                 new StrutsClassTemplateLoader()
         });
     }
View Full Code Here

         }

         // presume that most apps will require the class and webapp template loader
         // if people wish to
         return templatePathLoader != null ?
                 new MultiTemplateLoader(new TemplateLoader[]{
                         templatePathLoader,
                         new WebappTemplateLoader(servletContext),
                         new StrutsClassTemplateLoader()
                 })
                 : new MultiTemplateLoader(new TemplateLoader[]{
                 new WebappTemplateLoader(servletContext),
                 new StrutsClassTemplateLoader()
         });
     }
View Full Code Here

            log.warn("template path" + file + " either does not exist or is not a directory");
          }
    }
        loaders.add(new ClassTemplateLoader(this.getClass(),"/")); // the template names are like pojo/Somewhere so have to be a rooted classpathloader
       
        freeMarkerEngine.setTemplateLoader(new MultiTemplateLoader((TemplateLoader[]) loaders.toArray(new TemplateLoader[loaders.size()])));
       
    }
View Full Code Here

        assertTrue(errMsg.contains("ccc"));
    }
   
    @Test
    public void testMultiTemplateLoader() throws IOException {
        final String errMsg = failWith(new MultiTemplateLoader(new TemplateLoader[] {
                new WebappTemplateLoader(new MockServletContext(), "WEB-INF/templates"),
                new ClassTemplateLoader(this.getClass(), "foo/bar")
        }));
        showErrorMessage(errMsg);
        assertTrue(errMsg.contains("MultiTemplateLoader"));
View Full Code Here

        File rootFile = webAppFolder.getAbsoluteFile();
        while (rootFile.getParentFile() != null) {
            rootFile = rootFile.getParentFile();
        }
       
        MultiTemplateLoader mtl;
        TemplateLoader[] loaders = null;

        // ////////// Set the templateLoaders ////////////////
        // if we have a servletContext, then include a webappTemplateLoader
        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());
        }

        if (loaders != null) {
            mtl = new MultiTemplateLoader(loaders);
            conf.setTemplateLoader(mtl);
        }

        // set the BeanWrapper
        conf.setObjectWrapper(BeansWrapper.DEFAULT_WRAPPER);
View Full Code Here

TOP

Related Classes of freemarker.cache.MultiTemplateLoader

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.