Source

encuestame / encuestame-mvc / src / main / resources / encuestame-controller-context.xml

Full commit
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.0.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

  <!--
    Maps requests to @Controllers based on @RequestMapping("path")
    annotation values If no annotation-based path mapping is found, Spring
    MVC proceeds to the next HandlerMapping (order=0 below).
  -->
  <bean
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
      <property name="interceptors">
          <list>
               <!--<ref bean="openSessionInViewInterceptor"/>
               <ref bean="mobileInterceptor"/>
               <ref bean="enMeInterceptor"/>-->
          </list>
      </property>
     <property name="order" value="0"/>
  </bean>

  <bean id="mobileInterceptor" class="org.springframework.mobile.device.mvc.DeviceResolverHandlerInterceptor" />
  <bean id="enMeInterceptor" class=" org.encuestame.mvc.interceptor.DefaultEnMeInterceptor" />

  <!-- Scans for application @Components to deploy -->
  <context:component-scan base-package="org.encuestame.mvc" />

  <!--
    Enables annotated @Controllers; responsible for invoking an annotated
    POJO @Controller when one is mapped.
  -->
  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="order" value="0"/>
        <!--
            NOTE: it is important to specify the order property, so this
            adapter will be attempted before the HandlerAdapter that
            Spring MVC automatically configures. This is because a
            MappingJacksonHttpMessageConverter is registered
            automatically with the default adapter that will attempt to
            handle any Java object including BufferedImage.
        -->
        <property name="messageConverters">
            <list>
                <!-- Default converters -->
                <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.FormHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter">
                    <property name="supportedMediaTypes">
                        <list>
                            <value>image/jpeg</value>
                        </list>
                    </property>
                </bean>
                <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>

                <!-- Converter for images -->
                <bean class="org.encuestame.mvc.converter.EnhancedBufferedImageHttpMessageConverter"/>

                <!-- Handle JAXB XML objects
                <bean id="marshallingHttpMessageConverter"
                 class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
                    <constructor-arg>
                        <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                            <property name="classesToBeBound">
                                <list>
                                    <value>PictureFolders</value>
                                    <value>Pictures</value>
                                </list>
                            </property>
                        </bean>
                    </constructor-arg>
                </bean> -->

                <!-- This must come after our image converter
                <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
                -->
            </list>
        </property>
  </bean>

    <!-- thumbnail generator engine
         thanks to raulraja.
     -->
    <bean id="thumbnailGeneratorEngine" class="org.encuestame.core.image.ThumbnailGeneratorEngineImpl">

        <!-- the file extension for the thumbnail files -->
        <property name="generatedExtension">
            <value>.jpg</value>
        </property>

        <!-- the different sizes we want to generate, adjusting the aspect ratio based on the biggest dimension -->
        <property name="supportedSizes">
            <list>
                <value>900</value>
                <value>768</value>
                <value>375</value>
                <value>128</value>
                <value>64</value>
                <value>48</value>
                <value>22</value>
            </list>
        </property>

        <!-- mappings from the different content types to the right generator that handles each type -->
        <property name="thumbnailGenerators">
            <map>
                <entry key="image/jpeg" value-ref="imageThumbnailGenerator" />
                <entry key="image/jpg" value-ref="imageThumbnailGenerator" />
                <entry key="image/pjpeg" value-ref="imageThumbnailGenerator" />
                <entry key="image/gif" value-ref="imageThumbnailGenerator" />
                <entry key="image/png" value-ref="imageThumbnailGenerator" />
                <entry key="image/tiff" value-ref="imageThumbnailGenerator" />
                <entry key="image/bmp" value-ref="imageThumbnailGenerator" />
                <!--<entry key="application/pdf" value-ref="pdfThumbnailGenerator" />-->
            </map>
        </property>

        <!-- A default thumbnail generator to be used for unregistered mime types -->
        <property name="defaultThumbnailGenerator" ref="imageThumbnailGenerator"/>
    </bean>

    <!-- a thumbnail generator that generates thumbnails from images -->
    <bean id="imageThumbnailGenerator" class="org.encuestame.core.image.ImageThumbnailGeneratorImpl" />

</beans>