Oleg’s Weblog

My Tech Rant

Archive for December, 2008

OSGi and “uses” directive

Posted by Oleg Zhurakousky on December 9, 2008

In current Java model, uniqueness of the class is defined by fully qualified name of the class plus the defining class loader. This mechanism actually creates a problem, where it is quite easy to have multiple versions of the same class loaded in a single JVM space. This happens quite a lot, giving Java’s ability to load classes dynamically. Modern framework such as Spring, Hibernate and others utilize this feature quite a bit. However if not used properly, having multiple instances of class loaded often results in memory leaks and various class type exceptions such as CCE, NCDF, Linkage etc. . .

OSGi approaches this problem rather differently and it does so by bringing the concept of class/packages version into the runtime environment, thus allowing you to still have multiple versions of the same class loaded without creating conflicts.  But it comes with the price. OSGi defines a very strict visibility and class sharing rules that must be explicitly declared, while at the same time moving us a way from the legacy mentality of the linear class path we are all so used to.

The following article article concentrates on one area of OSGi dependency resolution mechanism and that is “uses” directive. . .


Posted in osgi | Tagged: | Leave a Comment »

To Spring or not to Spring. . .

Posted by Oleg Zhurakousky on December 8, 2008

Just another rant on the whole JEE vs. Spring and specifications in general . . .
Here is how I see it:
JEE(J2EE) is a specification which addresses some areas of concerns derived from the concepts of Enterprise Java.
Spring is an open source framework which also addresses some areas of concerns derived from the concepts of Enterprise Java.
One is managed by a large group of people and vendors, each with their own egos and potentially contradicting agendas, while the other one is managed by a smaller like-minded group of people with two common interests and that is to “make it better then other guy” and “make it quicker then other guy”.

So the real sticking point here is the speed and quality of innovation. In the privately managed framework such as Spring a good idea could be turned into concrete implementation in days (some times hours), while it takes years to accomplish anything in any managed specification (not only JEE). Take Hibernate’s capabilities of today vs. its derived specification such as JPA for example. Or take capabilities of Spring vs. various JEE implementations? You can clearly see how far behind JEE really is.
One might argue that specification gives you portability across platforms. . . well not true!
JEE, although meant to be portable, never has been. JEE application on JBoss is not portable to another platform such as WAS unless you spend some time making it portable. I spent two years of my career migrating apps from WAS and WebLogic to JBoss and it was anything but trivial due to all kinds of proprietary extensions and APIs on either platforms which resulted in a typical vendor lock-in.
Spring on the other hand, is giving you the same functionality as JEE plus much more, but in the detached non-JEE container called Application Context, while providing basic integration of Application Context with standard JEE services (e.g., JTA, DataSources, Messaging etc…), thus making your Spring based application completely portable across all JEE containers (You don’t have WAS version of Spring vs. the same of BEA). Yes that raises another question; If Spring can do all of what JEE does, why do I need JEE in the first place? Well, you don’t. . ., but that is a different discussion 🙂

Going back to the question of portability and innovation; If I can’t achieve portability and innovation, what is the value in following any specification? The way I see it I will always be behind the “other guy”.
Spring and other privately managed frameworks (open source and not) are evolving into conventions that developers understand and feel comfortable with.  And good conventions are just as good if not better then any specification. . .

Posted in Spring | Tagged: , , | Leave a Comment »