IOC and Dependency Injection – Struts Tutorial

IOC / Dependency injection:-

Dependency lookup:-

In this process resource spends rimes to search & gather its dependent values from other resource of the application. In this process the resource pulls the values from other resources.

Example: –   The way JDBC data source object is gathered from registry software through JNDI comes under dependency lookup.

Example: –   If student gets its course material from institute staff only by asking / demanding for it comes under dependency lookup.

Dependency injection:-

  • If the underlying s/w or framework or container or server or special resource of the application is assigning values to our resource dynamically or automatically then that process is called as “Dependency Injection”.
  • In this process the underlying s/w processes values to the resource.

Real life example: – The way institute staff person assigns material to students immediately after is registration for course comes under dependency injection.

Technical example: – The way ActionServlet writes form data of form page to form bean class object dynamically comes under dependency injection.

MVC2 in Struts:-

  • This design pattern allows the programmer to develop the web application by having multiple layers & clean separation of logics.
  • Struts application also contains multiple layers like view controller & model and also allows clean separation of logics.

Leave a Reply

Your email address will not be published. Required fields are marked *