@Bean @ConditionalOnBean(MustacheViewResolver.class) public LiteDeviceDelegatingViewResolver deviceDelegatingMustacheViewResolver( DeviceDelegatingViewResolverFactory factory, MustacheViewResolver viewResolver) { return factory.createViewResolver(viewResolver); }
@Bean @ConditionalOnMissingBean(MustacheViewResolver.class) public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) { MustacheViewResolver resolver = new MustacheViewResolver(); this.mustache.applyToViewResolver(resolver); resolver.setCharset(this.mustache.getCharsetName()); resolver.setCompiler(mustacheCompiler); resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10); return resolver; }
@Test public void deviceDelegatingMustacheViewResolver() throws Exception { load(Collections.<Class<?>>singletonList(MustacheAutoConfiguration.class), "spring.mobile.devicedelegatingviewresolver.enabled:true"); assertThat(this.context.getBeansOfType(LiteDeviceDelegatingViewResolver.class)) .hasSize(2); assertLiteDeviceDelegatingViewResolver( this.context.getBean(MustacheViewResolver.class), "deviceDelegatingMustacheViewResolver"); }
@Bean @ConditionalOnMissingBean(MustacheViewResolver.class) public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) { MustacheViewResolver resolver = new MustacheViewResolver(); resolver.setPrefix(this.mustache.getPrefix()); resolver.setSuffix(this.mustache.getSuffix()); resolver.setCache(this.mustache.isCache()); resolver.setViewNames(this.mustache.getViewNames()); resolver.setContentType(this.mustache.getContentType().toString()); resolver.setCharset(this.mustache.getCharsetName()); resolver.setCompiler(mustacheCompiler); resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10); return resolver; }
@Override public void configureViewResolvers(ViewResolverRegistry registry) { registry.viewResolver(new MustacheViewResolver()); }