a journal of a researcher

Wednesday, July 09, 2008

A first insight on Spring Framework

What is Spring? Spring is a framework for enterprise application development. It uses only the so-called plain-old java objects (POJO) to implement enterprise functions, such as database connection, resources balancing, front end, messaging, remote access. It also uses container (like EJB) to provide services to javabeans. Compared to EJB, Spring uses DI and AOP. So Spring is more loose coupling, and function separation.

For me, DI is nothing, but a design pattern. 1) use interface (object decoupling) for the attributes (objects) of a bean. Then the object does not need to know where the attribute is. Or in another word, the object does not need to know if the attribute objects are local or a remote Web service. 2) initialize the attribute object when the bean is initialized – inject the object, instead of asking the bean to search/call the object. 3) the attributes of an object can be initialized by XML description, that means the container takes care of initialization.

AOP: use DI first, that means you initialize the attribute objects. You embed one object inside a bean. The bean does not need to know the detail of the object.

1 Comments:

  • I agree that the DI is a kinda design pattern, a very powerful idea to decouple between objects, while AOP enhances cohesion of one object - to let it focus on its primary task. Beside objects, DI could be used to inject methods into object at run-time, which I think is an amazing plus. However, what I think is the most powerful thing about Spring is its flexibility with other existing frameworks - Struts + Spring + Hibernate is currently one of the most popular design patterns for J2EE design, in which Struts serves as the MVC, Spring is the middle layer contributing DI and AOP features and Hibernate is the Model. Spring could be also used as a complete MVC frameworks itself (some think it is now even better than struts). I think to program in Spring with be a pleasant experience.

    By Blogger Eric Zhao, at 7:29 PM  

Post a Comment

<< Home