Spring-intrusive and non-intrusive

Source: Internet
Author: User

1. The non-intrusive technology embodies the ability to freely select and assemble the various functional modules of the spring framework in the application system, and does not enforce that the class of the application system must inherit or implement an interface from a class of the spring framework's system API.

2. How to achieve a non-intrusive design goal

1) Applying the reflection mechanism to provide various functions through dynamic invocation, establish the core inter-group Beanfactory

2) Use the Beanwrapper and Beanfactory component classes in the spring framework to eventually achieve instance creation and attribute injection of objects

3) Advantages: Allows the development of the application system can be used in the environment of the free migration, do not need to modify the application system core function implementation of code

Let me explain briefly what I understand. Suppose everyone wants to plug the user code into a frame. An intrusive approach is to require that the user code "know" the framework's code to behave as a class that the user code needs to inherit from the framework . Non-intrusive does not require user code to introduce framework code information, from the writer's point of view, the existence of the framework is not detected. For example, when using struts, I needed to inherit some of the struts classes, when struts hacked into my code. with spring, there is no need to inherit spring-specific classes when writing some business classes, which can be used after configuration completion of dependency injection, when spring does not intrude into the code of my business class . intrusive allows user code to generate dependency on the framework, which cannot be used outside the framework and is not conducive to the reuse of code . But intrusive can make it easier for users to combine with the framework and make more use of the functionality provided by the framework. Non-intrusive code is not overly dependent and can be easily migrated to other places. But the way you interact with user code can be more complex. Both of these methods have their own pros and cons, the main look at the actual development of how to weigh.

simply put, non-intrusive is the class that does not inherit from the framework, but it can be used after the configuration completes the dependency injection!

Spring-intrusive and non-intrusive

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.