Java 类org.springframework.web.servlet.view.script.ScriptTemplateConfigurer 实例源码

项目:react-practice-web    文件:WebApplication.java   
@Bean
ScriptTemplateConfigurer configureScript() {
    ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
    configurer.setEngineName("nashorn");
    configurer.setRenderFunction("render");
    configurer.setScripts(
            "/META-INF/resources/webjars/react/15.1.0/react.min.js",
            "/META-INF/resources/webjars/react/15.1.0/react-dom-server.min.js",
            "/build/react-templating.jsx",
            "/static/js/doms.js",
            "/static/js/playfield.js"
    );

    logger.trace("  ScriptTemplateConfigurer configureScript()");
    return configurer;
}
项目:spring-react-isomorphic    文件:IsomorphicApplication.java   
@Bean
    public ScriptTemplateConfigurer reactConfigurer() {
        ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
        configurer.setEngineName("nashorn");
        configurer.setScripts("static/polyfill.js",
                "static/lib/js/ejs.min.js",
                "/META-INF/resources/webjars/react/0.13.1/react.js",
//                "/META-INF/resources/webjars/react/0.13.1/JSXTransformer.js",
                "static/render.js",
                "static/output/comment.js",
                "static/output/comment-form.js",
                "static/output/comment-list.js");
        configurer.setRenderFunction("render");
        configurer.setSharedEngine(false);
        return configurer;
    }
项目:spring4-understanding    文件:ViewResolverRegistry.java   
/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * @since 4.2
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
    if (this.applicationContext != null && !hasBeanOfType(ScriptTemplateConfigurer.class)) {
        throw new BeanInitializationException("In addition to a script template view resolver " +
                "there must also be a single ScriptTemplateConfig bean in this web application context " +
                "(or its parent): ScriptTemplateConfigurer is the usual implementation. " +
                "This bean may be given any name.");
    }
    ScriptRegistration registration = new ScriptRegistration();
    this.viewResolvers.add(registration.getViewResolver());
    return registration;
}
项目:spring4-understanding    文件:ViewResolverRegistryTests.java   
@Before
public void setUp() {
    StaticWebApplicationContext context = new StaticWebApplicationContext();
    context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
    context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
    context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
    context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
    context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);
    this.registry = new ViewResolverRegistry();
    this.registry.setApplicationContext(context);
    this.registry.setContentNegotiationManager(new ContentNegotiationManager());
}
项目:spirng-boot-sample-web-dustjs    文件:ScriptTemplateConfiguration.java   
@Bean
public ScriptTemplateConfigurer scriptTemplateConfigurer() throws IOException {
    final ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
    configurer.setRenderFunction("render");
    configurer.setSharedEngine(true);

    ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
    configurer.setEngine(engine);

    addScripts(configurer);

    return configurer;
}
项目:spirng-boot-sample-web-dustjs    文件:ScriptTemplateConfiguration.java   
private void addScripts(ScriptTemplateConfigurer configurer) throws IOException {
    List<String> scripts = new ArrayList<>();
    scripts.add("/static/dust.js");
    scripts.add("/static/polyfill.js");
    scripts.add("/META-INF/resources/webjars/dustjs-linkedin/2.7.2/dust-full.js");

    // TODO we needs refactoring if add STV.setScripts("folder")
    final ClassPathResource dir = new ClassPathResource("/static/templates/compiled");
    for (File f : dir.getFile().listFiles()) {
        scripts.add("/static/templates/compiled/" + f.getName());
    }
    configurer.setScripts(scripts.toArray(new String[scripts.size()]));
}
项目:spring-boot-sample-web-handlebars    文件:ScriptTemplateApplication.java   
@Bean
public ScriptTemplateConfigurer handlebarsConfigurer() {
ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
    configurer.setEngineName("nashorn");
        configurer.setScripts("/static/polyfill.js",
            "/META-INF/resources/webjars/handlebars/3.0.0-1/handlebars.js",
            "/static/render.js");
    configurer.setRenderFunction("render");
    configurer.setSharedEngine(false);
    return configurer;
}