BeanFactoryLocator

Pro Spring: Spring and EJB. Learn how to use Spring with EJB applictions

Although all the ApplicationContext instances created for your EJB instances are identically configured, the beans are not identical. Consider a Spring configuration that defines the echoService bean the EchoServiceEJB will use. If your application server creates 100 instances of your EJB, then 100 instances of ContextJndiBeanFactoryLocator are created, along with 100 instances of ClassPathXmlApplicationContext and 100 instances of the echoService bean.

If this behavior is undesirable for your application, then Spring provides the SingletonBeanFactoryLocator and ContextSingletonBeanFactoryLocator classes that load singleton instances of BeanFactory and ApplicationContext, respectively. For more information, see the Javadoc for these classes.


Enterprise JavaBeans 第3版のp386脚注より

1個のステートレスセッションBeanインスタンスが存続する期間は非常に長いものとされていますが、実際のEJBサーバーの中にはメソッド呼び出しのたびにインスタンスの生成/破棄を行うものもあり、ステートレスBeanを使うメリットが必ずしも得られない場合があります。ステートレスBeanインスタンスの実際の扱いについてはベンダのドキュメントを参照する必要があります。

ContextSingletonBeanFactoryLocatorを使ったほうがよさげか。