<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:beans="http://www.springframework.org/schema/beans"
             xmlns:p="http://www.springframework.org/schema/p"
             xmlns:context="http://www.springframework.org/schema/context"
             xmlns:faces="http://www.springframework.org/schema/faces"
             xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
    <context:component-scan base-package="ru.javastudy"/>

    <beans:import resource="webflow.xml" />

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources location="/" mapping="/resources/**"/>

    <!--Enable processing of JSF 2 resource requests. For example:
        /ch18/app/javax.faces.resource/jsf.js?ln=javax.faces-->
    <faces:resources/>

    <!--Maps request paths to flows in the flowRegistry-->
    <beans:bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <beans:property name="flowRegistry" ref="flowRegistry" />
        <beans:property name="order" value="1"/>
    </beans:bean>

    <!--Resolves views selected for rendering by @Controllers to .xhtml
        resources in the /WEB-INF/ directory-->
    <beans:bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".xhtml" />
    </beans:bean>

    <!--Dispatches requests mapped to flows to FlowHandler implementations-->
    <beans:bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
        <beans:property name="flowExecutor" ref="flowExecutor" />
    </beans:bean>

    <!-- Spring MVC Request handler Mapping -->
    <beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
        <beans:property name="order" value="0" />
    </beans:bean>

    <!--Find views returned in ModelAndView("viewName") in src/main/resources/views -->
    <!-- Order is IMPORTANT! If viewResolver will be first - 404 will be when PDF create -->
    <beans:bean id="viewPDFResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
        <beans:property name="order" value="0"/>
        <beans:property name="basename" value="views"/>
    </beans:bean>

     <!--for xls exporter-->
    <beans:bean id="viewExcelResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
    <beans:property name="location" value="/WEB-INF/spring/utils-config.xml"/>
    <beans:property name="order" value="0"/>
    </beans:bean>

    <beans:bean id="viewResolver"
                class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/" />
        <beans:property name="suffix" value=".xhtml" />
        <beans:property name="order" value="1"/>
    </beans:bean>

    <!-- Message Source -->
    <beans:bean id="messageSource"
          class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <beans:property name="basename" value="/WEB-INF/locales/messages" />
        <beans:property name="defaultEncoding" value="UTF-8" />
    </beans:bean>

    <beans:bean id="localeChangeInterceptor"
          class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <beans:property name="paramName" value="lang" />
    </beans:bean>

    <beans:bean id="localeResolver"
          class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <beans:property name="defaultLocale" value="ru" />
    </beans:bean>

    <interceptors>
        <interceptor>
            <mapping path="/*" />
            <beans:ref bean="localeChangeInterceptor" />
        </interceptor>
    </interceptors>
    <!--end Message Source -->

</beans:beans>
