사용자 도구

사이트 도구


springframework:scope

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
springframework:scope [2018/09/17 17:55]
kwon37xi [prototype]
springframework:scope [2018/09/17 18:03] (현재)
kwon37xi
줄 1: 줄 1:
 ====== Spring Bean Scope ====== ====== Spring Bean Scope ======
-===== prototype =====+  * [[https://www.baeldung.com/spring-lookup|@Lookup Annotation in Spring]] 
 + 
 +===== prototype Scope =====
   * 매번 객체 새로 생성할 필요가 있을 경우 사용한다.   * 매번 객체 새로 생성할 필요가 있을 경우 사용한다.
   * [[http://docs.oracle.com/javaee/7/api/javax/annotation/PreDestroy.html|@PreDestroy]] 애노테이션이 작동하지 않는다. 즉, 초기화는 하지만 종료 처리는 하지 않으므로 종료처리를 Bean 사용처에서 직접해야 한다. 그 외의 다른 스코프에서는 작동한다.    * [[http://docs.oracle.com/javaee/7/api/javax/annotation/PreDestroy.html|@PreDestroy]] 애노테이션이 작동하지 않는다. 즉, 초기화는 하지만 종료 처리는 하지 않으므로 종료처리를 Bean 사용처에서 직접해야 한다. 그 외의 다른 스코프에서는 작동한다. 
     * [[http://stackoverflow.com/questions/22848563/predestroy-on-session-scoped-spring-mvc-controllers|참조 @PreDestroy on session scoped ...]]     * [[http://stackoverflow.com/questions/22848563/predestroy-on-session-scoped-spring-mvc-controllers|참조 @PreDestroy on session scoped ...]]
 +  * [[https://www.baeldung.com/spring-inject-prototype-bean-into-singleton|Injecting Prototype Beans into a Singleton Instance in Spring]] Prototype scope 객체 얻는 다양한 방법
  
 ==== 구현방법 Provider<T> ==== ==== 구현방법 Provider<T> ====
줄 14: 줄 17:
 ... ...
 </code> </code>
-===== request/session =====+ 
 +==== @Lookup ==== 
 +  * ''@Lookup'' 메소드를 호출하면 매번 새로운 객체를 생성해준다. [[https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Lookup.html|@Lookup]] 
 + 
 +<code java> 
 +@Component 
 +public class SingletonLookupBean { 
 +  
 +    @Lookup 
 +    public PrototypeBean getPrototypeBean() { 
 +        return null; 
 +    } 
 +
 +</code> 
 + 
 +===== request/session Scope =====
   * 웹 Request/Session 이 생성될 때마다 객체를 새로 생성하여 넘겨준다.   * 웹 Request/Session 이 생성될 때마다 객체를 새로 생성하여 넘겨준다.
   * [[http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-factory-scopes-other|Bean Factory Scopes Other]]   * [[http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-factory-scopes-other|Bean Factory Scopes Other]]
springframework/scope.1537174504.txt.gz · 마지막으로 수정됨: 2018/09/17 17:55 저자 kwon37xi