ApplicationContext is BeanFactory's super set.
ApplicationContext can do all the things that BeanFactory can do, but have additional features (Event notification, AOP, ..) also.
There is not enough difference in performance.
BeanFactory vs. ApplicationContext
- In ApplicationContext, here we can have more than one config files possible.
- In BeanFactory, only one config file or .xml file
- ApplicationContext can publish events to beans that are registered as listeners
- BeanFactory doesn’t support.
- ApplicationContext supports internationalization (I18N) messages
- BeanFactory not
- ApplicationContext supports application lifecycle events, and validation.
- BeanFactory doesn't support.
- ApplicationContext support many enterprise services such JNDI access, EJB integration, remoting
- BeanFactory doesn’t support.
EXAMPLE IoC
// Here, XML needs to be inside the project folder.
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("spring.xml"));
Triangle t = (Triangle) factory.getBean("triange");
t.draw();
// Here, XML needs to be in classpath - inside "src" folder in eclipse
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
Triangle t = (Triangle) context.getBean("triange");
t.draw();
No comments:
Post a Comment
Note: only a member of this blog may post a comment.