서비스 및 데이터 액세스 계층에 액세스 할 수있는 세션 빈이 필요하지만 모든 객체에 세션 빈을 삽입하고 싶지는 않습니다.Spring과 JSF의 세션 빈 검색에 대한 정적 클래스
나는 이것을 원하지 않는다 :
<!-- a HTTP Session-scoped bean exposed as a proxy -->
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
<!-- this next element effects the proxying of the surrounding bean -->
<aop:scoped-proxy/>
</bean>
<!-- a singleton-scoped bean injected with a proxy to the above bean -->
<bean id="userService" class="com.foo.SimpleUserService">
<!-- a reference to the proxied 'userPreferences' bean -->
<property name="userPreferences" ref="userPreferences"/>
</bean>
는 현재 요청의 세션 빈을 검색하기위한 정적 클래스를 만들 추적 할 수없는 가망인가? 이 같은
뭔가 :
<!-- a HTTP Session-scoped bean exposed as a proxy -->
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
<!-- this next element effects the proxying of the surrounding bean -->
<aop:scoped-proxy/>
</bean>
Public Class sessionResolver{
public static UserPreferences getUserPreferences(){
//Not real code!!!
return (UserPreferences)WebApplicationContex.getBean("userPreferences")
}
}
나는 스프링 구성에서 수행 할 수 없다고 생각하기 때문에 mock 코드를 getUserPreferences에 넣었지만 물론 코드 대신 구성을 선호합니다. – jlvaquero