读书人

spring in action 2.0读书笔记(2)

发布时间: 2012-10-28 09:54:44 作者: rapoo

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.

读书人网 >软件架构设计

热点推荐