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

[Relearn Spring] 2.1 IoC - Misc 一

2012-10-07 
[Relearn Spring] 2.1 IoC - Misc 11. BeanFactory V.S. ApplicationContextBeanFactory only handles the

[Relearn Spring] 2.1 IoC - Misc 1
1. BeanFactory V.S. ApplicationContext

  BeanFactory only handles the managements of beans.
  ApplicaitonContext is build upon BeanFactory (by inheritance) but add enterprise support to it, such as AOP/Resource etc.

2. BeanDefinition will hold the metadata for beans, such as  scope, lazy-initialization and so on.

3. You can use your self-defined to create your bean, just by XML configuration

 

 <bean id="exampleBean"factory-bean="serviceLocator"factory-method="createInstance"/>  



3.
 <ref local="someBean"/>    
means that the container will try to seek this bean in the same xml file.


4.
<bean id="beanOne" depends-on="manager"/>
will tell the container to initialize "beanOne" after it initializes "manager"


5.Inject "local" variable

package fiona.apple;// no more Spring imports!public abstract class CommandManager {public Object process(Object commandState) {// grab a new instance of the appropriate Command interfaceCommand command = createCommand();// set the state on the (hopefully brand new) Command instancecommand.setState(commandState);return command.execute();}// okay... but where is the implementation of this method?protected abstract Command createCommand();}



<bean id="commandManager" bean="command"/></bean>

热点排行