package com.indeed.proctor.service.core.config;

import com.indeed.proctor.common.AbstractProctorLoader;
import com.indeed.proctor.common.JsonProctorLoaderFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Contains beans and core configuration items that are independent of deployment.
 */
@Configuration
public class CoreConfig {

    @Bean
    public AbstractProctorLoader proctorLoader(
            @Value("${proctor.test.matrix.path}") final String testMatrixPath,
            @Value("${proctor.test.specification.path}") final String testSpecPath) {
        final JsonProctorLoaderFactory factory = new JsonProctorLoaderFactory();
        factory.setFilePath(testMatrixPath);
        factory.setSpecificationResource(testSpecPath);
        final AbstractProctorLoader loader = factory.getLoader();
        loader.run(); // ensure ProctorLoader runs once
        return loader;
    }
}

@@ -42,16 +42,116 @@
 onfig;%0A%0A
+import com.google.common.collect.Maps;%0Aimport com.indeed.proctor.common.AbsentProctorSpecification;%0A
 import c
@@ -257,16 +257,200 @@
 actory;%0A
+import com.indeed.proctor.common.ProctorSpecification;%0Aimport com.indeed.proctor.service.core.var.VariableConfiguration;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -614,16 +614,39 @@
 ation;%0A%0A
+import java.util.Map;%0A%0A
 /**%0A * C
@@ -780,16 +780,31 @@
   @Bean%0A
+    @Autowired%0A
     publ
@@ -938,82 +938,53 @@
     
-@Value(%22$%7Bproctor.test.specification.path%7D%22) final String testSpecPath
+final ProctorSpecification specification
 ) %7B%0A
+%0A
     
@@ -1141,29 +1141,22 @@
 tion
-Resource(testSpecPath
+(specification
 );%0A 
@@ -1304,11 +1304,1128 @@
 r;%0A    %7D
+%0A%0A    @Bean%0A    @Autowired%0A    public ProctorSpecification proctorSpecification(final VariableConfiguration varConfig) %7B%0A        // Don't use JsonServiceConfig autowired in method parameters.%0A        // We need the fully qualified type name for ProctorUtils to load the class without errors.%0A        // VariableConfiguration converted types so that %22UserAgent%22 -%3E %22com.indeed.proctor.service.deploy.useragent.UserAgent%22%0A        final JsonServiceConfig jsonServiceConfig = varConfig.getJsonConfig();%0A%0A        // Let API have access to all existing tests.%0A        final ProctorSpecification spec = new AbsentProctorSpecification();%0A%0A        // Generate a provided context from our own type configuration.%0A        final Map%3CString, String%3E contextMap = Maps.newHashMap();%0A        for (final Map.Entry%3CString, JsonContextVarConfig%3E e : jsonServiceConfig.getContext().entrySet()) %7B%0A            final String varName = e.getKey();%0A            final JsonContextVarConfig var = e.getValue();%0A            contextMap.put(varName, var.getType());%0A        %7D%0A        spec.setProvidedContext(contextMap);%0A%0A        return spec;%0A    %7D
 %0A%7D%0A

Stop using specification.