문제 설명
Stateless EJB가 역직렬화될 때 @Resource 주석이 적용됩니까? (Is the @Resource annotation applied when a Stateless EJB is deserialized?)
EJB
가 역직렬화될 때 메소드의 @Resource
주석이 적용됩니까? 컨테이너에 의해 지속되는 EJB 타이머가 있으며 EJB가 역직렬화될 때 일시적인 TimerService
(직렬화할 수 없음)가 다시 주입되는지 알고 싶습니다.
참조 솔루션
방법 1:
Perhaps this articles help:
Stateless Session Bean: the stateless session EJB is injected at creation time, and keeps it's resources along its life time.
Stateful Session Bean: It seems that the dependency injection only occurs at creation time. Anyway, after activation, the @PostActivate callback Handler is invoked, where you could recover your transient elements.
Edit for adding the Java EE Tutorial link on this subject, which confirms what is exposed:
So, as a conclusion, the answer is no, the container won't inject again your transient resources after activation, but you can implement a PostActivate handler to do it by your own means.
(by n002213f、Tomas Narros)