{
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver()

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {
        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);
        viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);

package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {

        viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");

package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {
        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);

        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {
        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);
        viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/W

        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {
        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);
        viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


package com.jeroenreijn.examples.configuration;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.jeroenreijn.examples.view.*;
import org.fusesource.scalate.spring.view.ScalateViewResolver;
import org.rythmengine.spring.web.RythmConfigurer;
import org.rythmengine.spring.web.RythmViewResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import com.github.enpassant.ickenham.springmvc.IckenhamViewResolver;
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
import com.jeroenreijn.examples.repository.InMemoryPresentationsRepository;
import com.jeroenreijn.examples.repository.PresentationsRepository;
import com.x5.template.spring.ChunkTemplateView;
import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import httl.web.springmvc.HttlViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "com.jeroenreijn.examples.controller", "com.jeroenreijn.examples.factory" })
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/robots.txt").addResourceLocations("/robots.txt");
        registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/");
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:/messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr;
    }

    @Bean
    public PresentationsRepository presentationsRepository() {
        PresentationsRepository inMemory = new InMemoryPresentationsRepository();
        return inMemory;
    }

    @Bean
    public SpringResourceTemplateResolver thymeleafTemplateResolver() {
        SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
        templateResolver.setApplicationContext(this.applicationContext);
        templateResolver.setPrefix("/WEB-INF/thymeleaf/");
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setCharacterEncoding("UTF-8");
        return templateResolver;
    }

    @Bean
    public SpringTemplateEngine thymeleafTemplateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(thymeleafTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ViewResolver thymeleafViewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewNames(new String[] { "*-thymeleaf" });
        viewResolver.setTemplateEngine(thymeleafTemplateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver handlebarsViewResolver() {
        HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
        viewResolver.setViewNames("*-handlebars");
        viewResolver.setPrefix("/WEB-INF/handlebars/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean(name = "chunkTemplatesConfig")
    @Scope("prototype")
    public Map<String, String> chunkTemplatesConfig() {
        Map<String, String> config = new HashMap<>();
        config.put("default_extension", "chtml");
        config.put("cache_minutes", "0");
        config.put("layers", "");
        config.put("theme_path", "");
        config.put("hide_errors", "FALSE");
        config.put("error_log", "");
        config.put("encoding", "UTF-8");
        config.put("locale", "");
        config.put("filters", "");
        return config;
    }

    @Bean
    public ViewResolver chunkViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(ChunkTemplateView.class);
        viewResolver.setPrefix("/WEB-INF/chunk/");
        viewResolver.setViewNames("*-chunk");
        viewResolver.setSuffix(".chtml");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver jspViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/jsp/");
        viewResolver.setViewNames("*-jsp");
        viewResolver.setSuffix(".jsp");
        viewResolver.setCache(false);
        viewResolver.setRequestContextAttribute("rc");
        return viewResolver;
    }

    @Bean
    public ViewResolver httlViewResolver() {
        HttlViewResolver viewResolver = new HttlViewResolver();
        viewResolver.setContentType("text/html;charset=UTF-8");
        viewResolver.setViewNames("*-httl");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public SpringTemplateLoader jade4jTemplateLoader() {
        SpringTemplateLoader templateLoader = new SpringTemplateLoader();
        templateLoader.setEncoding("UTF-8");
        return templateLoader;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration config = new JadeConfiguration();
        config.setPrettyPrint(true);
        config.setCaching(false);
        config.setTemplateLoader(applicationContext.getBean(SpringTemplateLoader.class));
        return config;
    }

    @Bean
    public ViewResolver jadeViewResolver() {
        JadeViewResolver viewResolver = new JadeViewResolver();
        viewResolver.setPrefix("/WEB-INF/jade/");
        viewResolver.setSuffix(".jade");
        viewResolver.setViewNames("*-jade");
        viewResolver.setRenderExceptions(true);
        viewResolver.setCache(false);
        viewResolver.setConfiguration(applicationContext.getBean(JadeConfiguration.class));
        return viewResolver;
    }

    @Bean
    public ViewResolver scalateViewResolver() {
        ScalateViewResolver viewResolver = new ScalateViewResolver();
        viewResolver.setPrefix("/WEB-INF/scalate/");
        viewResolver.setSuffix(".scaml");
        viewResolver.setViewNames("*-scalate");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver htmlFlowViewResolver() {
        HtmlFlowViewResolver viewResolver = new HtmlFlowViewResolver();
        viewResolver.setViewNames("*-htmlFlow");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver trimouViewResolver() {
        MessageSource messageSource = applicationContext.getBean(MessageSource.class);
        TrimouViewResolver viewResolver = new TrimouViewResolver(messageSource);
        viewResolver.setPrefix("classpath:/templates/trimou/");
        viewResolver.setSuffix(".trimou");
        viewResolver.setViewNames("*-trimou");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver rockerViewResolver() {
        RockerViewResolver viewResolver = new RockerViewResolver();
        viewResolver.setViewNames("*-rocker");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Bean
    public ViewResolver ickenhamViewResolver() {
        IckenhamViewResolver viewResolver = new IckenhamViewResolver();
        viewResolver.setPrefix("/WEB-INF/ickenham/");
        viewResolver.setSuffix(".hbs");
        viewResolver.setViewNames("*-ickenham");
        viewResolver.setRequestContextAttribute("rc");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public RythmConfigurer rythmConfigurer() {
        RythmConfigurer conf = new RythmConfigurer();
        conf.setDevMode(true);
        conf.setResourceLoaderPath("/WEB-INF/rythm/");
        conf.setAutoImports("com.jeroenreijn.examples.model.*");
        return conf;
    }

    @Bean
    public ViewResolver rythmViewResolver() {
        RythmViewResolver viewResolver = new RythmViewResolver();
        viewResolver.setPrefix("/WEB-INF/rythm/");
        viewResolver.setSuffix(".html");
        viewResolver.setViewNames("*-rythm");
        viewResolver.setCache(false);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public LiqpViewResolver liqpViewResolver() {
        LiqpViewResolver viewResolver = new LiqpViewResolver(applicationContext.getBean(MessageSource.class));
        viewResolver.setViewClass(LiqpView.class);
        viewResolver.setPrefix("classpath:./templates/liqp/");
        viewResolver.setSuffix(".liqp");
        viewResolver.setViewNames("*-liqp");
        viewResolver.setCache(fal

se);
        viewResolver.setContentType("text/html;charset=UTF-8");
        return viewResolver;
    }

    @Bean
    public ViewResolver kotlinxHtmlViewResolver() {
        KotlinxHtmlViewResolver viewResolver = new KotlinxHtmlViewResolver();
        viewResolver.setViewNames("*-kotlinx");
        viewResolver.setCache(false);
        return viewResolver;
    }

    @Controller
    static class FaviconController {

        @RequestMapping("favicon.ico")
        String favicon() {
            return "forward:/resources/images/favicon.ico";
        }
    }
}


@GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException

package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();
        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }
        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

{
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


{
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();
        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }
        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();

package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {

        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }
        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException {
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }

package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();

        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException {
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();
        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException {
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@ComponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();
        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }
        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException {
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return response

    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


package com.jtricks.rest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

@Path("/category")
@Named
public class CategoryResource {

    private final ProjectManager projectManager;

    @Inject
    public CategoryResource(@Co

mponentImport ProjectManager projectManager) {
        this.projectManager = projectManager;
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Response getCategories(@QueryParam("dummyParam") String dummyParam) throws SearchException {
        System.out.println("This is just a dummyParam to show how parameters can be passed to REST methods:" + dummyParam);
        Collection<ProjectCategory> categories = this.projectManager.getAllProjectCategories();
        List<Category> categoryList = new ArrayList<Category>();
        for (ProjectCategory category : categories) {
            categoryList.add(new Category(category.getId(), category.getName()));
        }
        Response.ResponseBuilder responseBuilder = Response.ok(new Categories(categoryList));
        return responseBuilder.build();
    }

    @GET
    @AnonymousAllowed
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Path("/{id}")
    public Response getCategoryFromId(@PathParam("id") String id) throws SearchException {
        ProjectCategory category = this.projectManager.getProjectCategoryObject(new Long(id));
        Response.ResponseBuilder responseBuilder = Response.ok(new Category(category.getId(), category.getName()));
        return responseBuilder.build();
    }

    @XmlRootElement
    public static class Category {

        @XmlElement
        private Long id;

        @XmlElement
        private String name;

        public Category() {
        }

        public Category(Long id, String name) {
            this.id = id;
            this.name = name;
        }
    }

    @XmlRootElement
    public static class Categories {

        @XmlElement
        private List<Category> categories;

        public Categories() {
        }

        public Categories(List<Category> categories) {
            this.categories = categories;
        }
    }
}


public static void contributeChatService(Binder binder, String chatService)

package org.apache.cayenne.event;

import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.MapBuilder;
import org.apache.cayenne.di.Module;

public class XMPPModule implements Module {

    /**
     * A DI container key for the Map<String, String> storing
     * {@link org.apache.cayenne.event.XMPPBridge} properties
     *
     * @since 4.0
     */
    public static final String XMPP_BRIDGE_PROPERTIES_MAP = "cayenne.server.xmpp_bridge";

    public static void contributeHost(Binder binder, String host) {
        contributeProperties(binder).put(XMPPBridge.XMPP_HOST_PROPERTY, host);
    }

    public static void contributePort(Binder binder, int port) {
        contributeProperties(binder).put(XMPPBridge.XMPP_PORT_PROPERTY, Integer.toString(port));
    }

    public static void contributeLogin(Binder binder, String login, String password) {
        contributeProperties(binder).put(XMPPBridge.XMPP_LOGIN_PROPERTY, login);
        contributeProperties(binder).put(XMPPBridge.XMPP_PASSWORD_PROPERTY, password);
    }

{
        contributeProperties(binder).put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, chatService);
    }

    public static void contributeSecureConnection(Binder binder, boolean secure) {
        contributeProperties(binder).put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, Boolean.toString(secure));
    }

    private static MapBuilder<String> contributeProperties(Binder binder) {
        return binder.bindMap(String.class, XMPP_BRIDGE_PROPERTIES_MAP);
    }

    @Override
    public void configure(Binder binder) {
        // init properties' defaults
        contributeChatService(binder, XMPPBridge.DEFAULT_CHAT_SERVICE);
        binder.bind(EventBridge.class).toProvider(XMPPBridgeProvider.class).withoutScope();
    }
}


{
        // init properties' defaults
        contributeChatService(binder, XMPPBridge.DEFAULT_CHAT_SERVICE);
        binder.bind(EventBridge.class).toProvider(XMPPBridgeProvider.class).withoutScope();
    }

package org.apache.cayenne.event;

import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.MapBuilder;
import org.apache.cayenne.di.Module;

public class XMPPModule implements Module {

    /**
     * A DI container key for the Map<String, String> storing
     * {@link org.apache.cayenne.event.XMPPBridge} properties
     *
     * @since 4.0
     */
    public static final String XMPP_BRIDGE_PROPERTIES_MAP = "cayenne.server.xmpp_bridge";

    public static void contributeHost(Binder binder, String host) {
        contributeProperties(binder).put(XMPPBridge.XMPP_HOST_PROPERTY, host);
    }

    public static void contributePort(Binder binder, int port) {
        contributeProperties(binder).put(XMPPBridge.XMPP_PORT_PROPERTY, Integer.toString(port));
    }

    public static void contributeLogin(Binder binder, String login, String password) {
        contributeProperties(binder).put(XMPPBridge.XMPP_LOGIN_PROPERTY, login);
        contributeProperties(binder).put(XMPPBridge.XMPP_PASSWORD_PROPERTY, password);
    }

    public static void contributeChatService(Binder binder, String chatService) {
        contributeProperties(binder).put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, chatService);
    }

    public static void contributeSecureConnection(Binder binder, boolean secure) {
        contributeProperties(binder).put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, Boolean.toString(secure));
    }

    private static MapBuilder<String> contributeProperties(Binder binder) {
        return binder.bindMap(String.class, XMPP_BRIDGE_PROPERTIES_MAP);
    }

    @Override
    public void configure(Binder binder)


package org.apache.cayenne.event;

import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.MapBuilder;
import org.apache.cayenne.di.Module;

public class XMPPModule implements Module {

    /**
     * A DI container key for the Map<String, String> storing
     * {@link org.apache.cayenne.event.XMPPBridge} properties
     *
     * @since 4.0
     */
    public static final String XMPP_BRIDGE_PROPERTIES_MAP = "cayenne.server.xmpp_bridge";

    public static void contributeHost(Binder binder, String host) {
        contributeProperties(binder).put(XMPPBridge.XMPP_HOST_PROPERTY, host);
    }

    public static void contributePort(Binder binder, int port) {
        contributeProperties(binder).put(XMPPBridge.XMPP_PORT_PROPERTY, Integer.toString(port));
    }

    public static void contributeLogin(Binder binder, String login, String password) {
        contributeProperties(binder).put(XMPPBridge.XMPP_LOGIN_PROPERTY, login);
        contributeProperties(binder).put(XMPPBridge.XMPP_PASSWORD_PROPERTY, password);
    }

    public static void contributeChatService(Binder binder, String chatService) {
        contributeProperties(binder).put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, chatService);
    }

    public static void contributeSecureConnection(Binder binder, boolean secure) {
        contributeProperties(binder).put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, Boolean.toString(secure));
    }

    private static MapBuilder<String> contributeProperties(Binder binder) {
        return binder.bindMap(String.class, XMPP_BRIDGE_PROPERTIES_MAP);
    }

    @Override
    public void configure(Binder binder) {
        // init properties' defaults
        contributeChatService(binder, XMPPBridge.DEFAULT_CHAT

        binder.bind(EventBridge.class).toProvider(XMPPBridgeProvider.class).withoutScope();
    }
}


package org.apache.cayenne.event;

import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.MapBuilder;
import org.apache.cayenne.di.Module;

public class XMPPModule implements Module {

    /**
     * A DI container key for the Map<String, String> storing
     * {@link org.apache.cayenne.event.XMPPBridge} properties
     *
     * @since 4.0
     */
    public static final String XMPP_BRIDGE_PROPERTIES_MAP = "cayenne.server.xmpp_bridge";

    public static void contributeHost(Binder binder, String host) {
        contributeProperties(binder).put(XMPPBridge.XMPP_HOST_PROPERTY, host);
    }

    public static void contributePort(Binder binder, int port) {
        contributeProperties(binder).put(XMPPBridge.XMPP_PORT_PROPERTY, Integer.toString(port));
    }

    public static void contributeLogin(Binder binder, String login, String passw

ord) {
        contributeProperties(binder).put(XMPPBridge.XMPP_LOGIN_PROPERTY, login);
        contributeProperties(binder).put(XMPPBridge.XMPP_PASSWORD_PROPERTY, password);
    }

    public static void contributeChatService(Binder binder, String chatService) {
        contributeProperties(binder).put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, chatService);
    }

    public static void contributeSecureConnection(Binder binder, boolean secure) {
        contributeProperties(binder).put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, Boolean.toString(secure));
    }

    private static MapBuilder<String> contributeProperties(Binder binder) {
        return binder.bindMap(String.class, XMPP_BRIDGE_PROPERTIES_MAP);
    }

    @Override
    public void configure(Binder binder) {
        // init properties' defaults
        contributeChatService(binder, XMPPBridge.DEFAULT_CHAT_SERVICE);
        binder.bind(EventBridge.class).toProvider(XMPPBridgeProvider.class).withoutScope();
    }
}