# 스코프와 Provider

main() 메서드로 스프링을 실행하고, 웹 브라우저에 <http://localhost:8080/log-demo> 를 입력하자.

* ObjectProvider 덕분에 **ObjectProvider.getObject() 를 호출하는 시점까지 request scope 빈의 생성을 지연**!(생성을 지연한다기보다 스프링컨테이너에 요청하는 것을 지연. 그러면 스프링 빈이 나중에 그 시점에 생성해준다.)
* ObjectProvider.getObject() 를 호출하시는 시점에는 HTTP 요청이 진행중이므로 request scope 빈의 생성이 정상 처리된다.
* ObjectProvider.getObject() 를 LogDemoController , LogDemoService 에서 각각 시간차를 두고 따로 호출해도 같은 HTTP 요청이면 같은 스프링 빈이 반환된다!

결론

아무리 많은 HTTP 요청이 동시에 들어와도 스프링은 각 요청당 한 개의 빈을 할당한다!\
멤버변수로 request scope을 하면 HTTP 요청이 들어와서 끝나는 시점까지 고유한 HTTP UUID를 가지며 각 요청을 식별할 수 있다!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/spring/undefined-9/provider-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
