Login Form






Lost Password?

Statistics

OS: Linux s
PHP: 5.1.2
MySQL: 5.0.26-Max
Time: 16:18
Caching: Enabled
GZIP: Enabled
Members: 5
News: 67
WebLinks: 8
Visitors: 57144
Home arrow Mamblog
Blog entries written by Erik Brakkee
Battle of the IOC containers
Written by Erik Brakkee

Looking back

A lot has happened in the last 5 years in the Java EE world. Developing EJB 2 applications was really hard and as a result a lot of opensource projects appeared addressing these problems. In particular, Spring and Hibernate had a lot of influence. 

Spring initially had a clear philosophy of using dependency injection/inversion of control instead of using lookups and singletons (the (in)famous JNDI in EJB2), and of separating the platform from the implementation of the functionality. I.e. no longer tying business functionality to platform interfaces such as SessionBean and EntityBean.

Hibernate on the other hand solved a lot of problems with entity beans, allowing a more object-oriented style of development supporting persistence of (almost) arbitrary structures of objects. Together, Spring and Hibernate identified a lot of pain points in EJB 2 and greatly improved testability and productivity in Java EE. 

Current state 

Now, Java EE standardisation has incorporated many ideas like using dependency injection and Java Persistence API, the latter of which is basically the standardized Hibernate and Toplink API. 

Unfortunately, it remains to be seen whether the situation has now really improved. In particular, Spring has become sort of a one-stop-shop for applications and has become a big utility library. In practice, many companies are now really tied to the Spring framework since they use it almost everywhere for everything.

In the Java EE standard there is now EJB 3 which adds dependency injection through some annotations and (optional) XML configuration. Nevertheless, this is also not such a big improvement. In particular, testability of session beans in a standalone environment (one of the main triggers for what happened in the last 5 years) is problematic. Also, from a maintenance point of view, it is difficult to get a grasp of a given EJB 3 application because it requires looking through a lot of different source files to see how the application is tied together. Spring in this regard is more explicit but this quickly leads to a big XML configuration that is also difficult to understand.  

Taking a step back, Spring and EJB 3 are trying to solve the same problem of programming to interfaces. In other words, at a particular place in the software I want to use an interface without knowing the implementation and the framework somehow injects the implementation where the interface is expected. This is a generic problem that is also being attacked by other IOC containers like pico container and Guice. 

Some of these frameworks have big marketing engines behind them, such as google's guice, and as a result that framework is also gaining some popularity. Admittedly, Guice and picocontainer are a lot simpler than Spring and a lot more focused in the problems they solve. The unfortunate thing is that these frameworks all work well with a singleton type of approach where, for a given interface, there is precisely one implementation. 

Trends, component based development

In parallel, however, it looks like OSGI is gaining a lot of popularity. In particular, there is now a spring source application server based on it, Jonas uses an OSGI kernel, Glassfish v3 will be based on OSGI, IBM Websphere 6.1 uses OSGI, BEA is also using OSGI for some of its products and is investigating integration in its application server, and JBoss is also going in that direction. Not to mention of course Eclipse which is built on Equinox, an OSGI R4 implementation. 

I like the component idea. Basically, a component provides a number of interfaces an requires a number of interfaces. Then in a given running system, the provided and required interfaces must be linked together to form an application.  A component in this case might be realised through various objects. For example if a component provides two interfaces, then these interfaces can be provided by two distinct objects that are part of the component. As a special degenerate case, supported by existing IOC containers, this corresponds to a single object that implements both interfaces.

Of course, OSGI also allows different versions of the same component to be deployed at a given time in a system. This concept provides a lot more flexibility than an all Guice or all Spring application. In particular, subsystems can be realised as Guice or Spring applications but exposed at a higher level through OSGI bundles or components. In this way, a big monolitic approach where an application has to be all Spring or all Guice can be avoided and this reopens the possibility of traditional software architecture where a system is decomposed into smaller subsystems.

My guess is that an approach like this will eliminate the need for frameworks such as Spring and Guice alltogether since hand-wiring a few objects together in a few lines of code is easy. In my view, frameworks such as Spring and Guice only help if you are creating a big monolithic application.

Experiments

For this reason, I am currently experimenting with a small IOC container of my own that implements this component concept. Frameworks such as Spring, Guice, and picocontainer do not offer this component concept since they focus on objects and not on components.

At this point I am already using this component concept in my own projects to avoid a Spring nightmare where loads of XML files are loaded in one big application context. As a result, I can now more easily reuse existing Spring configurations as components that are connected to each other through interfaces and not through application contexts. One application of it is testing persistence out of the container which has now become very easy. The next step is diving deep into OSGI and providing an integration of this component concept with OSGI. 

 


View/Add Comments (1)

Move from JBoss to Glassfish
Written by Erik Brakkee

Over the last weeks I have been preparing for the move from JBoss to Glassfish application server. The reason for this was to have full Java EE 5 capability instead of having to depend on a patched JBoss 4 server. 

This migration has caused me a few problems though. I started with the most difficult application where I did a lot of work on security with JBoss. This was an application where I integrated J2EE declarative security with JAAS and tapestry. A lot of work. 

The application used authentication to a database so looking for support in glassfish, I found the JDBC realm. Unfortunately, that was a bit restrictive because it placed all kinds of restrictions on the data model. So the first thing I had to do was to write a new flexible JDBC realm that could be configured with the same flexibility as that in JBoss. Of course, that didn't work out of the box and I encountered an error. Finally, however, I managed to work around this problem. See this thread for details.

After this problem, it was relatively easy to move over all the other applications. One final issue I encountered was the automatic restart of glassfish at a server reboot. Here, SUN recommends a non-standard approach by editing /etc/inittab directly. This is cumbersome since that file is managed by yast2 on SuSE so I added a init.d script for glassfish instead. This fits much better in the way that services work on SuSE. 

Now everything is running on glassfish and jboss has been shutdown. Migration successful!


View/Add Comments (3)

Humanity is doomed...
Written by Erik Brakkee

Ok, so after years of investigation, it seems that the greenhouse effect is real. There is real climate change and this requires a joint effort of all the nations in the world to limit its effects. If it continues, large parts of the world will be flooded and many people will die because of hunger and disease. 

But, nonetheless, what is happening? Well, as a result of the greenhouse effect, the North pole will become ice free before 2050 and the north pole has huge amounts of resources such as oil. So, instead of figuring out what to do about the greenhouse effect, nations are fighting over the north pole. So far, the United States, Canada, Danmark, and Russia are laying claims on the north pole. 

So who wants to bet? Will the earth's nations work together to come up with solutions to the worlds problems or will humanity just self-destruct in a pointless war about the north pole?  (whose resources are also finite).

 

 


View/Add Comments (2)



More...
new car...
rm -rf Joomla
System-Idle Optimization

Show all blog entries

Show archived blog entries by this user

© 2009 Nonsense and other useful things...
Joomla! is Free Software released under the GNU/GPL License.