Spring IOC One Page Guide

来源:百度文库 编辑:神马文学网 时间:2024/04/30 04:03:09

MicroSpring
A Spring Framework (mainly) compatible IOC container by J.Gibbons, Feb 2005
http://www.tallsoftware.com/microspring/
HomeSpring Framework 1 page Guide (html)
Spring Framework 1 page Guide (PDF)
MicroSpring short user guide
Download MicroSpring
Background notes which you can ignore
The Spring IOC Guide in a single sheet of paper! Either printthis off, ordownload the PDF version.
All you need to know! (for the average user, on green field project )
Source: C:\\spring-framework-1.1.3\docs\reference\html_single\index.html
Note from the author.
I only use Spring for IOC, not for AOP, not for DAO, not for JDBC rewrite, not for Web, or every other part of my system. I have a JVM and an OS, I do not need yet another J2EE. This is my personal choice, and one I am extremely happy with.
All the notes you need on Spring IOC.
Avoid anything that ties your code to the spring framework.
Do use ApplicationListener to get refresh and close events for your singletons on close down (even though it is a spring interface).
Use setters and not constructors for injection.
For most users, beans in the container will be singletons. They are created at startup by the app context unless lazy-init="true"
Use to inject other beans into properties.
To force order of creation you can use the depends-on=”beanId”
If you need lifecycle then use the init-method and destroy-method attributes. Only do this on singleton beans.
Template beans avoid repitition; the abstract and parent attributes.
Use ApplicationContext as your bean factory
Do not use spring ApplicationListeners for broadcast of your own events – write your own mechanism and avoid being tied to spring. Event frameworks are very simple!
ApplicationContextAware interface has method setApplicationContext() which the app context calls, allows the use of app contexts (resources, events etc) – but it ties you to spring!
Data source beans are great, select your db pool implementation, define a datasource bean or set of them and inject it in.
changing the auto wiring mode is discouraged. i.e. the default works out dependencies, and creation ordering.
<<<<<<< .mine=======>>>>>>> .r28 Client Code: FileSystemXmlApplicationContext factory = new XmlBeanFactory("config.xml"); Client Code: FileSystemXmlApplicationContext factory = new FileSystemXmlApplicationContext("config.xml");
BeanFactory methods: boolean containsBean(String) Object getBean(String)throws BeansException; Object getBean(String,Class) throws BeansException; boolean isSingleton(String) throws NoSuchBeanDefinitionException Class getType(String name) throws NoSuchBeanDefinitionException; String[] getAliases(String)throws NoSuchBeanDefinitionException;
Null param value null =
Empty string value "" =
The list, set, map, and props elements allow properties and arguments of Java type List, Set, Map, and Properties, respectively, to be defined and set.
London Frankfurt Europe America Earth sol Mars