I'm new to the spring framework. In most of the Spring tutorials I saw, Spring is described as "non-invasive".
What is meant by invasive? What are the merits of using Spring in Java and what makes it non-invasive?
An invasive framework means that you are force to extend one of their classes or implement one of their interfaces. You can see that in frameworks like Struts or EJB2. Spring is not-invasive because avoids that.
Spring can be non-intrusive meaning you can write components which have no dependency on Spring. However, this require dicipline and in reality, many Spring project introduce dependancies on Spring and how it behaves so IMHO many Spring project don't use it as a non-intrusive container.
(NON-in-VAY-siv) In medicine, it describes a procedure that does not require inserting an instrument through the skin or into a body opening. In cancer, it describes disease that has not spread outside the tissue in which it began.
In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container.
Claiming that Spring is non-invasive is like claiming that the earth is flat. You completely deny reality based on nothing else than your personal bias. Spring is not only invasive to your code base, it is also invasive to your brain.
Define invasive. invasive synonyms, invasive pronunciation, invasive translation, English dictionary definition of invasive. adj. 1. Of, engaging in, or given to armed aggression: an invasive military force. 2. a. Of or relating to a disease or condition that has a tendency to...
An invasive framework means that you are force to extend one of their classes or implement one of their interfaces. You can see that in frameworks like Struts or EJB2. Spring is not-invasive because avoids that.
Difference between Invasive & Non-invasive and Intrusive & Non-intrusive. Invasive devices have transducers which come into contact with the flowing fluid. They are also called ‘wetted’ transducers. Non–invasive transducers do not come into contact with the fluid and are placed on the outside of the pipe.
If an IoC container is invasive, it means your code needs to be explicitly aware of dependency injection. For example, in Guice you use the @Inject
annotation (and others). These annotations are more standardized than they used to be, which is good - it means with a single set of annotations you can (at least in theory) make your code available for use with various different invasive IoC containers.
With a non-invasive container, you can write your code with no reference to IoC at all... everything is just determined by reflection over members and annotations which would be present even if you weren't using IoC.
There are pros and cons of both invasive and non-invasive containers - being more specific in code can give you more control over some of the details of binding, for example - but it's worth being aware of the difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With