<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2002-2013 the original author or authors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<!--
    - DispatcherServlet application context for PetClinic's web tier.
-->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!--
    - The ContentNegotiatingViewResolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
    - and uses the requested media type (determined by the path extension) to pick a matching view.
    - When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
    - otherwise to the BeanNameViewResolver.
    -->
    <mvc:view-resolvers>
        <mvc:content-negotiation use-not-acceptable="true">
            <mvc:default-views>
                <bean class="org.springframework.web.servlet.view.JstlView">
                    <property name="url" value=""/>
                </bean>
            </mvc:default-views>
        </mvc:content-negotiation>

        <!-- Registering BeanNameViewResolver and InternalViewResolver -->
        <mvc:bean-name/>
        <mvc:jsp prefix="/WEB-INF/jsp/" suffix=".jsp"/>
    </mvc:view-resolvers>

    <!-- Renders an XML view. Used by the BeanNameViewResolver  -->
    <bean id="vets/vetList.xml" class="org.springframework.web.servlet.view.xml.MarshallingView">
        <property name="marshaller" ref="marshaller"/>
    </bean>

    <oxm:jaxb2-marshaller id="marshaller">
        <!-- Object-XML mapping declared using annotations inside 'Vets' -->
        <oxm:class-to-be-bound name="org.springframework.samples.petclinic.model.Vets"/>
    </oxm:jaxb2-marshaller>

</beans>
