Spring Bean Factory Basics

I will explain the basics of Spring Inversion of Control.

1.) Spring is a Java Framework, where we can build on top this Framework with our own Java Classes, which in whole creates the Application.

2.) Spring has a functionality called IOC ( Inversion of Control ), which can be done by using DI ( Dependency Injection ).

3.) The basic setup would be:

a.) The Java Object for Application Logic. ( Yellow Box )
b.) The Java Object Spring Main to initialize. ( Grey Box )
c.) The Spring configuration ( Green lines )

( As illustrated in the figures below )

4.) Spring operates using the IOC concept. This means that classes and its fields are created by using the Spring Configuration setter. This is to eliminate the using of initialization and to prevent a “tightly coupled” in the main class.

Please see the illustration below:

Notice that Figure A. is a tightly coupled system. The yellow box represents the Main class, then the grey boxes represent the sub classes to be created inside the Main Class. This works fine as for functionality and basic design, but however as you notice, the sub classes are enclosed in the Main Class. In Design, Accessibility, Linking, Testing and Maintainability point of view, Figure B is much better. Spring in this case translates to better maintainability, design and can be easily accessible for Unit Test. In Figure B, Spring Framework is described by the green lines.

This Basic Spring functionality is the BeanFactory as described here:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s