package io.teiler.server.config;

import static spark.Spark.ipAddress;
import static spark.Spark.port;

import io.teiler.server.endpoints.EndpointController;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Holds the configuration and programmatic setup required for Spark.
 *
 * @author pbaechli
 */
@Configuration
@EnableTransactionManagement
public class SparkConfiguration {

    @Value("${server.ip}")
    private String ip;

    @Value("${server.port}")
    private int port;

    @Autowired
    private List<EndpointController> endpoints = new ArrayList<>();

    @PostConstruct
    public void init() {
        ipAddress(ip);
        port(port);
    }

    @Bean
    CommandLineRunner sparkRunner() {
        return args -> endpoints.stream().forEach(EndpointController::register);
    }

}

@@ -101,62 +101,8 @@
 t;%0A%0A
-import io.teiler.server.endpoints.EndpointController;%0A
 impo
@@ -144,24 +144,25 @@
 .util.List;%0A
+%0A
 import javax
@@ -188,16 +188,17 @@
 struct;%0A
+%0A
 import o
@@ -555,16 +555,71 @@
 ement;%0A%0A
+import io.teiler.server.endpoints.EndpointController;%0A%0A
 /**%0A * H

reorder imports, cause eclipse