All Downloads are FREE. Search and download functionalities are using the official Maven repository.

elsci-mocks.web-app-context.xml Maven / Gradle / Ivy

There is a newer version: 20231025.1145-36
Show newest version
<?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:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"
       default-autowire="constructor">
    <context:annotation-config />
    <bean class="io.elsci.signals.mock.mongo.MongoContext"/>
    <bean class="io.elsci.signals.mock.entities.SignalsEntityApi"/>
    <bean class="io.elsci.signals.mock.attributes.SignalsAttributeApi"/>
    <bean class="io.elsci.signals.mock.assets.SignalsMaterialsApi"/>
    <bean class="io.elsci.mocks.instanceinfo.VersionApi"/>
    <bean class="io.elsci.signals.mock.exception.RestExceptionHandler"/>

    <bean class="io.elsci.signals.mock.assets.AssetsDao">
        <constructor-arg index="1" value="${signals.mongo.db}"/>
        <constructor-arg index="2" value="${signals.mongo.entities_collection:entities}"/>
    </bean>
    <bean class="io.elsci.signals.mock.attributes.AttributeDao">
        <constructor-arg index="1" value="${signals.mongo.db}"/>
        <constructor-arg index="2" value="${signals.mongo.attributes_collection:attributes}"/>
    </bean>

    <bean class="io.elsci.mocks.instanceinfo.InstanceInfo">
        <constructor-arg index="0" value="${version}"/>
        <constructor-arg index="1" value="${commit}"/>
    </bean>
    <bean id="objectMapper" class="io.elsci.sdk.util.JsonObjectMapperFactory" factory-method="create"/>

    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="propertySources">
            <bean class="io.elsci.springutils.PropertySourcesFactoryBean">
                <constructor-arg index="0">
                    <array>
                        <bean class="io.elsci.springutils.EnvironmentPropertySource"/>
                        <!-- We'll enable AWS when we need it -->
                        <!--<bean class="io.elsci.springutils.AwsSecretPropertySource"/>-->

                        <!-- It's important that we SWITCH OFF AUTOWIRING here because one of the possible params
                             is ClassLoader, and Spring starts too look for all possible implementations of the
                             ClassLoader - for this it start loading the beans BEFORE the whole property resolution
                             logic is initialized - and so the props aren't getting resolved. -->
                        <bean class="org.springframework.core.io.support.ResourcePropertySource" autowire="no">
                            <constructor-arg type="org.springframework.core.io.Resource" value="classpath:/elsci-mocks/application.properties"/>
                        </bean>
                        <bean class="org.springframework.core.io.support.ResourcePropertySource" autowire="no">
                            <constructor-arg type="org.springframework.core.io.Resource" value="classpath:/elsci-mocks/version.properties"/>
                        </bean>
                    </array>
                </constructor-arg>
            </bean>
        </property>
    </bean>

    <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
        <mvc:message-converters>
            <!--  Required by springdoc swagger -->
            <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper" ref="objectMapper"/>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
        <property name="useRegisteredExtensionsOnly" value="true"/>
        <property name="favorParameter" value="true"/>
        <property name="parameterName" value="format"/>
        <property name="defaultContentType" value="application/json"/>
        <property name="mediaTypes">
            <map>
                <entry key="css" value="text/css"/>
                <entry key="js" value="application/javascript"/>
                <entry key="json" value="application/json"/>
                <entry key="excel" value="application/vnd.ms-excel"/>
            </map>
        </property>
    </bean>

    <bean name="multipartResolver" class="org.springframework.web.multipart.support.StandardServletMultipartResolver" />
    <!-- Required for springdoc/swagger -->
    <bean id="mvcConversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"/>
</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy