package com.realdolmen.jcc.springasyncdemo.b_async;

import com.realdolmen.jcc.springasyncdemo.Browser;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@EnableAutoConfiguration
@SpringBootApplication
public class ApplicationRunner extends Application {

    private static String[] args;

    public static void main(String[] args) {
        ApplicationRunner.args = args;
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Youtube browser");

        ApplicationContext applicationContext = SpringApplication.run(ApplicationRunner.class, args);
        Browser browser = applicationContext.getBean(AsyncBrowser.class);
        browser.goToUrl("https://youtube.com");

        stage.setScene(new Scene((Parent) browser, 800, 600));
        stage.show();
    }

}
