The screencast below brings up many different approaches of modularity systems in Java. Hmmm. I never even considered anything beyond OSGi.

  • OSGi
  • JSR 277
  • JSR 294
  • NetBeans Modules
  • Maven
  • SMS
  • Jigsaw

Jaroslave Tulach, the guy who wrote the netbeans module system is interviewed here, it's a great discussion.

 

I used to be a really fast java programmer. If you wanted something written quickly, I was your guy. But that was "so last month...".

Certainly not today.

And it's a psychological struggle, because I'm fighting back the shame constantly. It's embarrassing as hell being this slow - even when no-one is watching.

Why so slow?

I'm working on my own software now. This is my nickel. Not billing others for my time, so I can do things right.

Such as but not limited to these "better" practices that I used to largely ignore in the interest of speed.

  • Writing tests for everything I write.
  • Setting up infrastructure first, not a year after I needed it.
  • Never writing a similar project twice, using an archetype template and writing a replication routine etc.
  • Using Spring dependency injection in each appropriate circumstance instead of when it is convenient.
  • Using modularity to organize code into little, discrete, independent jars.
  • Using OSGI to keep all my modules clean.
  • Interfaces instead of concrete classes for calls between projects.
  • Writing a maven generated "site" for each module, that gives a future module developer insight into what's what.
  • etc. etc.

Summary:

"We get it" was the three word version of this presentation. Rod Johnson, the creator of Spring should be proud that the entire focus of JEE and GlassFish teams seems to have been to enthusiastically and shamelessly imitate his every move in recent years. Almost no reference was made to Spring or the driving force behind the latest changes, but it's a credit to the many JSR working groups that they allowed themselves to be so thoroughly influenced by the direction that market moved when Spring supplanted so much of the market that EJBs were intended to serve 10 years ago.

There were over 50 attendees.

To wit - the following technologies were described as "new" that seemed to follow rather than lead, the trends set by market forces years ago.

Compact, Helpful, Well Produced - All in One Place

OSGI isn't just a technology, it's a different way to think, a different kind of design. It can be a real trick to get one's head around. This screencast from SpringSource might help.

Every technology can enable questionable or even destructive uses. What follows is one that OSGI enables.

From that perspective, this screenshot is perfect OSGI anti-pattern. OSGI going to the dark side. (No, it has nothing to do with groovy or the plugin shown)

... from the "Can't We All Just Get Along?" department, you may feel as I do... You want to be lazy where you can, and let these specific Java tools do your work for you. 

And of course, you want it to happen without them fighting each other, and without keeping multiple layers of duplicate metadata synched up in pom.xml, MANIFEST.MF, and gosh knows what other files. In other words, you want DRY.

Sounds great huh? Consider Tycho, if that's your situation. This is Sonatype's work in progress, which neither supports nor fights Spring OSGI, and lets you use the MANIFEST.MF file as your configuration instead of your pom.xml. Even works with p2, if that's you thing.

So I decided to take it for a spin, even though it isn't supposed to be ready yet.

From Gosling (March 17 2010)

James Gosling is quoted in this article in the ServerSide to have described the features of JEE 6 centering around the modularity that comes from the use of OSGI Blueprints.

He's presented as being pretty positive on the whole affair.

 

This started as an offshoot of a previous thread on Why OSGI Will Never Be Popular but then it got me thinking...

The first thing you need, if you're going to do enterprise OSGI, is a starting template for a modular project.

5 minutes, right? We've all done this before. Right click in the IDE > new > project > yada yada

Not So Fast

True, that will do the trick in a non-OSGI world. But then there's all the other stuff like

Where Does OSGI fit into Your Daily Routine?

 
This blog assumes you are already a fan of loose coupling and high cohesion in your coding practices.