What Is Dependency Injection/ Inversion of Control And How Does It Helps In Loose Coupling?

Spring framework contributes in loose coupling with the help of Dependency Injection(DI) or Inversion of Control(IOC). DI allows you to inject objects into a class, rather than relying on the class to create the object itself. So the process of creating an object is inverted.

In a software system, objects collaborate with each other to make the system work. These collaborations are generally in the form of one object depending on another object, in other words, declaring an object with “new” operator in the other class.

The discussed example in this article can be downloaded as eclipse project from here
Continue reading What Is Dependency Injection/ Inversion of Control And How Does It Helps In Loose Coupling?

Spring+Hibernate: How to convert entities to XML/JSON?

Spring makes it remarkably easy to write controllers which return XML or JSON response. Simply add the annotation @ResponseBody to your controller definition and you are done. Whatever you will return from your controller method will be automatically converted to XML or JSON (depending upon “Accept” header of the request). The return type of the controller can be any Object: ranging from maps and beans to collections and arrays.
Continue reading Spring+Hibernate: How to convert entities to XML/JSON?