Skip to content

Commit 14f5dc8

Browse files
committed
20180918 spring study 때 배운 부분 정리
1 parent df71074 commit 14f5dc8

7 files changed

Lines changed: 133 additions & 5 deletions

File tree

‎_data/pageMap.yml‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
BeanScope:
2+
type: wiki
3+
title: BeanScope
4+
summary: 'Bean scope 에 대한 설명'
5+
parent: Spring
6+
url: /wiki/BeanScope
7+
updated: '2018-09-18 20:11:14 +0900'
8+
children: []
19
'CORS (Cross Origin Resource Sharing)':
210
type: wiki
311
title: 'Cross Origin Resource Sharing'
@@ -28,15 +36,15 @@ Enum:
2836
summary: 'Enum 사용법 및 팁'
2937
parent: Java
3038
url: /wiki/Enum
31-
updated: '2018-09-18 01:47:53 +0900'
39+
updated: '2018-09-18 01:50:39 +0900'
3240
children: []
3341
index:
3442
type: wiki
3543
title: index
3644
summary: 'anyjava wiki index'
3745
parent: null
3846
url: /wiki/index
39-
updated: '2018-09-18 01:38:37 +0900'
47+
updated: '2018-09-18 20:12:49 +0900'
4048
children: []
4149
Jackson:
4250
type: wiki
@@ -53,7 +61,7 @@ Java:
5361
parent: index
5462
url: /wiki/Java
5563
updated: '2018-09-13 08:36:04 +0900'
56-
children: [Enum, Jackson]
64+
children: [Enum, Jackson, Optional, PostContrunct]
5765
JPA:
5866
type: wiki
5967
title: JPA
@@ -78,14 +86,30 @@ Logging:
7886
url: /wiki/Logging
7987
updated: '2018-09-05 09:25:23 +0900'
8088
children: []
89+
Optional:
90+
type: wiki
91+
title: Optional
92+
summary: 'Optional 사용법 및 팁'
93+
parent: Java
94+
url: /wiki/Optional
95+
updated: '2018-09-18 20:00:21 +0900'
96+
children: []
97+
PostContrunct:
98+
type: wiki
99+
title: 'PostConstruct Annotation'
100+
summary: 'PostConstruct annotion 의 사용법 용례'
101+
parent: Java
102+
url: /wiki/PostContrunct
103+
updated: '2018-09-18 20:13:23 +0900'
104+
children: []
81105
Spring:
82106
type: wiki
83107
title: Spring
84108
summary: 'Spring 활용에 관한 모든것'
85109
parent: index
86110
url: /wiki/Spring
87111
updated: '2018-09-05 09:22:27 +0900'
88-
children: [JPA, Logging, Spring_Boot_Actuator]
112+
children: [BeanScope, JPA, Logging, Spring_Boot_Actuator]
89113
Spring_Boot_Actuator:
90114
type: wiki
91115
title: 'Spring Boot Actuator'

‎_data/tagList.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
- annoatation
2+
- bean_scope
13
- devops
24
- docker
35
- 'enum,'
46
- jackson
57
- java
8+
- 'java,'
9+
- 'Java,'
610
- jpa
711
- 'json,'
812
- linux
13+
- optional
914
- slf4j
1015
- spring
16+
- 'spring,'
1117
- 'spring,springboot,actuactor'
1218
- tools

‎_data/tagMap.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
'spring,':
2+
- {fileName: BeanScope}
3+
bean_scope:
4+
- {fileName: BeanScope}
15
devops:
26
- {fileName: DevOps}
37
docker:
@@ -17,6 +21,14 @@ linux:
1721
- {fileName: Linux}
1822
slf4j:
1923
- {fileName: Logging}
24+
'Java,':
25+
- {fileName: Optional}
26+
optional:
27+
- {fileName: Optional}
28+
'java,':
29+
- {fileName: PostContrunct}
30+
annoatation:
31+
- {fileName: PostContrunct}
2032
spring:
2133
- {fileName: Spring}
2234
'spring,springboot,actuactor':

‎_wiki/BeanScope.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout : wiki
3+
title : BeanScope
4+
summary : Bean scope 에 대한 설명
5+
date : 2018-09-18 20:05:34 +0900
6+
updated : 2018-09-18 20:11:14 +0900
7+
tags : spring, bean_scope
8+
toc : true
9+
public : true
10+
parent : Spring
11+
latex : false
12+
---
13+
* TOC
14+
{:toc}
15+
16+
# Bean Scope
17+
18+
* Spring Bean 의 생성 주기를 설정할 수 있다.
19+
* org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_SINGLETON
20+
* org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE
21+
* SessionScope
22+
* RequestScope
23+
* JobScope
24+
* StepScope
25+
26+
## 주의사항
27+
28+
* org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE
29+
* 실제 `@Autowired` 해서 주입된 bean 을 getter 로 조회 한다면 동일한 객체에 접근이 된다.
30+
* 따라서 아래와 같은 방법으로 사용하자.
31+
* Provider<Object> 로 주입 받아아 한다.(javax)
32+
* ObjectFactory<Object> 로 주입 받는다. (spring)

‎_wiki/Optional.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout : wiki
3+
title : Optional
4+
summary : Optional 사용법 및 팁
5+
date : 2018-09-18 19:58:14 +0900
6+
updated : 2018-09-18 20:00:21 +0900
7+
tags : Java, optional
8+
toc : true
9+
public : true
10+
parent : Java
11+
latex : false
12+
---
13+
* TOC
14+
{:toc}
15+
16+
# Optional
17+
18+
## 사용상 주의 사항
19+
20+
* Optional 은 객체의 Field 로 사용하는걸 권장하지 않는다.
21+
* Optional 은 member field 초기화 될때 default 값이 null 이다. => 으잉??? 뭐야 Optional 이 Null 인 케이스가 있다.
22+
* Optional 은 Serializable 하지 않다. 즉, DTO 로 만들어서 Json 으로 변환을 하지 못함.

‎_wiki/PostContrunct.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout : wiki
3+
title : PostConstruct Annotation
4+
summary : PostConstruct annotion 의 사용법 용례
5+
date : 2018-09-18 20:01:31 +0900
6+
updated : 2018-09-18 20:13:23 +0900
7+
tags : java, annoatation
8+
toc : true
9+
public : true
10+
parent : Java
11+
latex : false
12+
---
13+
* TOC
14+
{:toc}
15+
16+
# PostConstruct annotation
17+
18+
## 설명
19+
* 객체의 생성 직후, 수행되는 method 이다.
20+
* Java 의 표준 annotation 이며, Spring 에서도 Bean 생성 후, 연관관계 주입 후에 수행된다.
21+
22+
## 사용 사례
23+
24+
* 어디서 많이 사용할까?
25+
* 한번에 대량의 데이터를 미리 읽어 둘때, ex) 지역코드 정보, 공통 코드 정보
26+
* 사용자의 명령이나 행동 패턴에 따른 Command Object 를 Map에 저장해 두고 싶을때,
27+
* 사용자의 명령 commaon String 이나 enum type 을 Map 의 key 로 지정하고 value 에는 Command 객체를 미리 매핑해두고 로직에서 사용한다.
28+
* 이렇게 사용하면 if 문을 획기적으로 줄일 수 있다.
29+
* TODO: examples...

‎_wiki/index.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout : wiki
33
title : index
44
summary : anyjava wiki index
55
date : 2018-08-15 19:41:36 +0900
6-
updated : 2018-09-18 01:38:37 +0900
6+
updated : 2018-09-18 20:12:49 +0900
77
tags :
88
toc : true
99
public : true
@@ -17,9 +17,12 @@ latex : false
1717
* [[Java]]
1818
* [[Jackson]]
1919
* [[Enum]]
20+
* [[Optional]]
21+
* [[PostContrunct]]
2022
* [[Spring]]
2123
* [[Spring_Boot_Actuator]]
2224
* [[JPA]]
25+
* [[BeanScope]]
2326
* [[DevOps]]
2427
* [[Linux]]
2528
* [[Docker]]

0 commit comments

Comments
 (0)