Monday, July 12, 2004

IoC Containers

Last week I was working on a .NET application needing a very pluggable architecture. To ensure extensibility, the application was factored into components. It is obvious that most components required some basic services like lifecycle management, configuration, contextualization and composition. Thus began my search for an IoC (Inversion of Control) container in .NET. Martin Fowler explains it very well.

There has been considerable interest in light-weight containers in the Java world for providing these services wich has resulted in projects like Avalon/Merlin, Spring and PicoContainer. Of course, their heavier counterparts, J2EE application servers are only too well-known. These containers differ from the application servers in many respects. One is, they just provide a microkernel for managing the components. The application servers provide a much larger set of services to the EJBs including security, transactions, connection pooling, message queues and schedulers. There are almost no restrictions on the components being managed by the container and no hard contracts to fulfill.

While application servers provide their services to the contained EJBs using descriptors, these containers explicitly handover the service providing component to the user component. There is a difference in the lookup pattern also. While the J2EE containers use the ServiceLocator pattern (JNDI) to find other components, these containers use some variation of IoC or dependency injection - Constructor injection(PicoContainer), Setter injection(Spring) or Interface injection(Avalon).

These containers also provide features which are not part of the J2EE framework. For example, Spring provides a framework for aspect-oriented programming. Avalon provides components on the avalon planet for thread pool, scheduler and datasources thus allowing the use of different implementations of these services. If you are working on the J2EE platform, HiveMind is a good bet. It is an IoC container that can be deployed on a J2EE application server. Thus you have access to a simple container with the full power of J2EE.

As for my search, I found that PicoContainer.NET is the only option at the moment. Spring.NET is in planning stages. Avalon is also being ported as Castle but has not been released.

1 Comments:

Blogger Kapil Jain said...

hi,

One Good link for Comparing Spring and HiveMind is
http://howardlewisship.com/blog/2004/06/hivemind-vs-spring-philosophy.html

Kapil

3:17 AM  

Post a Comment

<< Home