Portlet开发学习笔记(一)
Portlet开发学习笔记(一)
作者:Kagula
日期:2008-11-2
学习对象:
《使用 Spring 2 Portlet MVC 框架构建 Portlet 应用》
http://www.ibm.com/developerworks/cn/java/j-lo-spring2-portal/
学习笔记:
《使用 Spring 2 Portlet MVC 框架构建 Portlet 应用》文章中,springPortlet项目结构图。
图一 springPortlet结构图
上图太复杂,我们把springPortlet1独立出来,如下图:
图二 springtest-protlet1结构图
下面我们讨论springtest-Portlet2、springtest-Portlet3,它们使用同一个springtest-Portlet2.xml来配置自己的属性。
第一次进入TestBeanScopePage页面时,控制台会打印出下列信息
bean [requestTestBean] was initialized at Sun Nov 02 12:15:09 CST 2008
bean [sessionTestBean] was initialized at Sun Nov 02 12:15:09 CST 2008
bean [globalSessionTestBean] was initialized at Sun Nov 02 12:15:09 CST 2008
bean [requestTestBean] was initialized at Sun Nov 02 12:15:09 CST 2008
bean [sessionTestBean] was initialized at Sun Nov 02 12:15:09 CST 2008
当再次刷新TestBeanScopePage页面时,控制台会打印出下列信息
bean [requestTestBean] was initialized at Sun Nov 02 12:18:27 CST 2008
bean [requestTestBean] was initialized at Sun Nov 02 12:18:27 CST 2008
证明:每次Request会新建一个requestBean. 每次Session会新建一个sessionBean.
所有的Session会共享globalBean。
注意:Spring 上下文加载过程中使用 springportal.bean.TestBean.setBeanName 方法将 Bean 的名称(XML 配置中 id 或者 name 属性)注入到 Bean 的属性中,并且在 Bean 初始化完成后调用 afterPropertiesSet 方法。
图三 控制器
上图中的TestScopeController.handleRenderRequestInternal负责Render、TestScopeController.handlerActionRequest负责Action。
学习总结:
理解portlet框架机制。