I personally do not understand spring.net, this article is just a simple example to compare the difference between the configuration. In the Castle IOC container, the concept of automatic assembly (auto-wiring) is proposed, whereby the container automatically manages the dependencies between components, and we do not have to write our own XML configuration files
For the IOC, unity see Bo Friends article click here.Words do not say much, on the procedure hellounity, the procedure uses vs2010,unity2.1.1. The program framework is as follows2. Class library hellounity.objects, primarily entity classes, are used to create.3. Class Library HELLOUNITY.IOC, including parser production plant, parser Interface, Static Class Iochelper for us to create an object instance. 4. Class library hellounity.unity, mainly includi
In the previous topic, we learned about the basic concepts of the IOC container and how the beanfactory is designed and implemented, and here's how the ApplicationContext approach is implemented.ApplicationContextIn spring's reference documentation, why would you recommend using ApplicationContext? What benefits can it bring to our applications? As one of the implementations of Beanfactory, how is it design
(1) Each bean should provide a unique name or ID and a fully qualified class name for the IOC container to instantiate it. You can specify a
You can also declare it in the In fact, the preferred method for marking beans is: through the standard xml id attribute, if your text editor is XML aware, you can verify the uniqueness of each bean during design. This is concise. Starting from spring 2.0, you can
First in the Web. XML configurationand get the request in your bean.... HttpServletRequest request = ((servletrequestattributes) requestcontextholder.getrequestattributes ()). GetRequest () ;...It's a lot easier to get other scopes then, and this is not the case.Allows any bean to access the request, session, global session scope in the spring IOC container, Requestcontextlistener
Main content
Principle Analysis of startable facility
......
In the Castle IOC container practice startable Facility (a) we have seen how to use startable facility, this article will do some analysis of its principles. First look at the interface istartable, its implementation code is as follows:
public interface IStartable { void Start(); void Stop(); }
The code is fairly simple, with only two met
Main content
1. Typedfactory Facility Overview
2. Typedfactory Facility Quick Start
A Typedfactory Facility Overview
I believe that the factory method design mode is no stranger, in factory methods, for each specific product needs to have a corresponding factory class, with the specific products more and more, we are more and more difficult to manage the factory class, So how do you manage the plant through the IOC
the action.4, @ Repository@Repository the corresponding data access layer bean, for example:1 @Repository (value= "Userdao")2public classextends Basedaoimpl {3 ... .. 4 }The @Repository (value= "Userdao") note is to tell spring to let spring create a Userdaoimpl instance named "Userdao".When the service needs to use the Userdaoimpl instance named "Userdao" created by spring, you can use the @resource (name = "Userdao") annotation to tell Spring that Spring injects the created Userdao to
in the container in case it is modified
Beanfactory.freezeconfiguration ();
//Instantiate all remaining non-lazy-init singleton beans
Beanfactory.preinstantiatesingletons ();
}
9OtherBeanInstantiate a scenario:A.Above1-8corresponding to theBeanInstantiation relies on otherBeanTime, theBeanis instantiated at the same time (this analysisCreatebean ()B. The singleton Bean that is lazily instantiated is instantiated the first time it is insta
Spring.net helps us achieve IOC functionality through configuration files , which are very flexible and varied in approach.Click to viewWe only need to define interfaces and implementation methods, and Spring.net helps us achieve other functions.The first step is to define the interfacenamespace spring.examples.moviefinder{ publicinterface isimplemoviefinder { stringgetset;} void Show (); }}The second step is to define the im
addition to the namedparameter, there are several seed arches resolve used:
Parameter type
Parameter description
Namedparameter
Match by name
Positionalparameter
Match according to Index, note: Starting index is 0
Typedparameter
Match by type, note: Pass in multiple typedparameter of the same type, all parameters of that type will take the value of the first Typedparameter
Resolvedparameter
Recei
AUTOFAC is a lightweight, dependency-injected framework, with a framework of the same type and spring.net,unity,castle.A very depressing place to use AUTOFAC is that the server requires the Microsoft. NET Framework 4 KB2468871 to be installed. The address of the patch is: http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=3556 if not installed, the running program will report the following error: Specific information can be here to view: https://code.google.com/p/autofac/wiki/Frequent
1. Listener with spring container when service is started (method to inherit Contextloaderlistener listener) Public classListenerspringcontextextendsContextloaderlistener {Private FinalLogger log = Loggerfactory.getlogger (listenerspringcontext.class); Public voidcontextinitialized (Servletcontextevent event) {Log.info ("Init listenerspringcontext ..."); Super. contextinitialized (event); ApplicationContext ApplicationContext=Webapplicationcontextuti
resource = new ClassPathResource("META-INF/beans.xml"); BeanFactory beanFactory = new XmlBeanFactory(resource); User user = beanFactory.getBean("user1", User.class); System.out.println(user.getName()+" : "+user.getAge()); }}Steps to create a container:
To create an abstraction of a bean configuration fileResource
Created BeanFactory , for example:XmlBeanFactory
Parse the bean and create a BeanDefinition reader
The services provided by the container include:1. lifecycle management2. Search: Search for references to Managed Objects3. Configuration: use consistent methods to configure Managed Objects4. dependency parsing:
There are two IOC policies:1. Dependency search: a traditional method similar to JNDI2. Dependency injection: The method using JavaBean property is called setter injection or type 2,The construct
The SPRINGIOC container is the core content of spring.role: Create objects handle dependencies on objects.
I. IOC container Creation object:1. There are several ways to create objects:1) Call parameterless constructor2) with parametric constructor
3) factory-created objectsA) factory class, static method Creation objectb) Factory class, non-static method to cre
Summary
Martin Fowler's classicArticle+ Transparent and brilliant translation + 1-2-3 UML illustrations (this is not enough to concern your teeth, huh, huh ).
Download Original Text
IOC container and dependency injection mode Martin Fowler, transparent translation, PDF format.Good English friends can also read the original article inversion of control containers and the dependency injection pattern
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.