<?xml version="1.0"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
       
	<mvc:resources mapping="/js/**" location="/js/" />
	<mvc:resources mapping="/img/**" location="/img/" />
	<mvc:resources mapping="/css/**" location="/css/" />
	<mvc:resources mapping="/bower_components/**" location="/bower_components/" />
	<mvc:resources mapping="/bootstrap/**" location="/bootstrap/" />
	<mvc:resources mapping="/font-awesome/**" location="/font-awesome/" />
	<mvc:resources mapping="/jquery/**" location="/jquery/" />
	<mvc:resources mapping="/partials/**" location="/partials/" />
	<mvc:resources mapping="/select/**" location="/select/" />
	<mvc:resources mapping="/templates/**" location="/templates/" />
	
	<mvc:annotation-driven > 
	    <mvc:message-converters register-defaults="false">
	        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
	            <property name="objectMapper">
	                <bean class="common.utility.ISODateTimeMapper"/>
	            </property>
	        </bean>
	    </mvc:message-converters>
	 </mvc:annotation-driven>

	<context:component-scan base-package="sicura.web.filters"/>
	<context:component-scan base-package="dao"/>
	<context:component-scan base-package="controller"/>
	<context:component-scan base-package="controller.rest"/>
	<context:component-scan base-package="utils"/>
		 	
  	<mvc:view-controller path="/" view-name="home" />

	<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
	    <property name="contentNegotiationManager" ref="contentNegotiationManager"/>
	    <property name="useSuffixPatternMatch" value="false"/>
	</bean>
	<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
	    <property name="favorPathExtension" value="false"/>
	    <property name="favorParameter" value="true"/>
	    <property name="mediaTypes">
	        <value>
	            json=application/json
	            xml=application/xml
	            txt=text/plain
	        </value>
	    </property>
	</bean>

	<!-- Multipart upload -->
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="100000000"/>
	</bean>

	<!-- definizione mapping -->

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
   		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
 		<property name="prefix" value="/WEB-INF/views/"/>
		<property name="suffix" value=".jsp"/>
	</bean>

	<bean id="jacksonObjectMapper" class="common.utility.CustomObjectMapper" />
	
<!-- 	<bean id="jacksonSerializationConfig" class="org.codehaus.jackson.map.SerializationConfig" -->
<!-- 	    factory-bean="jacksonObjectMapper" factory-method="getSerializationConfig" > -->
<!-- 	</bean> -->

	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

 	<context:annotation-config/>


<!-- <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> -->
<!--         <property name="jpaVendorAdapter"> -->
<!--             <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> -->
<!--                 <property name="showSql" value="true" /> -->
<!--                 <property name="generateDdl" value="true" /> -->
<!--                 <property name="databasePlatform" value="org.hibernate.dialect.SQLServer2008Dialect" /> -->
<!--             </bean> -->
<!--         </property> -->
<!--         <persistence-unit name="JpaPersistenceUnit" -->
<!-- 		        transaction-type="RESOURCE_LOCAL"> -->
<!-- 		        <provider>org.hibernate.ejb.HibernatePersistence</provider> -->
<!-- 	    </persistence-unit> -->
<!--         <property name="dataSource" ref="dataSource" /> -->

<!--     </bean> -->

<!--     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> -->
<!--         <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/> -->
<!--         <property name="url" value="dbc:jtds:sqlserver://localhost:1433/SicuraSQL_Findomestic_Web"/> -->
<!--         <property name="username" value="sa"/> -->
<!--         <property name="password" value="kranio-10"/> -->
<!--     </bean> -->

<!--     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -->
<!--         <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/> -->
<!--         <property name="url" value="jdbc:jtds:sqlserver://localhost:1433/SicuraSQL_Findomestic_Web"/> -->
<!--         <property name="username" value="sa"/> -->
<!--         <property name="password" value="kranio-10"/> -->
<!--     </bean> -->
 
<!--     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> -->
<!--         <property name="dataSource" ref="dataSource" /> -->
<!--     </bean> -->



    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="order" value="1" />
        <property name="contentNegotiationManager">
            <bean class="org.springframework.web.accept.ContentNegotiationManager">
                <constructor-arg>
                    <bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
                        <constructor-arg>
                            <map>
                                <entry key="json" value="application/json"/>
                                <entry key="xml" value="application/xml"/>
                                <entry key="txt" value="text/plain"/>
                            </map>
                        </constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
   	</bean>
</beans>
