forked from JavaOPs/topjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_06_bean_life_cycle.patch
More file actions
49 lines (44 loc) · 1.73 KB
/
3_06_bean_life_cycle.patch
File metadata and controls
49 lines (44 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Index: src/main/java/ru/javawebinar/topjava/repository/mock/InMemoryMealRepositoryImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/ru/javawebinar/topjava/repository/mock/InMemoryMealRepositoryImpl.java (date 1520799144000)
+++ src/main/java/ru/javawebinar/topjava/repository/mock/InMemoryMealRepositoryImpl.java (date 1520877425484)
@@ -1,5 +1,7 @@
package ru.javawebinar.topjava.repository.mock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
import ru.javawebinar.topjava.model.Meal;
@@ -7,6 +9,8 @@
import ru.javawebinar.topjava.util.DateTimeUtil;
import ru.javawebinar.topjava.util.MealsUtil;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Collections;
@@ -23,6 +27,7 @@
@Repository
public class InMemoryMealRepositoryImpl implements MealRepository {
+ private static final Logger log = LoggerFactory.getLogger(InMemoryMealRepositoryImpl.class);
// Map userId -> (mealId-> meal)
private Map<Integer, Map<Integer, Meal>> repository = new ConcurrentHashMap<>();
@@ -47,6 +52,16 @@
return meals.computeIfPresent(meal.getId(), (id, oldMeal) -> meal);
}
+ @PostConstruct
+ public void postConstruct() {
+ log.info("+++ PostConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ log.info("+++ PreDestroy");
+ }
+
@Override
public boolean delete(int id, int userId) {
Map<Integer, Meal> meals = repository.get(userId);