package de.springbootbuch.extconfig;

import de.springbootbuch.extconfig.ApplicationConfig.BarProperties;
import de.springbootbuch.extconfig.ApplicationConfig.FooProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({BarProperties.class, FooProperties.class})
public class ApplicationConfig {

    @ConfigurationProperties("bar")
    public static class BarProperties {

        private String otherValue;

        public String getOtherValue() {
            return otherValue;
        }

        public void setOtherValue(String otherValue) {
            this.otherValue = otherValue;
        }
    }

    @ConfigurationProperties("foo")
    public static class FooProperties {

        private String value;

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
    
    public static class FooService {
        final String name;

        public FooService(String name) {
            this.name = name;
        }
    }
    
    public static class BarService {
        final FooService fooService;
        
        final Integer interval;

        public BarService(FooService fooService, Integer interval) {
            this.fooService = fooService;
            this.interval = interval;
        }
    }
    
    private final FooProperties fooProperties;

    public ApplicationConfig(FooProperties fooProperties) {
        this.fooProperties = fooProperties;
    }
    
    @Bean(name = "myFooService")
    public FooService fooService() {
        return new FooService(fooProperties.getValue());
    }
    
    @Bean
    public BarService barService(ExampleProperties exampleProperties) {
        return new BarService(fooService(), exampleProperties.getInterval());
    }
}

@@ -1288,38 +1288,121 @@
 name;%0A        %7D%0A
+        %0A        public void myInit() %7B%7D%0A        %0A        public void destroy() %7B%7D%0A
     %7D%0A
-
     %0A    public 
@@ -1657,32 +1657,122 @@
 rval;%0A        %7D%0A
+        %0A        public void close() %7B%0A            System.out.println(%22close%22);%0A        %7D%0A
     %7D%0A    %0A    p
@@ -1960,16 +1960,66 @@
 Service%22
+, initMethod = %22myInit%22, destroyMethod = %22destroy%22
 )%0A    pu
@@ -2109,32 +2109,32 @@
 ());%0A    %7D%0A    %0A
-
     @Bean%0A    pu
@@ -2126,16 +2126,36 @@
    @Bean
+(destroyMethod = %22%22)
 %0A    pub

Add examples of lifecycle callbacks