-
Notifications
You must be signed in to change notification settings - Fork 0
Temporary comment for SO user ignore
This is a bad question and will probably be closed (It was), I'll try to get something quick in first (I didn't).
Spring is a way to allow you to register class instances and automatically have them inserted into places where you need them.
For instance, instead of constantly saying:
Log log=new Logger(this.class, "Something else")
you say something more like:
@Inject Log log
and spring will figure out what to put into "log" for you.
This simple ability starts to open up HUGE numbers of possibilities, there are so many uses for this concept and others that spawn from it that they are still being figured out.
Also, since it has to scan all the files for annotations and have ways to intercept "New" calls (Something that often involves code between your invocation of new and the object's constructor being called), you have piles of more things you get to do with that additional ability.
Spring is so general and powerful that to just call it a IOC framework is an understatement, but that was it's original purpose--IOC means inversion of control, spring's initial/core purpose, which allows an object to "Request" another object rather than forcing the caller to create both object and pass one to another.
This can also allow you to use data to reconfigure your program by specifying what object to feed to another object based on external configuration.
The most common example is having a log or database access object replaced by one that does nothing or routes to System.out during a test rather than having the log/database access hardcoded or passed in every time (both have disadvantages)