首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring in action 2.0读书笔记(2)

2012-10-28 
springin action 2.0读书笔记(二)Bean scopesingleton:Scopes the bean definition to a single instance

spring in action 2.0读书笔记(二)
Bean scope
singleton:Scopes the bean definition to a single instance per Spring container (default).
prototype:Allows a bean to be instantiated any number of times (once per use).
request:Scopes a bean definition to an HTTP request. Only valid when used with a webcapable Spring context (such as with Spring MVC).
session:Scopes a bean definition to an HTTP session. Only valid when used with a webcapable Spring context (such as with Spring MVC).
global-session:Scopes a bean definition to a global HTTP session. Only valid when used in a portlet context.


<bean id="theStage" /><bean id="kenny" destroy-method="cleanInstrument"><property name="song" value="Jingle Bells" /><property name="instrument" ref="saxophone" /></bean>

Creating beans from factory methods.
The init-method attribute specifies a method that is to be called on the bean immediately upon instantiation. Similarly, destroy-method specifies a method that is called just before a bean is removed from the container.

热点排行