diff --git a/2021-11/spring-05-adv-conf/.gitignore b/2021-11/spring-05-adv-conf/.gitignore
new file mode 100644
index 00000000..e62c33c2
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/.gitignore
@@ -0,0 +1,4 @@
+.idea/
+*.iml
+
+target/
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/.gitignore b/2021-11/spring-05-adv-conf/application-events-demo/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/README.md b/2021-11/spring-05-adv-conf/application-events-demo/README.md
new file mode 100644
index 00000000..63e68847
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/README.md
@@ -0,0 +1,2 @@
+# application-events-demo
+Пример работы с событиями
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/pom.xml b/2021-11/spring-05-adv-conf/application-events-demo/pom.xml
new file mode 100644
index 00000000..1d59ab8b
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/pom.xml
@@ -0,0 +1,62 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ application-events-demo
+ 0.0.1-SNAPSHOT
+ application-events-demo
+ Application events demo
+
+
+ 11
+ 11
+ 11
+ 2.0.1.RELEASE
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.shell
+ spring-shell-starter
+ ${spring.shell.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/ApplicationEventsDemoApplication.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/ApplicationEventsDemoApplication.java
new file mode 100644
index 00000000..5b8d7ef3
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/ApplicationEventsDemoApplication.java
@@ -0,0 +1,26 @@
+package ru.otus.example.applicationeventsdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.event.ApplicationEventMulticaster;
+import org.springframework.context.event.SimpleApplicationEventMulticaster;
+import org.springframework.core.task.SimpleAsyncTaskExecutor;
+
+@SpringBootApplication
+public class ApplicationEventsDemoApplication {
+
+ //@Bean @Primary
+ //@Bean(name = "applicationEventMulticaster")
+ public ApplicationEventMulticaster applicationEventMulticaster() {
+ SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
+ eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
+ return eventMulticaster;
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApplicationEventsDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/EventsPublisher.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/EventsPublisher.java
new file mode 100644
index 00000000..2274570a
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/EventsPublisher.java
@@ -0,0 +1,5 @@
+package ru.otus.example.applicationeventsdemo.events;
+
+public interface EventsPublisher {
+ void publish();
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEvent.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEvent.java
new file mode 100644
index 00000000..22bab552
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEvent.java
@@ -0,0 +1,15 @@
+package ru.otus.example.applicationeventsdemo.events;
+
+import lombok.Getter;
+import org.springframework.context.ApplicationEvent;
+
+public class HalfAGlassOfWaterEvent extends ApplicationEvent {
+
+ @Getter
+ private final String payload;
+
+ public HalfAGlassOfWaterEvent(Object source) {
+ super(source);
+ payload = "Осталось половина стакана воды!!!";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEventPublisher.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEventPublisher.java
new file mode 100644
index 00000000..a1186fcc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/HalfAGlassOfWaterEventPublisher.java
@@ -0,0 +1,17 @@
+package ru.otus.example.applicationeventsdemo.events;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class HalfAGlassOfWaterEventPublisher implements EventsPublisher {
+
+ private final ApplicationEventPublisher publisher;
+
+ @Override
+ public void publish() {
+ publisher.publishEvent(new HalfAGlassOfWaterEvent(this));
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/NegativeRespondent.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/NegativeRespondent.java
new file mode 100644
index 00000000..ce6115c9
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/NegativeRespondent.java
@@ -0,0 +1,18 @@
+package ru.otus.example.applicationeventsdemo.events;
+
+import lombok.SneakyThrows;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NegativeRespondent implements ApplicationListener {
+
+ @SneakyThrows
+ @Override
+ public void onApplicationEvent(HalfAGlassOfWaterEvent halfAGlassOfWaterEvent) {
+ Thread.sleep(100);
+ System.out.println("Негативно настроенный слушатель");
+ System.out.println(String.format("- %s", halfAGlassOfWaterEvent.getPayload()));
+ System.out.println("- Какой ужас. Теперь он наполовину пуст!!!\n\n");
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/PositiveRespondent.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/PositiveRespondent.java
new file mode 100644
index 00000000..fb930f9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/events/PositiveRespondent.java
@@ -0,0 +1,18 @@
+package ru.otus.example.applicationeventsdemo.events;
+
+import lombok.SneakyThrows;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+@Component
+public class PositiveRespondent {
+
+ @SneakyThrows
+ @EventListener
+ public void onApplicationEvent(HalfAGlassOfWaterEvent halfAGlassOfWaterEvent) {
+ Thread.sleep(100);
+ System.out.println("Позитивно настроенный слушатель");
+ System.out.println(String.format("- %s", halfAGlassOfWaterEvent.getPayload()));
+ System.out.println("- Ничего. Главное, что он наполовину полон!!!\n\n");
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommands.java b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommands.java
new file mode 100644
index 00000000..153a61ae
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommands.java
@@ -0,0 +1,35 @@
+package ru.otus.example.applicationeventsdemo.shell;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.shell.Availability;
+import org.springframework.shell.standard.ShellComponent;
+import org.springframework.shell.standard.ShellMethod;
+import org.springframework.shell.standard.ShellMethodAvailability;
+import org.springframework.shell.standard.ShellOption;
+import ru.otus.example.applicationeventsdemo.events.EventsPublisher;
+
+@ShellComponent
+@RequiredArgsConstructor
+public class ApplicationEventsCommands {
+
+ private final EventsPublisher eventsPublisher;
+
+ private String userName;
+
+ @ShellMethod(value = "Login command", key = {"l", "login"})
+ public String login(@ShellOption(defaultValue = "AnyUser") String userName) {
+ this.userName = userName;
+ return String.format("Добро пожаловать: %s", userName);
+ }
+
+ @ShellMethod(value = "Publish event command", key = {"p", "pub", "publish"})
+ @ShellMethodAvailability(value = "isPublishEventCommandAvailable")
+ public String publishEvent() {
+ eventsPublisher.publish();
+ return "Событие опубликовано";
+ }
+
+ private Availability isPublishEventCommandAvailable() {
+ return userName == null? Availability.unavailable("Сначала залогиньтесь"): Availability.available();
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/main/resources/application.yml b/2021-11/spring-05-adv-conf/application-events-demo/src/main/resources/application.yml
new file mode 100644
index 00000000..3680b6b5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+logging:
+ level:
+ root: ERROR
+
+
+spring:
+ main:
+ allow-circular-references: true
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/test/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommandsTest.java b/2021-11/spring-05-adv-conf/application-events-demo/src/test/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommandsTest.java
new file mode 100644
index 00000000..be44d813
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/test/java/ru/otus/example/applicationeventsdemo/shell/ApplicationEventsCommandsTest.java
@@ -0,0 +1,67 @@
+package ru.otus.example.applicationeventsdemo.shell;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.shell.Availability;
+import org.springframework.shell.CommandNotCurrentlyAvailable;
+import org.springframework.shell.Shell;
+import org.springframework.test.annotation.DirtiesContext;
+import ru.otus.example.applicationeventsdemo.events.EventsPublisher;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+@DisplayName("Тест команд shell ")
+@SpringBootTest
+class ApplicationEventsCommandsTest {
+
+ @MockBean
+ private EventsPublisher eventsPublisher;
+
+ @Autowired
+ private Shell shell;
+
+ private static final String GREETING_PATTERN = "Добро пожаловать: %s";
+ private static final String DEFAULT_LOGIN = "AnyUser";
+ private static final String CUSTOM_LOGIN = "Вася";
+ private static final String COMMAND_LOGIN = "login";
+ private static final String COMMAND_LOGIN_SHORT = "l";
+ private static final String COMMAND_PUBLISH = "publish";
+ private static final String COMMAND_PUBLISH_EXPECTED_RESULT = "Событие опубликовано";
+ private static final String COMMAND_LOGIN_PATTERN = "%s %s";
+
+ @DisplayName(" должен возвращать приветствие для всех форм команды логина")
+ @Test
+ void shouldReturnExpectedGreetingAfterLoginCommandEvaluated() {
+ String res = (String) shell.evaluate(() -> COMMAND_LOGIN);
+ assertThat(res).isEqualTo(String.format(GREETING_PATTERN, DEFAULT_LOGIN));
+
+ res = (String) shell.evaluate(() -> COMMAND_LOGIN_SHORT);
+ assertThat(res).isEqualTo(String.format(GREETING_PATTERN, DEFAULT_LOGIN));
+
+ res = (String) shell.evaluate(() -> String.format(COMMAND_LOGIN_PATTERN, COMMAND_LOGIN_SHORT, CUSTOM_LOGIN));
+ assertThat(res).isEqualTo(String.format(GREETING_PATTERN, CUSTOM_LOGIN));
+ }
+
+ @DisplayName(" должен возвращать CommandNotCurrentlyAvailable если при попытке выполнения команды publish пользователь выполнил вход")
+ @DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
+ @Test
+ void shouldReturnCommandNotCurrentlyAvailableObjectWhenUserDoesNotLoginAfterPublishCommandEvaluated() {
+ Object res = shell.evaluate(() -> COMMAND_PUBLISH);
+ assertThat(res).isInstanceOf(CommandNotCurrentlyAvailable.class);
+ }
+
+ @DisplayName(" должен возвращать статус выполнения команды publish и вызвать соответствующий метод сервиса есл икоманда выполнена после входа")
+ @DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
+ @Test
+ void shouldReturnExpectedMessageAndFirePublishMethodAfterPublishCommandEvaluated() {
+ shell.evaluate(() -> COMMAND_LOGIN);
+ String res = (String) shell.evaluate(() -> COMMAND_PUBLISH);
+ assertThat(res).isEqualTo(COMMAND_PUBLISH_EXPECTED_RESULT);
+ verify(eventsPublisher, times(1)).publish();
+ }
+}
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/application-events-demo/src/test/resources/application.yml b/2021-11/spring-05-adv-conf/application-events-demo/src/test/resources/application.yml
new file mode 100644
index 00000000..b4921681
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/application-events-demo/src/test/resources/application.yml
@@ -0,0 +1,4 @@
+spring:
+ shell:
+ interactive:
+ enabled: false
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/.gitignore b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/README.md b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/README.md
new file mode 100644
index 00000000..75a9cff8
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/README.md
@@ -0,0 +1,19 @@
+#### Упражнение №2
+- Изучить классы ничего в них не меняя:
+ - CustomBeanFactoryPostProcessor
+ - CustomBeanPostProcessor
+ - CustomLifeCycleBean
+- Запуститить приложение
+- Изучить распечатанный жизненный цикл
+
+
+#### Упражнение №3
+- В application.yml выставить spring.shell.interactive.enabled в true
+- Запуститить приложение командой "cfn" или "call-favorite-number"
+- Запомнить результат
+- В CustomBeanFactoryPostProcessor раскомментировать блок кода
+- Запуститить приложение командой "cfn" или "call-favorite-number"
+- Что изменилось?
+- В CustomBeanPostProcessor раскомментировать строку
+- Запуститить приложение командой "cfn" или "call-favorite-number"
+- Что изменилось теперь? Круто, да?
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/pom.xml b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/pom.xml
new file mode 100644
index 00000000..0e741ab9
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/pom.xml
@@ -0,0 +1,42 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+ ru.otus.example
+ beans-lifecycle-exercise
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/BeansLifecycleDemoApplication.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/BeansLifecycleDemoApplication.java
new file mode 100644
index 00000000..337afceb
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/BeansLifecycleDemoApplication.java
@@ -0,0 +1,20 @@
+package ru.otus.example.beanslifecycledemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import ru.otus.example.beanslifecycledemo.domain.Phone;
+
+@SpringBootApplication
+public class BeansLifecycleDemoApplication {
+
+ public static void main(String[] args) {
+ ApplicationContext ctx = SpringApplication.run(BeansLifecycleDemoApplication.class, args);
+ try {
+ Phone phone = ctx.getBean(Phone.class);
+ phone.callFavoriteNumber();
+ }catch (Exception e) {
+ }
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/FriendPhoneNumber.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/FriendPhoneNumber.java
new file mode 100644
index 00000000..913d7db0
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/FriendPhoneNumber.java
@@ -0,0 +1,8 @@
+package ru.otus.example.beanslifecycledemo.domain;
+
+public class FriendPhoneNumber extends PhoneNumber {
+ @Override
+ public String getOwnerName() {
+ return "Друг";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/GirlfiendPhoneNumber.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/GirlfiendPhoneNumber.java
new file mode 100644
index 00000000..54e4e173
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/GirlfiendPhoneNumber.java
@@ -0,0 +1,11 @@
+package ru.otus.example.beanslifecycledemo.domain;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class GirlfiendPhoneNumber extends PhoneNumber {
+ @Override
+ public String getOwnerName() {
+ return "Подруга";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/Phone.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/Phone.java
new file mode 100644
index 00000000..81170317
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/Phone.java
@@ -0,0 +1,18 @@
+package ru.otus.example.beanslifecycledemo.domain;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConditionalOnProperty(name = "lifecycle.print.enabled", havingValue = "false")
+@RequiredArgsConstructor
+public class Phone {
+ private String greeting = "Погнали к родителям";
+
+ private final PhoneNumber favoriteNumber;
+
+ public void callFavoriteNumber() {
+ System.out.println(favoriteNumber.getOwnerName() + " " + greeting);
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/PhoneNumber.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/PhoneNumber.java
new file mode 100644
index 00000000..215bd09f
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/domain/PhoneNumber.java
@@ -0,0 +1,7 @@
+package ru.otus.example.beanslifecycledemo.domain;
+
+public abstract class PhoneNumber {
+ public String getOwnerName() {
+ return "Спорт-лото";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanDefinitionRegistrar.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanDefinitionRegistrar.java
new file mode 100644
index 00000000..dd2eed77
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanDefinitionRegistrar.java
@@ -0,0 +1,60 @@
+package ru.otus.example.beanslifecycledemo.lifecycle;
+
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanNameGenerator;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.core.env.Environment;
+import org.springframework.core.type.AnnotationMetadata;
+
+import java.util.Optional;
+
+public class CustomBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar, EnvironmentAware {
+ private Environment environment;
+
+ @Override
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
+ BeanDefinitionRegistry registry,
+ BeanNameGenerator importBeanNameGenerator) {
+ registerBeanDefinitions(importingClassMetadata, registry);
+ }
+
+ @Override
+ public void registerBeanDefinitions(AnnotationMetadata metadata,
+ BeanDefinitionRegistry registry) {
+
+ registerBeanFactoryPostProcessor(registry);
+ registerBeanPostProcessor(registry);
+
+ if (Optional.ofNullable(environment.getProperty("lifecycle.print.enabled", Boolean.class)).orElse(false)) {
+ System.out.println("Шаг #0: ImportBeanDefinitionRegistrar.registerBeanDefinitions\n");
+ registerCustomLifeCycleBean(registry);
+ }
+
+ }
+
+ private void registerCustomLifeCycleBean(BeanDefinitionRegistry registry) {
+ GenericBeanDefinition gbd = new GenericBeanDefinition();
+ gbd.setBeanClass(CustomLifeCycleBean.class);
+ registry.registerBeanDefinition("customLifeCycleBean", gbd);
+ }
+
+ private void registerBeanFactoryPostProcessor(BeanDefinitionRegistry registry) {
+ GenericBeanDefinition gbd = new GenericBeanDefinition();
+ gbd.setBeanClass(CustomBeanFactoryPostProcessor.class);
+ registry.registerBeanDefinition("customBeanFactoryPostProcessor", gbd);
+ }
+
+ private void registerBeanPostProcessor(BeanDefinitionRegistry registry) {
+ GenericBeanDefinition gbd = new GenericBeanDefinition();
+ gbd.setBeanClass(CustomBeanPostProcessor.class);
+ registry.registerBeanDefinition("customBeanPostProcessor", gbd);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanFactoryPostProcessor.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanFactoryPostProcessor.java
new file mode 100644
index 00000000..5f82e6e5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanFactoryPostProcessor.java
@@ -0,0 +1,32 @@
+package ru.otus.example.beanslifecycledemo.lifecycle;
+
+import org.springframework.beans.BeanMetadataAttribute;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.annotation.ScannedGenericBeanDefinition;
+import ru.otus.example.beanslifecycledemo.domain.FriendPhoneNumber;
+import ru.otus.example.beanslifecycledemo.domain.GirlfiendPhoneNumber;
+
+public class CustomBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+
+ if (beanFactory.containsBean("customLifeCycleBean")) {
+ System.out.println("Шаг #1: BeanFactoryPostProcessor.postProcessBeanFactory\n");
+ }
+
+/*
+ for (String beanName : beanFactory.getBeanDefinitionNames()) {
+ BeanDefinition d = beanFactory.getBeanDefinition(beanName);
+
+ if (GirlfiendPhoneNumber.class.getName().equalsIgnoreCase(d.getBeanClassName())) {
+ d.setBeanClassName(FriendPhoneNumber.class.getName());
+ ((ScannedGenericBeanDefinition) d).addMetadataAttribute(new BeanMetadataAttribute("className", FriendPhoneNumber.class.getName()));
+ d.setAutowireCandidate(true);
+ }
+ }
+*/
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanPostProcessor.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanPostProcessor.java
new file mode 100644
index 00000000..9368a673
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomBeanPostProcessor.java
@@ -0,0 +1,41 @@
+package ru.otus.example.beanslifecycledemo.lifecycle;
+
+import lombok.SneakyThrows;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import ru.otus.example.beanslifecycledemo.domain.Phone;
+
+import java.lang.reflect.Field;
+
+public class CustomBeanPostProcessor implements BeanPostProcessor {
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ if (bean.getClass().equals(CustomLifeCycleBean.class)) {
+ System.out.println("Шаг #5: BeanPostProcessor.postProcessBeforeInitialization\n");
+ }
+ return bean;
+ }
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ if (bean.getClass().equals(CustomLifeCycleBean.class)) {
+ System.out.println("Шаг #9: BeanPostProcessor.postProcessAfterInitialization\n");
+ }
+
+/*
+ if (bean.getClass().isAssignableFrom(Phone.class)) {
+ updateGreeting(bean);
+ }
+*/
+ return bean;
+ }
+
+ @SneakyThrows
+ private void updateGreeting(Object bean) {
+ Class> aClass = Phone.class;
+ Field greetingField = aClass.getDeclaredField("greeting");
+
+ greetingField.setAccessible(true);
+ greetingField.set(bean, "Ай-да в гараж. Стихи читать!");
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomLifeCycleBean.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomLifeCycleBean.java
new file mode 100644
index 00000000..b94d3e99
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/CustomLifeCycleBean.java
@@ -0,0 +1,55 @@
+package ru.otus.example.beanslifecycledemo.lifecycle;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.*;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+public class CustomLifeCycleBean implements InitializingBean, DisposableBean, BeanNameAware, BeanFactoryAware, ApplicationContextAware {
+
+ @Override
+ public void setBeanName(String s) {
+ System.out.println("Шаг #2: BeanNameAware\n");
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ System.out.println("Шаг #3: BeanFactoryAware\n");
+ }
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ System.out.println("Шаг #4: ApplicationContextAware\n");
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ System.out.println("Шаг #6: @PostConstruct\n");
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ System.out.println("Шаг #7: InitializingBean.afterPropertiesSet\n");
+ }
+
+ public void customInitMethod() {
+ System.out.println("Шаг #8: CustomLifeCycleBean.customInitMethod\n");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ System.out.println("Шаг #10: @PreDestroy\n");
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ System.out.println("Шаг #11: DisposableBean.destroy\n");
+ }
+
+ public void customDestroyMethod() {
+ System.out.println("Шаг #12: CustomLifeCycleBean.customDestroyMethod\n");
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/LifeCycleConfig.java b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/LifeCycleConfig.java
new file mode 100644
index 00000000..a1cb405b
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/java/ru/otus/example/beanslifecycledemo/lifecycle/LifeCycleConfig.java
@@ -0,0 +1,30 @@
+package ru.otus.example.beanslifecycledemo.lifecycle;
+
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Import(CustomBeanDefinitionRegistrar.class)
+@Configuration
+public class LifeCycleConfig {
+/*
+ @Bean
+ public BeanFactoryPostProcessor customBeanFactoryPostProcessor() {
+ return new CustomBeanFactoryPostProcessor();
+ }
+
+ @Bean
+ public BeanPostProcessor customBeanPostProcessor() {
+ return new CustomBeanPostProcessor();
+ }
+
+ @ConditionalOnProperty(name = "lifecycle.print.enabled", havingValue = "true")
+ @Bean(initMethod = "customInitMethod", destroyMethod = "customDestroyMethod")
+ public CustomLifeCycleBean customLifeCycleBean() {
+ return new CustomLifeCycleBean();
+ }
+*/
+}
diff --git a/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/resources/application.yml b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/resources/application.yml
new file mode 100644
index 00000000..54b14aef
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-lifecycle-exercise/src/main/resources/application.yml
@@ -0,0 +1,7 @@
+logging:
+ level:
+ root: ERROR
+
+lifecycle:
+ print:
+ enabled: true
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/.gitignore b/2021-11/spring-05-adv-conf/beans-scopes-exercise/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/README.md b/2021-11/spring-05-adv-conf/beans-scopes-exercise/README.md
new file mode 100644
index 00000000..2a7c2a04
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/README.md
@@ -0,0 +1,9 @@
+#### Упражнение №1
+- Расставить скоупы над сервисами так, чтобы приложение запустилось и заработало, как указано на странице http://localhost:8080
+- Подсказки в названии сервисов
+- Не забываем про proxyMode для некоторых скоупов
+
+```
+Задать скоуп можно с помощью аннотации @Scope
+Возможные значения: singleton, prototype, session, request
+```
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/pom.xml b/2021-11/spring-05-adv-conf/beans-scopes-exercise/pom.xml
new file mode 100644
index 00000000..991f5d9a
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/pom.xml
@@ -0,0 +1,48 @@
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ beans-scopes-exercise
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java
new file mode 100644
index 00000000..a7ce4369
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java
@@ -0,0 +1,13 @@
+package ru.otus.example.beansscopesdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class BeansScopesDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BeansScopesDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java
new file mode 100644
index 00000000..1a309a90
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java
@@ -0,0 +1,40 @@
+package ru.otus.example.beansscopesdemo.controllers;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import ru.otus.example.beansscopesdemo.services.GreetingService;
+
+@Controller
+public class GreetingController {
+ private final GreetingService singletonGreetingService;
+ private final GreetingService prototypeGreetingService1;
+ private final GreetingService prototypeGreetingService2;
+ private final GreetingService sessionGreetingService;
+ private final GreetingService requestGreetingService;
+
+ public GreetingController(@Qualifier("SingletonGreetingService") GreetingService singletonGreetingService,
+ @Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService1,
+ @Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService2,
+ @Qualifier("SessionGreetingService")GreetingService sessionGreetingService,
+ @Qualifier("RequestGreetingService")GreetingService requestGreetingService
+ ) {
+ this.singletonGreetingService = singletonGreetingService;
+ this.prototypeGreetingService1 = prototypeGreetingService1;
+ this.prototypeGreetingService2 = prototypeGreetingService2;
+ this.sessionGreetingService = sessionGreetingService;
+ this.requestGreetingService = requestGreetingService;
+ }
+
+ @GetMapping("/")
+ public String greetingPage(Model model) {
+ boolean isFirstGreetingSuccess = prototypeGreetingService1.isFirstGreetingSuccess();
+ model.addAttribute("singletonGreeting", singletonGreetingService.greeting());
+ model.addAttribute("sessionGreeting", sessionGreetingService.greeting());
+ model.addAttribute("requestGreeting", requestGreetingService.greeting());
+ model.addAttribute("prototype1Greeting", prototypeGreetingService1.greeting());
+ model.addAttribute("prototype2Greeting", isFirstGreetingSuccess? prototypeGreetingService2.greeting(): "Пока жду");
+ return "index";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java
new file mode 100644
index 00000000..3fff2235
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java
@@ -0,0 +1,35 @@
+package ru.otus.example.beansscopesdemo.services;
+
+
+import org.springframework.beans.factory.annotation.Value;
+
+public abstract class AbstractGreetingServiceImpl implements GreetingService {
+
+ @Value("${greetings.first-greeting}")
+ private String firstGreeting;
+
+ @Value("${greetings.re-greeting}")
+ private String reGreeting;
+
+ private boolean isFirstGreetingSuccess;
+
+ public AbstractGreetingServiceImpl() {
+ this.isFirstGreetingSuccess = false;
+ }
+
+ @Override
+ public boolean isFirstGreetingSuccess() {
+ return isFirstGreetingSuccess;
+ }
+
+ @Override
+ public String greeting() {
+ return currentGreeting();
+ }
+
+ private synchronized String currentGreeting() {
+ String greeting = isFirstGreetingSuccess ? reGreeting : firstGreeting;
+ isFirstGreetingSuccess = true;
+ return greeting;
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java
new file mode 100644
index 00000000..1347ff39
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java
@@ -0,0 +1,6 @@
+package ru.otus.example.beansscopesdemo.services;
+
+public interface GreetingService {
+ boolean isFirstGreetingSuccess();
+ String greeting();
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java
new file mode 100644
index 00000000..73ebdcd6
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java
@@ -0,0 +1,7 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.stereotype.Service;
+
+@Service("PrototypeGreetingService")
+public class PrototypeGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java
new file mode 100644
index 00000000..4340188e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java
@@ -0,0 +1,7 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.stereotype.Service;
+
+@Service("RequestGreetingService")
+public class RequestGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java
new file mode 100644
index 00000000..045b0b5a
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java
@@ -0,0 +1,7 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.stereotype.Service;
+
+@Service("SessionGreetingService")
+public class SessionGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java
new file mode 100644
index 00000000..b2f792a1
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java
@@ -0,0 +1,7 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.stereotype.Service;
+
+@Service("SingletonGreetingService")
+public class SingletonGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/application.yml b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/application.yml
new file mode 100644
index 00000000..a18bec79
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+greetings:
+ first-greeting: Привет
+ re-greeting: Рад снова тебя видеть
+
+
+logging:
+ level:
+ root: ERROR
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/templates/index.html b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/templates/index.html
new file mode 100644
index 00000000..3719f228
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-exercise/src/main/resources/templates/index.html
@@ -0,0 +1,45 @@
+
+
+
+
+ Advanced configuration demo
+
+
+
+
+
Демонстрация @Scope
+
+ - SingletonGreetingService должен говорить сначала "Привет", а потом все время "Рад снова тебя видеть"
+ - PrototypeGreetingService1 должен говорить сначала "Привет", а потом все время "Рад снова тебя видеть"
+ - PrototypeGreetingService2 должен говорить сначала "Пока жду", после обновления страницы "Привет", а потом все время "Рад снова тебя видеть"
+ - SessionGreetingService должен вести себя как SingletonGreetingService, но только до перезапуска браузера
+ - RequestGreetingService должен каждый раз говорить "Привет"
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/.gitignore b/2021-11/spring-05-adv-conf/beans-scopes-solution/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/README.md b/2021-11/spring-05-adv-conf/beans-scopes-solution/README.md
new file mode 100644
index 00000000..b02345e6
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/README.md
@@ -0,0 +1,15 @@
+#### Решение к упражнению №1
+
+@Scope("singleton")
+SingletonGreetingServiceImpl
+
+@Scope("prototype")
+PrototypeGreetingServiceImpl
+
+@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
+RequestGreetingServiceImpl
+
+@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
+SessionGreetingServiceImpl
+
+
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/pom.xml b/2021-11/spring-05-adv-conf/beans-scopes-solution/pom.xml
new file mode 100644
index 00000000..05f92091
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/pom.xml
@@ -0,0 +1,48 @@
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ beans-scopes-solution
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java
new file mode 100644
index 00000000..a7ce4369
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/BeansScopesDemoApplication.java
@@ -0,0 +1,13 @@
+package ru.otus.example.beansscopesdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class BeansScopesDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BeansScopesDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java
new file mode 100644
index 00000000..1a309a90
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/controllers/GreetingController.java
@@ -0,0 +1,40 @@
+package ru.otus.example.beansscopesdemo.controllers;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import ru.otus.example.beansscopesdemo.services.GreetingService;
+
+@Controller
+public class GreetingController {
+ private final GreetingService singletonGreetingService;
+ private final GreetingService prototypeGreetingService1;
+ private final GreetingService prototypeGreetingService2;
+ private final GreetingService sessionGreetingService;
+ private final GreetingService requestGreetingService;
+
+ public GreetingController(@Qualifier("SingletonGreetingService") GreetingService singletonGreetingService,
+ @Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService1,
+ @Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService2,
+ @Qualifier("SessionGreetingService")GreetingService sessionGreetingService,
+ @Qualifier("RequestGreetingService")GreetingService requestGreetingService
+ ) {
+ this.singletonGreetingService = singletonGreetingService;
+ this.prototypeGreetingService1 = prototypeGreetingService1;
+ this.prototypeGreetingService2 = prototypeGreetingService2;
+ this.sessionGreetingService = sessionGreetingService;
+ this.requestGreetingService = requestGreetingService;
+ }
+
+ @GetMapping("/")
+ public String greetingPage(Model model) {
+ boolean isFirstGreetingSuccess = prototypeGreetingService1.isFirstGreetingSuccess();
+ model.addAttribute("singletonGreeting", singletonGreetingService.greeting());
+ model.addAttribute("sessionGreeting", sessionGreetingService.greeting());
+ model.addAttribute("requestGreeting", requestGreetingService.greeting());
+ model.addAttribute("prototype1Greeting", prototypeGreetingService1.greeting());
+ model.addAttribute("prototype2Greeting", isFirstGreetingSuccess? prototypeGreetingService2.greeting(): "Пока жду");
+ return "index";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java
new file mode 100644
index 00000000..3fff2235
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/AbstractGreetingServiceImpl.java
@@ -0,0 +1,35 @@
+package ru.otus.example.beansscopesdemo.services;
+
+
+import org.springframework.beans.factory.annotation.Value;
+
+public abstract class AbstractGreetingServiceImpl implements GreetingService {
+
+ @Value("${greetings.first-greeting}")
+ private String firstGreeting;
+
+ @Value("${greetings.re-greeting}")
+ private String reGreeting;
+
+ private boolean isFirstGreetingSuccess;
+
+ public AbstractGreetingServiceImpl() {
+ this.isFirstGreetingSuccess = false;
+ }
+
+ @Override
+ public boolean isFirstGreetingSuccess() {
+ return isFirstGreetingSuccess;
+ }
+
+ @Override
+ public String greeting() {
+ return currentGreeting();
+ }
+
+ private synchronized String currentGreeting() {
+ String greeting = isFirstGreetingSuccess ? reGreeting : firstGreeting;
+ isFirstGreetingSuccess = true;
+ return greeting;
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java
new file mode 100644
index 00000000..1347ff39
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/GreetingService.java
@@ -0,0 +1,6 @@
+package ru.otus.example.beansscopesdemo.services;
+
+public interface GreetingService {
+ boolean isFirstGreetingSuccess();
+ String greeting();
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java
new file mode 100644
index 00000000..0932a66c
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/PrototypeGreetingServiceImpl.java
@@ -0,0 +1,9 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+@Scope("prototype")
+@Service("PrototypeGreetingService")
+public class PrototypeGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java
new file mode 100644
index 00000000..a1559ea3
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/RequestGreetingServiceImpl.java
@@ -0,0 +1,11 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.context.annotation.ScopedProxyMode;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.WebApplicationContext;
+
+@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
+@Service("RequestGreetingService")
+public class RequestGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java
new file mode 100644
index 00000000..e9ad2d8e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SessionGreetingServiceImpl.java
@@ -0,0 +1,11 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.context.annotation.ScopedProxyMode;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.WebApplicationContext;
+
+@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
+@Service("SessionGreetingService")
+public class SessionGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java
new file mode 100644
index 00000000..fb8406a5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/java/ru/otus/example/beansscopesdemo/services/SingletonGreetingServiceImpl.java
@@ -0,0 +1,9 @@
+package ru.otus.example.beansscopesdemo.services;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+@Scope("singleton")
+@Service("SingletonGreetingService")
+public class SingletonGreetingServiceImpl extends AbstractGreetingServiceImpl {
+}
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/application.yml b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/application.yml
new file mode 100644
index 00000000..a18bec79
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+greetings:
+ first-greeting: Привет
+ re-greeting: Рад снова тебя видеть
+
+
+logging:
+ level:
+ root: ERROR
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/templates/index.html b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/templates/index.html
new file mode 100644
index 00000000..3719f228
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/beans-scopes-solution/src/main/resources/templates/index.html
@@ -0,0 +1,45 @@
+
+
+
+
+ Advanced configuration demo
+
+
+
+
+
Демонстрация @Scope
+
+ - SingletonGreetingService должен говорить сначала "Привет", а потом все время "Рад снова тебя видеть"
+ - PrototypeGreetingService1 должен говорить сначала "Привет", а потом все время "Рад снова тебя видеть"
+ - PrototypeGreetingService2 должен говорить сначала "Пока жду", после обновления страницы "Привет", а потом все время "Рад снова тебя видеть"
+ - SessionGreetingService должен вести себя как SingletonGreetingService, но только до перезапуска браузера
+ - RequestGreetingService должен каждый раз говорить "Привет"
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/.gitignore b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/README.md b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/README.md
new file mode 100644
index 00000000..3b88aa94
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/README.md
@@ -0,0 +1,11 @@
+#### Упражнение №4
+Условия вечеринки:
+- Алексей придет если condition.alexey-exists=true
+- Анна придет если будет Алексей
+- Олег придет если включен профиль Oleg
+- Петр придет если включен профиль Peter
+- Янис придет если condition.yanis-exists=true
+- Яна придет если нет Алексея, но есть Янис
+
+Измените только одну настройку в application.yml, чтобы на вечеринку пришло максимальное количество людей
+Напечатать имена пришедших на вечеринку можно с помощью команды "ppm" или "print-party-members"
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/pom.xml b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/pom.xml
new file mode 100644
index 00000000..089951cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ conditional-and-profiles-exercise
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/ConditionalAndProfilesDemoApplication.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/ConditionalAndProfilesDemoApplication.java
new file mode 100644
index 00000000..2aa5c3a4
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/ConditionalAndProfilesDemoApplication.java
@@ -0,0 +1,17 @@
+package ru.otus.example.conditionalandprofilesdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import ru.otus.example.conditionalandprofilesdemo.model.Party;
+
+@SpringBootApplication
+public class ConditionalAndProfilesDemoApplication {
+
+ public static void main(String[] args) {
+ ApplicationContext ctx = SpringApplication.run(ConditionalAndProfilesDemoApplication.class, args);
+ Party party = ctx.getBean(Party.class);
+ party.printPartyMembers();
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Alexey.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Alexey.java
new file mode 100644
index 00000000..66091903
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Alexey.java
@@ -0,0 +1,14 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+@ConditionalOnProperty(name = "condition.alexey-exists", havingValue = "true")
+@Component
+public class Alexey extends Friend {
+ @Override
+ public String getName() {
+ return "Алексей";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Anna.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Anna.java
new file mode 100644
index 00000000..be26e16d
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Anna.java
@@ -0,0 +1,14 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+@ConditionalOnBean(Alexey.class)
+@Component
+public class Anna extends Friend {
+ @Override
+ public String getName() {
+ return "Аня";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Oleg.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Oleg.java
new file mode 100644
index 00000000..2a11f476
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Oleg.java
@@ -0,0 +1,14 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+@Profile("Oleg")
+@Component
+public class Oleg extends Friend {
+ @Override
+ public String getName() {
+ return "Олег";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Party.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Party.java
new file mode 100644
index 00000000..18a53b5d
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Party.java
@@ -0,0 +1,19 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+@RequiredArgsConstructor
+public class Party {
+ private final List partyMembers;
+
+ public void printPartyMembers() {
+ System.out.println("Участники вечеринки:");
+ System.out.println(partyMembers.stream().map(Friend::getName).collect(Collectors.joining("\n")));
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Peter.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Peter.java
new file mode 100644
index 00000000..435891a8
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Peter.java
@@ -0,0 +1,15 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+@Profile("Peter")
+@Component
+public class Peter extends Friend {
+
+ @Override
+ public String getName() {
+ return "Петр";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yana.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yana.java
new file mode 100644
index 00000000..76b0fca3
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yana.java
@@ -0,0 +1,16 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.context.annotation.Conditional;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+import ru.otus.example.conditionalandprofilesdemo.model.conditions.YanaConditions;
+
+
+@Conditional(YanaConditions.class)
+@Component
+public class Yana extends Friend {
+ @Override
+ public String getName() {
+ return "Яна";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yanis.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yanis.java
new file mode 100644
index 00000000..6dd2c14d
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/Yanis.java
@@ -0,0 +1,14 @@
+package ru.otus.example.conditionalandprofilesdemo.model;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import ru.otus.example.conditionalandprofilesdemo.model.base.Friend;
+
+@ConditionalOnProperty(name = "condition.yanis-exists", havingValue = "true")
+@Component
+public class Yanis extends Friend {
+ @Override
+ public String getName() {
+ return "Янис";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/base/Friend.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/base/Friend.java
new file mode 100644
index 00000000..2d2eb67d
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/base/Friend.java
@@ -0,0 +1,5 @@
+package ru.otus.example.conditionalandprofilesdemo.model.base;
+
+public abstract class Friend {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/conditions/YanaConditions.java b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/conditions/YanaConditions.java
new file mode 100644
index 00000000..cf130ebb
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/java/ru/otus/example/conditionalandprofilesdemo/model/conditions/YanaConditions.java
@@ -0,0 +1,20 @@
+package ru.otus.example.conditionalandprofilesdemo.model.conditions;
+
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+
+public class YanaConditions extends AllNestedConditions {
+
+ public YanaConditions() {
+ super(ConfigurationPhase.PARSE_CONFIGURATION);
+ }
+
+
+ @ConditionalOnProperty(name = "condition.alexey-exists", havingValue = "false")
+ static class AlexeyDoesNotExistsCondition {
+ }
+
+ @ConditionalOnProperty(name = "condition.yanis-exists", havingValue = "true")
+ static class YanisExistsCondition {
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application-Peter.yml b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application-Peter.yml
new file mode 100644
index 00000000..aa28b2ce
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application-Peter.yml
@@ -0,0 +1,2 @@
+condition:
+ #yanis-exists: true
diff --git a/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application.yml b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application.yml
new file mode 100644
index 00000000..50db026d
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/conditional-and-profiles-exercise/src/main/resources/application.yml
@@ -0,0 +1,20 @@
+condition:
+ alexey-exists: true
+ yanis-exists: false
+
+spring:
+ profiles:
+ #Доступные профили: Oleg и Peter
+ active:
+
+logging:
+ level:
+ root: ERROR
+
+
+---
+spring:
+ profiles: Peter
+
+condition:
+ yanis-exists: true
diff --git a/2021-11/spring-05-adv-conf/pom.xml b/2021-11/spring-05-adv-conf/pom.xml
new file mode 100644
index 00000000..6eb42cdf
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/pom.xml
@@ -0,0 +1,26 @@
+
+
+ 4.0.0
+
+ ru.otus
+ advanced-config-class-work
+ 1.0
+
+ pom
+
+
+ application-events-demo
+ beans-lifecycle-exercise
+ beans-scopes-exercise
+ beans-scopes-solution
+ conditional-and-profiles-exercise
+ test-configuration-exercise-1
+ test-configuration-exercise-2
+ test-configuration-exercise-3
+ test-configuration-solution-1
+ test-configuration-solution-2
+ test-configuration-solution-3
+
+
diff --git a/2021-11/spring-05-adv-conf/spring-shell.log b/2021-11/spring-05-adv-conf/spring-shell.log
new file mode 100644
index 00000000..5692278a
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/spring-shell.log
@@ -0,0 +1,5 @@
+1638867120546:p
+1638867124184:l
+1638867125867:p
+1638867146689:l
+1638867147641:p
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/README.md b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/README.md
new file mode 100644
index 00000000..7f84475f
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/README.md
@@ -0,0 +1,9 @@
+#### Упражнение №5. Должен остаться только один
+
+С помощью вложенных конфигураций сделать так,
+чтобы прошел NestedConfigurationDemoTest
+(family должно содержать только собаку)
+
+- Сделать вложенный класс конфигурации. Не забываем про static
+- Выбрать тип конфигурации (@Configuration/@TestConfiguration)
+- С помощью @Bean/@ComponentScan добавить в контекст нужный бин(ы)
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/pom.xml
new file mode 100644
index 00000000..1408017a
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-exercise-1
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java
new file mode 100644
index 00000000..6f1795d0
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В NestedConfigurationDemoTest семья должна ")
+@SpringBootTest
+public class NestedConfigurationDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать только собаку ")
+ @Test
+ void shouldContainOnlyDog() {
+ assertThat(family).containsOnlyKeys("dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java
new file mode 100644
index 00000000..66932497
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В PlainSpringBootTestDemoTest семья должна ")
+@SpringBootTest
+public class PlainSpringBootTestDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, сына и собаку ")
+ @Test
+ void shouldContainAllFamilyExceptFather() {
+ assertThat(family).containsOnlyKeys("mother", "son", "dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/README.md b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/README.md
new file mode 100644
index 00000000..1d6f9395
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/README.md
@@ -0,0 +1,9 @@
+#### Упражнение №6. Вернуть отца в семью
+
+С помощью вложенных конфигураций сделать так,
+чтобы прошел NestedTestConfigurationDemoTest
+(family должно содержать маму, папу, сына и собаку)
+
+- Сделать вложенный класс конфигурации. Не забываем про static
+- Выбрать тип конфигурации (@Configuration/@TestConfiguration)
+- С помощью @Bean/@ComponentScan добавить в контекст нужный бин(ы)
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/pom.xml
new file mode 100644
index 00000000..9364d956
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-exercise-2
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java
new file mode 100644
index 00000000..a4b13be6
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В NestedTestConfigurationDemoTest семья должна ")
+@SpringBootTest
+public class NestedTestConfigurationDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, папу, сына и собаку ")
+ @Test
+ void shouldContainAllFamilyWithFather() {
+ assertThat(family).containsOnlyKeys("mother", "father", "son", "dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/README.md b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/README.md
new file mode 100644
index 00000000..ca65c8aa
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/README.md
@@ -0,0 +1,8 @@
+#### Упражнение №7. Вся семья, но без собаки
+
+С помощью внешней конфигурации сделать так,
+чтобы прошел SpringBootTestWithExternalLimitationDemoTest
+(family должно содержать маму, папу и сына)
+
+- Над TestSpringBootConfiguration повесить @SpringBootConfiguration
+- С помощью @Bean/@ComponentScan добавить в контекст нужный бин(ы)
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/pom.xml
new file mode 100644
index 00000000..41607fa3
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/pom.xml
@@ -0,0 +1,51 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-exercise-3
+ 0.0.1-SNAPSHOT
+ test-configuration-demo
+ Test configuration demo
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java
new file mode 100644
index 00000000..2091efeb
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В SpringBootTestWithExternalLimitationDemoTest семья должна ")
+@SpringBootTest
+public class SpringBootTestWithExternalLimitationDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, папу и сына")
+ @Test
+ void shouldContainAllFamilyExceptFather() {
+ assertThat(family).containsOnlyKeys("mother", "father", "son");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java
new file mode 100644
index 00000000..526a3c5f
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-exercise-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java
@@ -0,0 +1,4 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+public class TestSpringBootConfiguration {
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-solution-1/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/README.md b/2021-11/spring-05-adv-conf/test-configuration-solution-1/README.md
new file mode 100644
index 00000000..68ebd53c
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/README.md
@@ -0,0 +1,7 @@
+#### Решение упражнения №5
+По заданию нужно ограничить контекст одним бином с помощью вложенной конфигурации.
+@TestConfiguration не ограничивает, а дополняет контекст новыми бинами или подменяет те, что уже там.
+Соответственно выбираем @Configuration. Вешаем его над вложенным статическим классом.
+Т.к. Dog является @Component, то для его размещения в контексте подойдет любое из:
+- @ComponentScan("ru.otus.example.testconfigurationdemo.family.pets") над конфигурацией
+- Создание бина, через метод с аннотацией @Bean внутри конфигурации
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-solution-1/pom.xml
new file mode 100644
index 00000000..a5375c8f
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-solution-1
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java
new file mode 100644
index 00000000..7d496500
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedConfigurationDemoTest.java
@@ -0,0 +1,41 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+import ru.otus.example.testconfigurationdemo.family.pets.Dog;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В NestedConfigurationDemoTest семья должна ")
+@SpringBootTest
+public class NestedConfigurationDemoTest {
+
+ @ComponentScan("ru.otus.example.testconfigurationdemo.family.pets")
+ @Configuration
+ static class NestedConfiguration {
+/*
+ @Bean
+ FamilyMember dog() {
+ return new Dog();
+ }
+*/
+ }
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать только собаку ")
+ @Test
+ void shouldContainOnlyDog() {
+ assertThat(family).containsOnlyKeys("dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java
new file mode 100644
index 00000000..66932497
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-1/src/test/java/ru/otus/example/testconfigurationdemo/demo/PlainSpringBootTestDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В PlainSpringBootTestDemoTest семья должна ")
+@SpringBootTest
+public class PlainSpringBootTestDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, сына и собаку ")
+ @Test
+ void shouldContainAllFamilyExceptFather() {
+ assertThat(family).containsOnlyKeys("mother", "son", "dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-solution-2/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/README.md b/2021-11/spring-05-adv-conf/test-configuration-solution-2/README.md
new file mode 100644
index 00000000..988e8eab
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/README.md
@@ -0,0 +1,8 @@
+#### Решение упражнения №6
+По заданию нужно добавить в контекст бин, которого там нет, с помощью вложенной конфигурации.
+
+Эту проблему можно решить с помощью @Configuration, фактически заново сформировав контекст.
+При этом @TestConfiguration может дополнить существующий. Соответственно выбираем его и вешаем над вложенным статическим классом.
+
+Т.к. Father НЕ является @Component, то для его размещения в контексте нужно его создать,
+через метод с аннотацией @Bean внутри тестовой конфигурации
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-solution-2/pom.xml
new file mode 100644
index 00000000..e65a18de
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-solution-2
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java
new file mode 100644
index 00000000..33bfe11e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-2/src/test/java/ru/otus/example/testconfigurationdemo/demo/NestedTestConfigurationDemoTest.java
@@ -0,0 +1,37 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.context.annotation.Bean;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+import ru.otus.example.testconfigurationdemo.family.parents.Father;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В NestedTestConfigurationDemoTest семья должна ")
+@SpringBootTest
+public class NestedTestConfigurationDemoTest {
+
+ @TestConfiguration
+ static class NestedTestConfiguration {
+ @Bean
+ FamilyMember father() {
+ return new Father();
+ }
+ }
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, папу, сына и собаку ")
+ @Test
+ void shouldContainAllFamilyWithFather() {
+ assertThat(family).containsOnlyKeys("mother", "father", "son", "dog");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/.gitignore b/2021-11/spring-05-adv-conf/test-configuration-solution-3/.gitignore
new file mode 100644
index 00000000..789ddc9e
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/.gitignore
@@ -0,0 +1,32 @@
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#other
+*.bat
+*/.idea
+*.iml
+*/target
+
+.idea
+*.iml
+target
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/README.md b/2021-11/spring-05-adv-conf/test-configuration-solution-3/README.md
new file mode 100644
index 00000000..c53d9710
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/README.md
@@ -0,0 +1,12 @@
+#### Решение упражнения №7
+По заданию нужно ограничить контекст заданными бинами, с помощью внешней конфигурации.
+
+Вешаем @SpringBootConfiguration над внешним классом TestSpringBootConfiguration.
+Теперь сканирование конфигураций не уйдет далше него. Ни одного бина не найдется.
+Значит нужно формировать контекст самим.
+
+По заданию в нем должны быть бины типов Mother, Son и Father. Первые два являются @Component.
+Их можно разместить в контексте просканировав соответствующие пакеты с помощью @ComponentScan
+
+Т.к. Father НЕ является @Component, то для его размещения в контексте нужно его создать,
+через метод с аннотацией @Bean внутри тестовой конфигурации
\ No newline at end of file
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/pom.xml b/2021-11/spring-05-adv-conf/test-configuration-solution-3/pom.xml
new file mode 100644
index 00000000..9d47cf55
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
+
+ ru.otus.example
+ test-configuration-solution-3
+ 0.0.1-SNAPSHOT
+
+
+ 11
+ 11
+ 11
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
new file mode 100644
index 00000000..e5dd8341
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/TestConfigurationDemoApplication.java
@@ -0,0 +1,15 @@
+package ru.otus.example.testconfigurationdemo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan("ru.otus.example.testconfigurationdemo.family")
+@SpringBootApplication
+public class TestConfigurationDemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TestConfigurationDemoApplication.class, args);
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
new file mode 100644
index 00000000..1685a4cc
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/FamilyMember.java
@@ -0,0 +1,5 @@
+package ru.otus.example.testconfigurationdemo.family;
+
+public abstract class FamilyMember {
+ public abstract String getName();
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
new file mode 100644
index 00000000..f3da3289
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/childrens/Son.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.childrens;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Son extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Сын";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
new file mode 100644
index 00000000..d531bda5
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Father.java
@@ -0,0 +1,10 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+public class Father extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Папа";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
new file mode 100644
index 00000000..d9b97b75
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/parents/Mother.java
@@ -0,0 +1,12 @@
+package ru.otus.example.testconfigurationdemo.family.parents;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Mother extends FamilyMember {
+ @Override
+ public String getName() {
+ return "Мама";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
new file mode 100644
index 00000000..3e436c12
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/main/java/ru/otus/example/testconfigurationdemo/family/pets/Dog.java
@@ -0,0 +1,13 @@
+package ru.otus.example.testconfigurationdemo.family.pets;
+
+import org.springframework.stereotype.Component;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+@Component
+public class Dog extends FamilyMember {
+
+ @Override
+ public String getName() {
+ return "Собака";
+ }
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java
new file mode 100644
index 00000000..2091efeb
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/SpringBootTestWithExternalLimitationDemoTest.java
@@ -0,0 +1,26 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("В SpringBootTestWithExternalLimitationDemoTest семья должна ")
+@SpringBootTest
+public class SpringBootTestWithExternalLimitationDemoTest {
+
+ @Autowired
+ private Map family;
+
+ @DisplayName(" содержать маму, папу и сына")
+ @Test
+ void shouldContainAllFamilyExceptFather() {
+ assertThat(family).containsOnlyKeys("mother", "father", "son");
+ }
+
+}
diff --git a/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java
new file mode 100644
index 00000000..a92ce439
--- /dev/null
+++ b/2021-11/spring-05-adv-conf/test-configuration-solution-3/src/test/java/ru/otus/example/testconfigurationdemo/demo/TestSpringBootConfiguration.java
@@ -0,0 +1,17 @@
+package ru.otus.example.testconfigurationdemo.demo;
+
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import ru.otus.example.testconfigurationdemo.family.FamilyMember;
+import ru.otus.example.testconfigurationdemo.family.parents.Father;
+
+@ComponentScan({"ru.otus.example.testconfigurationdemo.family.parents",
+ "ru.otus.example.testconfigurationdemo.family.childrens"})
+@SpringBootConfiguration
+public class TestSpringBootConfiguration {
+ @Bean
+ FamilyMember father() {
+ return new Father();
+ }
+}