image.png

스프링 컨테이너가 우리가 작성한 코드와 구성정보를 가지고 어떻게 무슨일을 하는지에 대해서 잘 나타낸 그림.

싱글톤 레지스트리(Singleton Registry)

싱글톤 레지스트리의 단점

스프링의 정체성? 싱글톤 레지스트리

구성정보 확인

getBean 메서드를 이용해서 구성정보 확인

public class Client {
    public static void main(String[] args) throws IOException {
        BeanFactory benFactory = new AnnotationConfigApplicationContext(ObjectFactory.class);
        PaymentService paymentService = benFactory.getBean(PaymentService.class);
        PaymentService paymentService2 = benFactory.getBean(PaymentService.class);

        System.out.println("paymentService = " + paymentService);
        System.out.println("paymentService2 = " + paymentService2);
        System.out.println("paymentService == paymentService2 = " + (paymentService == paymentService2));

        Payment payment = paymentService.prepare(100L, "USD", BigDecimal.valueOf(50.7));
        System.out.println(payment);
    }
}

image.png

@Configuration을 이용해서 확인하는 경우