<commit_before><beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   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
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <bean id="bridgeConfig" class="org.sagebionetworks.bridge.config.BridgeConfigFactory"
            factory-method="getConfig" />

    <bean id="healthCodeEncryptor" class="org.sagebionetworks.bridge.crypto.BridgeEncryptor">
        <constructor-arg value="#{bridgeConfig.healthCodePassword}"/>
    </bean>

    <bean id="awsCredentials" class="com.amazonaws.auth.BasicAWSCredentials">
        <constructor-arg index="0" value="#{bridgeConfig.getProperty('aws.key')}"/>
        <constructor-arg index="1" value="#{bridgeConfig.getProperty('aws.secret.key')}"/>
    </bean>

    <bean id="exceptionInterceptor" class="interceptors.ExceptionInterceptor" />

    <!-- Stormpath identity service -->
    
    <bean id="stormpathClient" class="org.sagebionetworks.bridge.stormpath.StormpathFactory" 
        factory-method="createStormpathClient" scope="singleton">
    </bean>
    
    <!-- Caching abstraction -->
    
    <bean id="cacheProvider" class="org.sagebionetworks.bridge.cache.CacheProvider"/>
    
    <!-- Play controllers. -->

    <bean id="proxiedController" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyTargetClass" value="true"/>
        <property name="interceptorNames">
            <list><value>exceptionInterceptor</value></list>
        </property>
    </bean>

    <bean id="controllers.ApplicationController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.ApplicationController">
                <property name="authenticationService" ref="authenticationService" />
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>
    
    <bean id="controllers.AuthenticationController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.AuthenticationController">
                <property name="authenticationService" ref="authenticationService"/>
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>
    
    <bean id="controllers.HealthDataController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.HealthDataController">
                <property name="healthDataService" ref="healthDataService"/>
                <property name="authenticationService" ref="authenticationService"/>
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>
    
    <bean id="controllers.TrackerController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.TrackerController">
                <property name="jsonSchemaValidator">
                    <bean class="global.JsonSchemaValidator"/>
                </property>
                <property name="studyControllerService" ref="studyControllerService"/>
                <property name="authenticationService" ref="authenticationService"/>
            </bean>
        </property>
    </bean>
    
    <bean id="studyControllerService" class="controllers.StudyControllerService">
        <property name="studies">
            <list>
                <bean class="org.sagebionetworks.bridge.models.Study">
                    <constructor-arg index="0" value="Bridge Parkinson’s Research Program"/>
                    <constructor-arg index="1" value="neurod"/>
                    <constructor-arg index="2">
                        <list>
                            <!-- IE VirtualBox Machine, local development -->
                            <value>10.0.2.2</value>
                            <value>localhost</value>
                            <value>bridge-develop.herokuapp.com</value>
                            <!-- In production however, we'd expect to have DNS
                                entries like neurod.bridgesage.org, that we 
                                would use instead.
                             -->
                            <value>bridge-prod.herokuapp.<EMAIL></value>
                        </list>
                    </constructor-arg>
                    <constructor-arg index="3">
                        <list>
                            <ref bean="pb-tracker"/>
                            <ref bean="med-tracker"/>
                        </list>
                    </constructor-arg>                    
                </bean>
            </list>
        </property>
    </bean>
    
    <bean id="pb-tracker" class="org.sagebionetworks.bridge.models.Tracker">
        <property name="name" value="Blood Pressure Reading"/>
        <property name="type" value="BloodPressure"/>
        <property name="id" value="1"/>
        <property name="schemaFile" value="file:conf/schemas/bloodpressure.json"/>
    </bean>

    <bean id="med-tracker" class="org.sagebionetworks.bridge.models.Tracker">
        <property name="name" value="Medication"/>
        <property name="type" value="Medication"/>
        <property name="id" value="2"/>
        <property name="schemaFile" value="file:conf/schemas/medication.json"/>
    </bean>
    
    <!-- Services -->

    <bean id="authenticationService" class="org.sagebionetworks.bridge.services.AuthenticationServiceImpl">
        <property name="stormpathClient" ref="stormpathClient"/>
        <property name="cacheProvider" ref="cacheProvider"/>
        <property name="bridgeConfig" ref="bridgeConfig"/>
    </bean>
    
    <bean id="healthDataService" class="org.sagebionetworks.bridge.services.HealthDataServiceImpl">
        <property name="updateMapper">
            <bean class="com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper">
                <constructor-arg index="0" ref="dynamoDbClient"/>
                <constructor-arg index="1">
                    <bean class="org.sagebionetworks.bridge.dynamodb.DynamoDBMapperConfigFactory" factory-method="getUpdateMapper">
                        <constructor-arg><value>org.sagebionetworks.bridge.dynamodb.DynamoHealthDataRecord</value></constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
        <property name="createMapper">
            <bean class="com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper">
                <constructor-arg index="0" ref="dynamoDbClient"/>
                <constructor-arg index="1">
                    <bean class="org.sagebionetworks.bridge.dynamodb.DynamoDBMapperConfigFactory" factory-method="getCreateMapper">
                        <constructor-arg><value>org.sagebionetworks.bridge.dynamodb.DynamoHealthDataRecord</value></constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
        <property name="cacheProvider" ref="cacheProvider"/>
        <property name="encryptor">
            <bean class="org.sagebionetworks.bridge.crypto.EncryptorUtil" factory-method="getEncryptorOld">
	            <constructor-arg index="0" value="#{bridgeConfig.getHealthCodePassword()}"/>
	            <constructor-arg index="1" value="#{bridgeConfig.getHealthCodeSalt()}"/>
            </bean>
        </property>
    </bean>
    
    <bean id="dynamoDbClient" class="com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient" scope="prototype">
        <constructor-arg index="0">
            <ref bean="awsCredentials" />
        </constructor-arg>
    </bean>    
    
</beans><commit_msg>Should share the DynamoDB client across threads thus removing the "prototype" scope.<commit_after><beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   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
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <bean id="bridgeConfig" class="org.sagebionetworks.bridge.config.BridgeConfigFactory"
            factory-method="getConfig" />

    <bean id="healthCodeEncryptor" class="org.sagebionetworks.bridge.crypto.BridgeEncryptor">
        <constructor-arg value="#{bridgeConfig.healthCodePassword}"/>
    </bean>

    <bean id="awsCredentials" class="com.amazonaws.auth.BasicAWSCredentials">
        <constructor-arg index="0" value="#{bridgeConfig.getProperty('aws.key')}"/>
        <constructor-arg index="1" value="#{bridgeConfig.getProperty('aws.secret.key')}"/>
    </bean>

    <!-- DynamoDB -->

    <bean id="dynamoDbClient" class="com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient">
        <constructor-arg index="0">
            <ref bean="awsCredentials" />
        </constructor-arg>
    </bean>

    <bean id="exceptionInterceptor" class="interceptors.ExceptionInterceptor" />

    <!-- Stormpath identity service -->

    <bean id="stormpathClient" class="org.sagebionetworks.bridge.stormpath.StormpathFactory" 
        factory-method="createStormpathClient" scope="singleton">
    </bean>

    <!-- Caching abstraction -->

    <bean id="cacheProvider" class="org.sagebionetworks.bridge.cache.CacheProvider"/>

    <!-- Play controllers. -->

    <bean id="proxiedController" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyTargetClass" value="true"/>
        <property name="interceptorNames">
            <list><value>exceptionInterceptor</value></list>
        </property>
    </bean>

    <bean id="controllers.ApplicationController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.ApplicationController">
                <property name="authenticationService" ref="authenticationService" />
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>

    <bean id="controllers.AuthenticationController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.AuthenticationController">
                <property name="authenticationService" ref="authenticationService"/>
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>
 
    <bean id="controllers.HealthDataController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.HealthDataController">
                <property name="healthDataService" ref="healthDataService"/>
                <property name="authenticationService" ref="authenticationService"/>
                <property name="studyControllerService" ref="studyControllerService"/>
            </bean>
        </property>
    </bean>

    <bean id="controllers.TrackerController" parent="proxiedController">
        <property name="target">
            <bean class="controllers.TrackerController">
                <property name="jsonSchemaValidator">
                    <bean class="global.JsonSchemaValidator"/>
                </property>
                <property name="studyControllerService" ref="studyControllerService"/>
                <property name="authenticationService" ref="authenticationService"/>
            </bean>
        </property>
    </bean>

    <bean id="studyControllerService" class="controllers.StudyControllerService">
        <property name="studies">
            <list>
                <bean class="org.sagebionetworks.bridge.models.Study">
                    <constructor-arg index="0" value="<NAME>’s Research Program"/>
                    <constructor-arg index="1" value="neurod"/>
                    <constructor-arg index="2">
                        <list>
                            <!-- IE VirtualBox Machine, local development -->
                            <value>10.0.2.2</value>
                            <value>localhost</value>
                            <value>bridge-develop.herokuapp.com</value>
                            <!-- In production however, we'd expect to have DNS
                                entries like neurod.bridgesage.org, that we 
                                would use instead.
                             -->
                            <value>bridge-prod.herokuapp.com</value>
                        </list>
                    </constructor-arg>
                    <constructor-arg index="3">
                        <list>
                            <ref bean="pb-tracker"/>
                            <ref bean="med-tracker"/>
                        </list>
                    </constructor-arg>                    
                </bean>
            </list>
        </property>
    </bean>

    <bean id="pb-tracker" class="org.sagebionetworks.bridge.models.Tracker">
        <property name="name" value="Blood Pressure Reading"/>
        <property name="type" value="BloodPressure"/>
        <property name="id" value="1"/>
        <property name="schemaFile" value="file:conf/schemas/bloodpressure.json"/>
    </bean>

    <bean id="med-tracker" class="org.sagebionetworks.bridge.models.Tracker">
        <property name="name" value="Medication"/>
        <property name="type" value="Medication"/>
        <property name="id" value="2"/>
        <property name="schemaFile" value="file:conf/schemas/medication.json"/>
    </bean>

    <!-- Services -->

    <bean id="authenticationService" class="org.sagebionetworks.bridge.services.AuthenticationServiceImpl">
        <property name="stormpathClient" ref="stormpathClient"/>
        <property name="cacheProvider" ref="cacheProvider"/>
        <property name="bridgeConfig" ref="bridgeConfig"/>
    </bean>

    <bean id="healthDataService" class="org.sagebionetworks.bridge.services.HealthDataServiceImpl">
        <property name="updateMapper">
            <bean class="com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper">
                <constructor-arg index="0" ref="dynamoDbClient"/>
                <constructor-arg index="1">
                    <bean class="org.sagebionetworks.bridge.dynamodb.DynamoDBMapperConfigFactory" factory-method="getUpdateMapper">
                        <constructor-arg><value>org.sagebionetworks.bridge.dynamodb.DynamoHealthDataRecord</value></constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
        <property name="createMapper">
            <bean class="com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper">
                <constructor-arg index="0" ref="dynamoDbClient"/>
                <constructor-arg index="1">
                    <bean class="org.sagebionetworks.bridge.dynamodb.DynamoDBMapperConfigFactory" factory-method="getCreateMapper">
                        <constructor-arg><value>org.sagebionetworks.bridge.dynamodb.DynamoHealthDataRecord</value></constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
        <property name="cacheProvider" ref="cacheProvider"/>
        <property name="encryptor">
            <bean class="org.sagebionetworks.bridge.crypto.EncryptorUtil" factory-method="getEncryptorOld">
	            <constructor-arg index="0" value="#{bridgeConfig.getHealthCodePassword()}"/>
	            <constructor-arg index="1" value="#{bridgeConfig.getHealthCodeSalt()}"/>
            </bean>
        </property>
    </bean>
</beans>
{'fraction_non_alphanumeric': 0.13436551305403766, 'fraction_numerical': 0.003885853066180935, 'mean_word_length': 2.31742195367573, 'pattern_counts': {'":': 0, '<': 306, '<?xml version=': 0, '>': 306, 'https://': 0, 'lorem ipsum': 0, 'www.': 20, 'xml': 8}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1754477', 'n_tokens_mistral': 4415, 'n_tokens_neox': 4232, 'n_words': 623}