본문 바로가기
국비교육

국비교육 66일차

by Diligejy 2019. 3. 12.

1.

Maven Project는 인터넷에 연결되어있지 않으면 사용할 수가 없다(라이브러리가 계속 UPDATE)


2.

1) DI 클래스


2) xml 태그 안에 <beans> <bean> </bean> </beans>로 객체를 선언한다.


3) 프로그램 로직에서 호출하고 싶은 클래스의 객체를 xml 파일에 선언된 클래스의 id로 찾아온다.

new ClassPathXmlApplicationContext(); - xml파일을 가져온다.
getBean() 메소드로 id를 찾아온다

3. DI 
의존관계 관리하기 위한 방법
1) 생성자
2) Setter

4.

Bean factory implementations should support the standard bean lifecycle interfaces as far as possible. The full set of initialization methods and their standard order is:

  1. BeanNameAware's setBeanName
  2. BeanClassLoaderAware's setBeanClassLoader
  3. BeanFactoryAware's setBeanFactory
  4. EnvironmentAware's setEnvironment
  5. EmbeddedValueResolverAware's setEmbeddedValueResolver
  6. ResourceLoaderAware's setResourceLoader (only applicable when running in an application context)
  7. ApplicationEventPublisherAware's setApplicationEventPublisher (only applicable when running in an application context)
  8. MessageSourceAware's setMessageSource (only applicable when running in an application context)
  9. ApplicationContextAware's setApplicationContext (only applicable when running in an application context)
  10. ServletContextAware's setServletContext (only applicable when running in a web application context)
  11. postProcessBeforeInitialization methods of BeanPostProcessors
  12. InitializingBean's afterPropertiesSet
  13. a custom init-method definition
  14. postProcessAfterInitialization methods of BeanPostProcessors

5.

싱글톤 패턴(Singleton Pattern) : static method와 private 생성자를 만들어서 단 하나의 인스턴스만 연동할 수 있도록 구현하는 패턴


(Java에서 Calendar Class, Graphics Class 등이 이에 속한다)


class Test{

private Test(){}

public static Test getInc() { return new Test(); }

}


=> Test t1 = Test.getInc(); => 싱글톤


싱글톤 레지스트리 : 스프링에서 직접 싱글톤 형태의 오브젝트를 만들고 관리하는 기능을 제공하는 것을 말한다.


스프링은 빈 오브젝트는 내부적으로 싱글톤 레지스트리를 만들어서 연동한다.


싱글톤의 조건

ⓐ 클래스가 은닉되어있어야 함

ⓑ 자기자신을 호출해주는 static Method가 있어야 함


'국비교육' 카테고리의 다른 글

국비교육 68일차  (0) 2019.03.14
국비교육 67일차  (0) 2019.03.13
국비교육 65일차  (0) 2019.03.11
국비교육 64일차  (0) 2019.03.08
국비교육 63일차  (0) 2019.03.07

댓글