package com.restOne;

import java.util.Arrays;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import com.restOne.Recipe.RecipeRepository;
import com.restOne.configurationExample.AnnotationConfiguration;
import com.restOne.configurationExample.TypeSafeConfiguration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ComponentScan(basePackages = { "com.restOne.Recipe", "com.restOne.greeting", "com.restOne.configurationExample" })
@SpringBootApplication
public class Application {

    private static final Logger LOG = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
    	final ApplicationContext ctx = SpringApplication.run(Application.class, args);
    	final TypeSafeConfiguration typeSafeConfiguration = ctx.getBean(TypeSafeConfiguration.class);
        final AnnotationConfiguration annotationConfiguration = ctx.getBean(AnnotationConfiguration.class);

        info("Application initialized with the following configuration:");
        info(typeSafeConfiguration.toString());
        info(annotationConfiguration.toString());
        System.out.println();
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx, RecipeRepository repository) {

	return args -> {

	    System.out.println("Let's inspect the beans provided by Spring Boot:");

	    String[] beanNames = ctx.getBeanDefinitionNames();
	    Arrays.sort(beanNames);
	    for (String beanName : beanNames) {
		System.out.println(beanName);
	    }

	    LOG.debug("inspected the beans");

	};
    }
    
    private static void info(String text) {
        System.out.println(String.format("Application.java: %s", text));
    }

}

@@ -13,19 +13,17 @@
 restOne;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -39,19 +39,17 @@
 .Arrays;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -91,17 +91,16 @@
 eRunner;
-%0D
 %0Aimport 
@@ -134,33 +134,32 @@
 ringApplication;
-%0D
 %0Aimport org.spri
@@ -207,25 +207,24 @@
 Application;
-%0D
 %0Aimport org.
@@ -266,17 +266,16 @@
 Context;
-%0D
 %0Aimport 
@@ -318,17 +318,16 @@
 on.Bean;
-%0D
 %0Aimport 
@@ -379,19 +379,17 @@
 entScan;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -424,17 +424,16 @@
 ository;
-%0D
 %0Aimport 
@@ -489,17 +489,16 @@
 uration;
-%0D
 %0Aimport 
@@ -552,19 +552,17 @@
 uration;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -578,17 +578,16 @@
 .Logger;
-%0D
 %0Aimport 
@@ -610,19 +610,17 @@
 Factory;
-%0D%0A%0D
+%0A
 %0A@Compon
@@ -727,17 +727,16 @@
 mple%22 %7D)
-%0D
 %0A@Spring
@@ -750,17 +750,16 @@
 lication
-%0D
 %0Apublic 
@@ -777,19 +777,17 @@
 cation %7B
-%0D%0A%0D
+%0A
 %0A    pri
@@ -856,27 +856,145 @@
 tion.class);
-%0D%0A%0D
+%0A%0A    /**%0A     * Entry main of the restOne project%0A     * @param args agrs are forwarded to SpringApplication.run%0A     */
 %0A    public 
@@ -1026,17 +1026,16 @@
  args) %7B
-%0D
 %0A    %09fi
@@ -1110,17 +1110,16 @@
 , args);
-%0D
 %0A    %09fi
@@ -1209,17 +1209,16 @@
 .class);
-%0D
 %0A       
@@ -1317,19 +1317,17 @@
 .class);
-%0D%0A%0D
+%0A
 %0A       
@@ -1393,17 +1393,16 @@
 tion:%22);
-%0D
 %0A       
@@ -1433,33 +1433,32 @@
 ion.toString());
-%0D
 %0A        info(an
@@ -1491,17 +1491,16 @@
 ring());
-%0D
 %0A       
@@ -1521,26 +1521,23 @@
 intln();
-%0D
 %0A    %7D
-%0D%0A%0D
+%0A
 %0A    @Be
@@ -1538,17 +1538,16 @@
    @Bean
-%0D
 %0A    pub
@@ -1640,19 +1640,17 @@
 itory) %7B
-%0D%0A%0D
+%0A
 %0A%09return
@@ -1659,19 +1659,17 @@
 rgs -%3E %7B
-%0D%0A%0D
+%0A
 %0A%09    Sy
@@ -1737,19 +1737,17 @@
 Boot:%22);
-%0D%0A%0D
+%0A
 %0A%09    St
@@ -1794,17 +1794,16 @@
 Names();
-%0D
 %0A%09    Ar
@@ -1823,17 +1823,16 @@
 nNames);
-%0D
 %0A%09    fo
@@ -1864,17 +1864,16 @@
 Names) %7B
-%0D
 %0A%09%09Syste
@@ -1900,19 +1900,16 @@
 me);
-%0D
 %0A%09    %7D
-%0D%0A%0D
+%0A
 %0A%09  
@@ -1947,29 +1947,24 @@
 s%22);
-%0D%0A%0D
+%0A
 %0A%09%7D;
-%0D
 %0A    %7D
-%0D
 %0A    
-%0D
 %0A   
@@ -2003,17 +2003,16 @@
  text) %7B
-%0D
 %0A       
@@ -2080,18 +2080,14 @@
 t));
-%0D
 %0A    %7D
-%0D%0A%0D
+%0A
 %0A%7D
-%0D
 %0A

edit javadoc