Java 类org.springframework.web.servlet.view.freemarker.FreeMarkerConfig 实例源码

项目:onetwo    文件:WebFtlsContextConfig.java   
@Bean
    @ConditionalOnMissingBean({FreeMarkerConfig.class, FreeMarkerViewResolver.class})
    public FreeMarkerConfigurer freeMarkerConfigurer() {
        PluginFreeMarkerConfigurer configurer = new PluginFreeMarkerConfigurer();
        applyProperties(configurer);
        String[] paths = this.properties.getTemplateLoaderPath();
//      paths = ArrayUtils.add(paths, WEBFTLS_PATH);
        configurer.setTemplateLoaderPaths(paths);

        List<WithAnnotationBeanData<FreeMarkerViewTools>> tools = SpringUtils.getBeansWithAnnotation(applicationContext, FreeMarkerViewTools.class);
        tools.forEach(t->{
            String name = t.getAnnotation().value();
            if(StringUtils.isBlank(name)){
                name = t.getBean().getClass().getSimpleName();
            }
            configurer.setFreemarkerVariable(name, t.getBean());
            logger.info("registered FreeMarkerViewTools : {}", name);
        });
        return configurer;
    }
项目:leopard    文件:FreeMarkerUtil.java   
public static FreeMarkerConfig getFreeMarkerConfig(ApplicationContext applicationContext, String templateLoaderPath) {
    if (configurer != null) {
        return configurer;
    }
    configurer = getFreeMarkerConfigurer(applicationContext, templateLoaderPath);
    return configurer;
}
项目:xxl-incubator    文件:RegistryListener.java   
public void contextInitialized(ServletContextEvent sc) {
    logger.info("[5i net registry listener starting...]");

    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc.getServletContext());

    // 资源实例
    ResourceBundle resource = ResourceBundle.getInstance();
    resource.setFreemarkerConfig((FreeMarkerConfig) context.getBean("freemarkerConfig"));

    logger.info("[5i net registry listener finished...]");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:spring-boot-concourse    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:contestparser    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:jeecms6    文件:SimpleFreeMarkerView.java   
/**
 * 自动检测FreeMarkerConfig
 * 
 * @return
 * @throws BeansException
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
    try {
        return (FreeMarkerConfig) BeanFactoryUtils
                .beanOfTypeIncludingAncestors(getApplicationContext(),
                        FreeMarkerConfig.class, true, false);
    } catch (NoSuchBeanDefinitionException ex) {
        throw new ApplicationContextException(
                "Must define a single FreeMarkerConfig bean in this web application context "
                        + "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
                        + "This bean may be given any name.", ex);
    }
}
项目:ocms    文件:CmsFreeMarkerView.java   
@Override
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
    try {

        return (FreeMarkerConfig) BeanFactoryUtils.beanOfType(
                getApplicationContext(), FreeMarkerConfig.class, true,
                false);
    } catch (NoSuchBeanDefinitionException ex) {
        throw new ApplicationContextException(
                "Must define a single FreeMarkerConfig bean in this web application context "
                        + "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
                        + "This bean may be given any name.", ex);
    }
}
项目:ocms    文件:ScheduleFreeMarkerView.java   
@Override
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
    try {

        return (FreeMarkerConfig) BeanFactoryUtils.beanOfType(
                getApplicationContext(), FreeMarkerConfig.class, true,
                false);
    } catch (NoSuchBeanDefinitionException ex) {
        throw new ApplicationContextException(
                "Must define a single FreeMarkerConfig bean in this web application context "
                        + "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
                        + "This bean may be given any name.", ex);
    }
}
项目:Lottery    文件:SimpleFreeMarkerView.java   
/**
 * 自动检测FreeMarkerConfig
 * 
 * @return
 * @throws BeansException
 */
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
    try {
        return (FreeMarkerConfig) BeanFactoryUtils
                .beanOfTypeIncludingAncestors(getApplicationContext(),
                        FreeMarkerConfig.class, true, false);
    } catch (NoSuchBeanDefinitionException ex) {
        throw new ApplicationContextException(
                "Must define a single FreeMarkerConfig bean in this web application context "
                        + "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
                        + "This bean may be given any name.", ex);
    }
}
项目:mockserver    文件:WebMvcConfiguration.java   
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
    FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
    freeMarkerConfigurer.setConfiguration(new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_22) {{
        setTemplateLoader(new MultiTemplateLoader(
                new TemplateLoader[]{
                        new ClassTemplateLoader(FreeMarkerConfig.class, "/")
                }
        ));
        setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        setWhitespaceStripping(true);
    }});
    return freeMarkerConfigurer;
}
项目:leopard    文件:FtlView.java   
@Override
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
    System.out.println("autodetectConfiguration:");
    String templateLoaderPath = "";
    return FreeMarkerUtil.getFreeMarkerConfig(super.getApplicationContext(), templateLoaderPath);
}
项目:xxl-incubator    文件:ResourceBundle.java   
public FreeMarkerConfig getFreemarkerConfig() {
    return freemarkerConfig;
}
项目:xxl-incubator    文件:ResourceBundle.java   
public void setFreemarkerConfig(FreeMarkerConfig freemarkerConfig) {
    this.freemarkerConfig = freemarkerConfig;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FreeMarkerAutoConfiguration.java   
@Bean
public freemarker.template.Configuration freeMarkerConfiguration(
        FreeMarkerConfig configurer) {
    return configurer.getConfiguration();
}
项目:spring-boot-concourse    文件:FreeMarkerAutoConfiguration.java   
@Bean
public freemarker.template.Configuration freeMarkerConfiguration(
        FreeMarkerConfig configurer) {
    return configurer.getConfiguration();
}
项目:contestparser    文件:FreeMarkerAutoConfiguration.java   
@Bean
public freemarker.template.Configuration freeMarkerConfiguration(
        FreeMarkerConfig configurer) {
    return configurer.getConfiguration();
}
项目:jeecms6    文件:SimpleFreeMarkerView.java   
/**
 * Invoked on startup. Looks for a single FreeMarkerConfig bean to find the
 * relevant Configuration for this factory.
 * <p>
 * Checks that the template for the default Locale can be found: FreeMarker
 * will check non-Locale-specific templates if a locale-specific one is not
 * found.
 * 
 * @see freemarker.cache.TemplateCache#getTemplate
 */
protected void initApplicationContext() throws BeansException {
    super.initApplicationContext();

    if (getConfiguration() == null) {
        FreeMarkerConfig config = autodetectConfiguration();
        setConfiguration(config.getConfiguration());
    }
    checkTemplate();
}
项目:Lottery    文件:SimpleFreeMarkerView.java   
/**
 * Invoked on startup. Looks for a single FreeMarkerConfig bean to find the
 * relevant Configuration for this factory.
 * <p>
 * Checks that the template for the default Locale can be found: FreeMarker
 * will check non-Locale-specific templates if a locale-specific one is not
 * found.
 * 
 * @see freemarker.cache.TemplateCache#getTemplate
 */
protected void initApplicationContext() throws BeansException {
    super.initApplicationContext();

    if (getConfiguration() == null) {
        FreeMarkerConfig config = autodetectConfiguration();
        setConfiguration(config.getConfiguration());
    }
    checkTemplate();
}