Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes the Spring framework a lightweight container?

When people mention that Spring is a lightweight containter compared to other frameworks, do they mean? That it occupies less memory in the system or it does not have the operations like start stop that we have for EJB containers and it doesn't use a special container?

What makes Spring a lightweight container?

like image 714
ronan Avatar asked Nov 14 '11 04:11

ronan


Video Answer


2 Answers

Whether it is "lightweight" or "heavyweight", it is all about comparison. We consider Spring to be lightweight when we are comparing to normal J2EE container. It is lightweight in the sense of extra memory footprint for the facilities provided (e.g. Transaction Control, Life Cycle, Component dependency management)

However, there are sometimes other criteria to compare for the "weight" of a container, e.g. intrusiveness in design and implementation; facilities provided etc.

Ironically, Spring is sometimes treated as heavy weight container when compared to other POJO-based container, like Guice and Plexus.

like image 61
Adrian Shum Avatar answered Nov 09 '22 01:11

Adrian Shum


Spring calls itself 'lightweight' because you don't need all of Spring to use part of it. For example, you can use Spring JDBC without Spring MVC.

Spring provides various modules for different purposes; you can just inject dependencies according to your required module. That is, you don't need to download or inject all dependencies or all JARs to use a particular module.

enter image description here

If you want to run a Java EE application, you can't just create a small application that will run on its own. You will need a Java EE application server to run your application, such as Glassfish, WebLogic or WebSphere. Most application servers are big and complex pieces of software, that are not trivial to install or configure.

You don't need such a thing with Spring. You can use Spring dependency injection, for example, in any small, standalone program.

like image 37
Girdhar Singh Rathore Avatar answered Nov 09 '22 00:11

Girdhar Singh Rathore