Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IoC 컨테이너 5부 : 빈의 스코프. #3

Open
namnani opened this issue Nov 27, 2020 · 0 comments
Open

IoC 컨테이너 5부 : 빈의 스코프. #3

namnani opened this issue Nov 27, 2020 · 0 comments

Comments

@namnani
Copy link
Owner

namnani commented Nov 27, 2020

@Scope("prototype")
@Scope(value = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Autowired
private ObjectProvider<Proto> proto;

public Proto getProto() {
	return proto.getIfAvailable();
}

프로토타입 빈이 싱글톤 빈을 참조하면?

  • 아무 문제 없음.

싱글톤 빈이 프로토타입 빈을 참조하면?

  • 프로토타입 빈이 업데이트가 안됨.
  • 업데이트 하려면
    • scoped-proxy
    • ObjectProvider
    • Provider(표준)

싱글톤 객체 사용시 주의할 점

  • 프로퍼티가 공유됨. => thread safe한 방법으로 코딩을 해야함.
  • ApplicationContext 초기 구동시 인스턴스 생성.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant