Skip to content

Commit

Permalink
클린아키텍처, 네트워크 시작
Browse files Browse the repository at this point in the history
  • Loading branch information
timmy.oh committed Apr 21, 2023
1 parent 7613697 commit 4bb6701
Show file tree
Hide file tree
Showing 32 changed files with 560 additions and 45 deletions.
85 changes: 40 additions & 45 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,35 @@
"type": "split",
"children": [
{
"id": "f1bbe13c73918af4",
"id": "651b4689b025b4af",
"type": "tabs",
"children": [
{
"id": "f909c91d8ad7b761",
"id": "622fd4bc53116a1d",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "스프링/스프링 6.0 독스/스프링 6.0 독스 보기.md",
"file": "책/자바 병렬 프로그래밍.md",
"mode": "source",
"source": false
}
}
},
{
"id": "51c48677a74ddf07",
"id": "9c74d5ba02e4505d",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "스프링/스프링 6.0 독스/스프링 6.0 독스 보기.md",
"mode": "source",
"source": false
}
}
},
{
"id": "d2013a121b70e731",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "스프링/스프링 6.0 독스/10. Ahead of Time Optimizations.md",
"mode": "source",
"source": false
}
}
},
{
"id": "486b6b718336849c",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "소프트웨어 공학/리스코프 치환 원칙.md",
"file": "책/자바 네트워크 프로그래밍.md",
"mode": "source",
"source": false
}
}
}
],
"currentTab": 3
"currentTab": 1
}
],
"direction": "vertical"
Expand Down Expand Up @@ -106,7 +82,7 @@
}
],
"direction": "horizontal",
"width": 300
"width": 200
},
"right": {
"id": "79d3c9367f972a13",
Expand All @@ -122,7 +98,7 @@
"state": {
"type": "backlink",
"state": {
"file": "소프트웨어 공학/리스코프 치환 원칙.md",
"file": "책/자바 네트워크 프로그래밍.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -139,7 +115,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "소프트웨어 공학/리스코프 치환 원칙.md",
"file": "책/자바 네트워크 프로그래밍.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -162,7 +138,7 @@
"state": {
"type": "outline",
"state": {
"file": "소프트웨어 공학/리스코프 치환 원칙.md"
"file": "책/자바 네트워크 프로그래밍.md"
}
}
}
Expand All @@ -171,7 +147,8 @@
}
],
"direction": "horizontal",
"width": 300
"width": 200,
"collapsed": true
},
"left-ribbon": {
"hiddenItems": {
Expand All @@ -183,25 +160,43 @@
"command-palette:Open command palette": false
}
},
"active": "486b6b718336849c",
"active": "9c74d5ba02e4505d",
"lastOpenFiles": [
"Pasted image 20230307134230.png",
"Pasted image 20230307134219.png",
"Pasted image 20230307134141.png",
"Pasted image 20230307133634.png",
"스프링/스프링 6.0 독스/10. Ahead of Time Optimizations.md",
"file/Pasted image 20230421195653.png",
"INBOX/Java Stream, URLConnection 의 스트림.md",
"file/Pasted image 20230421202112.png",
"file/Pasted image 20230421202033.png",
"file/Pasted image 20230421201844.png",
"file/Pasted image 20230421201638.png",
"file/Pasted image 20230421201357.png",
"file/Pasted image 20230421201259.png",
"file/Pasted image 20230421201152.png",
"file/Pasted image 20230421201044.png",
"file/Pasted image 20230421200535.png",
"책/자바 네트워크 프로그래밍.md",
"책/자바 병렬 프로그래밍.md",
"책/자바 개발자를 위한 97가지 제안.md",
"INBOX/공변 반공변.md",
"책/만들면서 배우는 클린아키텍처.md",
"file",
"INBOX/코틀린 스콥 펑션.md",
"README.md",
"소프트웨어 공학/리스코프 치환 원칙.md",
"책/코틀린 인 액션.md",
"INBOX",
"OS/자바 IO 내부 동작 원리.md",
"OS",
"스프링/스프링 6.0 독스/스프링 6.0 독스 보기.md",
"스프링/스프링 6.0 독스/10. Ahead of Time Optimizations.md",
"소프트웨어 공학/file",
"소프트웨어 공학",
"스프링/스프링 6.0 독스",
"스프링/스프링 6.0 독스/스프링 6.0 독스 보기.md",
"네트워크/HttpClient 4.5 공식문서 보기/README.md",
"네트워크/HttpClient 4.5 공식문서 보기/HttpClient Overview, Quick Start.md",
"네트워크/아파치 톰캣 카탈리나 탐구/카탈리나 보기.md",
"스프링/스프링부트 3.0.md",
"DB/샤딩스피어 문서 보기.md",
"책/Cloud Native Spring in Action/README.md.md",
"네트워크/HttpClient 4.5 공식문서 보기/HttpClient Tutorial.md",
"Pasted image 20230127115821.png",
"네트워크/HttpClient 4.5 공식문서 보기/file/Pasted image 20230126180000.png"
"네트워크/HttpClient 4.5 공식문서 보기/HttpClient Tutorial.md"
]
}
92 changes: 92 additions & 0 deletions INBOX/Java Stream, URLConnection 의 스트림.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

https://www.tutorialspoint.com/java/java_files_io.htm
- ![[Pasted image 20230421192923.png]]

ByteStream
- 8비트 바이트로 통신하는 듯
- FileInput/OutputStream

Character Streams
- 16비트 유니코드 쓰는듯
- **FileReader** and **FileWriter**. Though internally FileReader uses FileInputStream and FileWriter uses FileOutputStream but here the major difference is that FileReader reads two bytes at a time and FileWriter writes two bytes at a time.



![[Pasted image 20230421193258.png]]

https://victorydntmd.tistory.com/134

![[Pasted image 20230421195606.png]]
![[Pasted image 20230421195653.png]]

- 보조 스트림은 데코레이턴 패턴으로 쓴다.


```java

new BufferReader(new InputStreamReader(urlConnection.getInputStream()))


```

- urlConnection.getInputStream 디버그 찍어보니 HttpInputStream 이다
- 이건 또 뭐냐..
- sun.net.www.protocol.http.HttpURLConnection.HttpInputStream
- java.io.FilterInputStream 상속한거네


sun.net.www.protocol.http.HttpURLConnection#getInputStream0
![[Pasted image 20230421201357.png]]

- sun.net.www.http.HttpClient#parseHTTP
![[Pasted image 20230421201259.png]]
- java.net.Socket#getInputStream
- java.net.AbstractPlainSocketImpl#getInputStream
![[Pasted image 20230421201152.png]]
- sun.net.www.http.HttpClient#parseHTTPHeader
- ![[Pasted image 20230421201844.png]]
- 아.. Transfer-Encoding 이라는 헤더값의 디폴트가 Chunked 구나
- 그래서 위에서 만들어 놨던 보조스트림인 BufferedInputStream 을 받은 ChunkedInputStream 으로 변환된 후 뭔가 작업을 하는 군



자 다시 돌아와서 기본 코드


```java
URL url = new URL("http://www.google.com");
URLConnection urlConnection = url.openConnection();
final InputStream inputStream = urlConnection.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
```

디버그찍어보면


![[Pasted image 20230421202033.png]]


sun.net.www.protocol.http.HttpURLConnection.HttpInputStream
![[Pasted image 20230421202112.png]]

- 자 이것도 보조스트림이므로 FilterInputStream 상속하긴 함 일단 이거는 보인다
- 자 이거를 도대체 왜 읽을려고 InputStreamReader에 담아서 BufferedReader 에 담나? 그거는 BufferedReader를 쓸려고 그냥 바꾼거임 끝




> - 저 parseHeader 에 많은 정보가 있어보인다.
> - 보조스트림, 주스트림 구분은 OK. 주스트림은 파일을 읽는 건데, 바이트 기반 vs 캐릭터 기반이 있는데
> - java.net.SocketInputStream 보면 이거는 FileInputStream 상속, 즉 바이트 기반
> - 이게 알 필요가 있냐고? 아직은 필요를 모르겠긴 함 헤더 Chunked 이정도만 알았네
> - 그래도 맨날 궁금했다 BufferedReader(머시기(머시기)) 딱 눈에 안들어왔는데 이제 들어오네









47 changes: 47 additions & 0 deletions INBOX/공변 반공변.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

https://www.heecheolman.dev/post/%EA%B3%B5%EB%B3%80-%EB%B0%98%EA%B3%B5%EB%B3%80/

## 공변 (Covariance)

공변이란 B가 A의 부분집합일 때 고차함수 T에 대해 `T<B>` 도 `T<A>` 의 부분집합이 되면 T는 "공변한다" 라고 합니다. 즉 A와 B의 관계가 유지될 때 공변한다고 말합니다.

예시 1. 고양이와 동물

고양이는 동물의 부분집합,
-> 동물에 고양이를 할당할 수 있고, 반대는 불가능
고양이배열, 동물배열은?
-> 동물배열에 고양이배열을 할당할 수 있고, 반대는 불가능

=> 고차타입(뭐추상화된타입..??)을 적용했더니 관계가 유지 => 공변한다...


### 쓸모

https://kdhyo98.tistory.com/83

![[Pasted image 20230420201138.png]]


- 펙스(PECS), producer-extends, consumer-super

흠...

https://asuraiv.tistory.com/16

![[Pasted image 20230420202059.png]]


음 예시를 보면 생산할려면 하위타입을 꺼내써야하므로 extends를 사용할 수 밖에 없고, 소비할려면 꺼내서 상위타입에 집어넣어야 하므로 super 를 사용할 수 밖에 없네

나도 코틀린 in out 보다가 이거 다시보게 됐는데 이사람도 똑같네

https://asuraiv.tistory.com/17

out : 소비할 수 없다. 즉 생산, 즉 extends
in : 생산할수없다, 즉 소비, 즉 super

> 음 이건 좀 더 쉽다
> 그냥 out 이면 리턴으로 사용, in 이면 파라미터로 사용
> 자 그럼 out이 extends 라는 건데 이건 뭐..

31 changes: 31 additions & 0 deletions INBOX/코틀린 스콥 펑션.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
https://kotlinworld.com/255


![[Pasted image 20230412172438.png]]


라고 하는데, 한방에 안 옴

apply : 객체에 뭔가 apply 한다
- 프로퍼티 세팅할 때 쓴다고 함

```
return a.apply { t = 1 }
```


run : 객체 가지고 run 하고, 결과 리턴한다
- 보통 쓰는 듯. (낫널에 대해)

with : 객체가지고 뭔가 하고 결과 리턴한다. (잘 안쓴단다)

let : 객체를 요렇게 하도록 놔두고, 그 결과를 리턴한다
- null 이 아닐때만 let을 실행해서, null 체크 후에 쓸 때 유용하다고 함

also : 객체도 있다. (객체 그대로 리턴)
- 프로퍼티 세팅하고, 다른 짓 할때 쓴다고 함
- 흠 위 블로그 예시가 이해가 안되는데 모르겠다 넘어간다




12 changes: 12 additions & 0 deletions OS/자바 IO 내부 동작 원리.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[하우투두인자바,페이징가상메모리](https://howtodoinjava.com/java/io/how-java-io-works-internally/)

- 가상메모리
- 메모리 페이징
- 파일, 파일 락
- 블록, 스트림

[개발한입블로그,자바로구현및설명](https://brewagebear.github.io/fundamental-nio-and-io-models/)




Binary file added file/Pasted image 20230412172438.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230420201138.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230420201510.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230420202059.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421192912.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421192923.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421193258.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421195606.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421195653.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421200535.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201044.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201259.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201357.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201638.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421201844.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421202033.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added file/Pasted image 20230421202112.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 4bb6701

Please sign in to comment.