bed7947cd2fc44d2ed12882340efd2a218d4b41d
[SpringWebServicesForFun/.git] /
1 <beans xmlns="http://www.springframework.org/schema/beans"
2         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3         xmlns:mvc="http://www.springframework.org/schema/mvc"
4         xmlns:context="http://www.springframework.org/schema/context"
5         xmlns:util="http://www.springframework.org/schema/util"
6         xmlns:p="http://www.springframework.org/schema/p"
7         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
9         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
10         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
11    
12         <!--
13                 I am declaring my beans without the automatic annotation. :/
14                 Better because we are saving memory but it requires more configuration.
15                 
16                 See: org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser
17                 <mvc:annotation-driven/>
18          -->
19          
20    
21         <context:annotation-config />
22    
23         <context:component-scan base-package="de.spring.webservices.rest"/>
24
25     <bean id="jsonObjectMapperFactory" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" p:indentOutput="true" p:failOnEmptyBeans="false">
26         <property name="featuresToDisable">
27             <array>
28                 <util:constant static-field="com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES"/>
29                 <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION"/>
30             </array>
31         </property>
32     </bean>
33
34     <util:list id="messageConverters">
35         <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" p:objectMapper-ref="jsonObjectMapperFactory"/>
36         <bean class="org.springframework.http.converter.StringHttpMessageConverter" />
37     </util:list>
38
39
40         <bean name="handlerAdapter"
41                 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
42                 <property name="webBindingInitializer">
43                         <bean
44                                 class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
45                                 <!-- It enables us to use JSR-303 -->
46                                 <property name="validator">
47                                         <bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
48                                 </property>
49                         </bean>
50                 </property>
51                 <property name="messageConverters" ref="messageConverters" />
52                 
53                 
54                 <property name="requestBodyAdvice">
55                         <util:list>
56                                 <bean id="requestBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice"/>
57                         </util:list>
58                 </property>
59                 
60                 
61                 <property name="responseBodyAdvice">
62                         <util:list>
63                                 <bean id="responseBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewResponseBodyAdvice"/>
64                         </util:list>
65                 </property>
66         </bean>
67     
68         <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
69
70         <mvc:default-servlet-handler />
71         
72 </beans>