Links

About

Inversion of Control

Mentawai has a complete and powerful Inversion of Control (IoC) container fully integrated with the framework. Therefore to use the best IoC and Dependency Injection (DI) practices you need not use any other framework. Mentawai supports injection by setter and constructor, smart auto-wiring and more. Let's see how easy this is:

NOTE: The IoC, DI and Auto-wiring capabilities of Mentawai were extracted in a separate project called MentaContainer, which remains seamlessly integrated with the framework.

Setting up IoC:

@Override
public void setupIoC() {
ioc(UserDAO.class, JdbcUserDAO.class); // for my UserDAO interface, I want to use the JdbcUserDAO implementation
}

Performing DI:

Now that you have indicated the implementation (JdbcUserDAO) you want to use in your web application, the dependency injection will happen automatically and seamlessly. You need not worry about anything. For example:

Mentawai will automatically detect this dependency and wire the objects together, in other words, it will pass the BeanSession implementation you specified (MySQLBeanSession) to the JdbcUserDAO's constructor, without you having to do anything.

TIP: Inversion of Control also makes it easier to test your objects with unit or functional testing.