J2EE without EJB Reading Notes-light weight container & IOC

Source: Internet
Author: User

The services provided by the container include:
1. lifecycle management
2. Search: Search for references to Managed Objects
3. Configuration: use consistent methods to configure Managed Objects
4. dependency parsing:

There are two IOC policies:
1. Dependency search: a traditional method similar to JNDI
2. Dependency injection: The method using JavaBean property is called setter injection or type 2,
The constructor parameters are called constructor injection or Type 3.

Setter injection: the setter method of Javabean is executed immediately after the object instance is constructed by the container and before any business method is called.
It works well for objects with default values, meaning that all properties are not required during runtime.
The setter order is not expressed in any contract. Not all necessary setters are called before the object is used,
Therefore, the object may only be partially configured. (spring can avoid this through dependency check)

Constructor receives input parameters and assigns values to properties.
Each managed object can be fully configured.
Valuable legacyCodeNot supported, such as commons DBCP.
These references in the object cannot be changed after the collaboration parameters are passed in the constructor and the member variables are initialized.

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.