[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"/>
<ref local="someBean"/>means that the container will try to seek this bean in the same xml file.
<bean id="beanOne" depends-on="manager"/>will tell the container to initialize "beanOne" after it initializes "manager"
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>