package io.teiler.server.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import io.teiler.api.endpoint.Endpoint;

@Configuration
@EnableTransactionManagement
public class SparkConfiguration {
    
    @Autowired
    private List<Endpoint> endpoints = new ArrayList<>();

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

}

@@ -25,24 +25,59 @@
 .config;%0D%0A%0D%0A
+import static spark.Spark.port;%0D%0A%0D%0A
 import java.
@@ -115,24 +115,66 @@
 il.List;%0D%0A%0D%0A
+import javax.annotation.PostConstruct;%0D%0A%0D%0A
 import org.s
@@ -225,16 +225,76 @@
 wired;%0D%0A
+import org.springframework.beans.factory.annotation.Value;%0D%0A
 import o
@@ -664,16 +664,75 @@
 %0D%0A    %0D%0A
+    @Value(%22$%7Bserver.port%7D%22)%0D%0A    private int port;%0D%0A    %0D%0A
     @Aut
@@ -797,16 +797,96 @@
 st%3C%3E();%0D
+%0A    %0D%0A    @PostConstruct%0D%0A    public void init() %7B%0D%0A        port(port);%0D%0A    %7D%0D
 %0A%0D%0A    @

use explicit server-port for Spark