From 34b90a33aac7df4feae5867355d72bb54ed4a045 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Thu, 3 Jan 2019 14:15:43 +0100 Subject: [PATCH] BAEL-2483 --- .../java/com/baeldung/annotation/MyBean.java | 26 +++++++++++++++++++ .../com/baeldung/annotation/TestBean.java | 8 ++++++ 2 files changed, 34 insertions(+) create mode 100644 spring-core/src/main/java/com/baeldung/annotation/MyBean.java create mode 100644 spring-core/src/main/java/com/baeldung/annotation/TestBean.java diff --git a/spring-core/src/main/java/com/baeldung/annotation/MyBean.java b/spring-core/src/main/java/com/baeldung/annotation/MyBean.java new file mode 100644 index 0000000000..9a1fd3beec --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/annotation/MyBean.java @@ -0,0 +1,26 @@ +package com.baeldung.annotation; + +import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +@Component +public class MyBean { + + private final TestBean testBean; + + public MyBean(TestBean testBean) { + this.testBean = testBean; + System.out.println("Hello from constructor"); + } + + @PostConstruct + private void postConstruct() { + System.out.println("Hello from @PostConstruct method"); + } + + @PreDestroy + public void preDestroy() { + System.out.println("Bean is being destroyed"); + } +} \ No newline at end of file diff --git a/spring-core/src/main/java/com/baeldung/annotation/TestBean.java b/spring-core/src/main/java/com/baeldung/annotation/TestBean.java new file mode 100644 index 0000000000..0539e10751 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/annotation/TestBean.java @@ -0,0 +1,8 @@ +package com.baeldung.annotation; + +import org.springframework.stereotype.Component; + +@Component +public class TestBean { + +} \ No newline at end of file