Spring Web Flow Bean 作用域和 JSF
我最近完成了 Spring Web Flow 中一個有趣的問題。這個問題 (SWF-163) 涉及為 Spring Web Flow 的內部作用域新增 Spring 2.0 Bean 作用域支援。實現過程本身並不是特別有趣(畢竟 Scope 介面實現起來相當容易),但我想要具體說明一下如何在你的應用中使用類似功能。
Spring 2.0 作用域
在 Spring 1.x 中,我們有 singleton 和 prototype bean 作用域的概念,但表示法是固定的,並且使用 singleton="[true | false]" 不是特別有描述性。因此在 Spring 2.0 中,這種表示法從 XSD 風格的配置中移除,現在你看到了更清晰的表示法 scope="[singleton | prototype | ...]"。Spring 本身添加了另外三個與 Web 應用相關的 Bean 作用域:request、session 和 globalSession。隨著 Spring Web Flow 1.1 的最新快照版本釋出,我們現在可以看到三個主要的 Web Flow 作用域的 Bean 作用域:flash、flow 和 conversation。
<bean id="sale" class="org.springframework.webflow.samples.sellitem.Sale…