Yes, there are times that I am jealous of the apparent simplicity of php driven sites. Take for instance Drupal, I really like all the functionality it has. I know there has been a ton of work and support to get Drupal where it is today, but the thing that makes me really jealous is there plugin framework. Anyone can write a plugin and distribute it to other Drupal users. This just seems so simple. And if you look at other php systems like Joomla, they all have similar plugin/module frameworks. So where is the java equivilant?
Now from a technical aspect, I understand why it is easier to write a plugin system in php. Since php is a scripting language, everything happens at runtime, there is no pre-compile stage. With java, everything has to be compiled first before deploying it. So in java, it is a little harder to add things at runtime that have not been pre-compiled with the rest of your app. There are definitely ways around this, it just is a big nightmare to handle all the different configuration settings to make it work.
I’ve looked at a few existing java projects that use plugins, Hudson, Magnolia and OpenCMS. All of them work, I just haven’t fully immersed myself enough to completely understand how each of the different systems work. With java, unlike php, you will sooner or later have to address dependency management and how to organize all the different versions of jars that get thrown into your app. This goes back to handling all configuration of all your different plugins.
So finally, to my wish list. What I would love to have is a basic framework that accepts different plugins that will ultimately build an app. An easy example is for a simple website. I would want one module for the admin section, one module for blogs, one module for message boards, one module for commets. I think you get the picture. Everything is modular, this way you can just stack together your modules to create the functionality of your site.
In my research, OSGi almost looks like what I am looking for. I say almost, because one of the requirements I have is to make it easy to use within a servlet container. With OSGi, your servlet container is actually a module itself. To me, this just adds another layer into the stack. And I most developers already know how to use a servlet container, so I don’t want to make them learn how to use OSGi.
Now to my wishlist of what I want the plugin framework to do:
1. Be able to assign a plugin to act like a servlet filter
This functionality is used to do things before or after a web request. You could use this to intercept incoming request parameters and do something with it, like set a cookie based on the refering source of the request.
2. Be able to register new url actions
I want to be able to add new pages to the site. So I would need to add all the actions associated with view a blog for instance. This would include both the page logic and the view layer (images, templates, etc).
3. Be able to assign plugins to a specific lifecycle phase
This is just like “hooks” in php. Say I want certain logic to fire every time I save something or run some special code when the page is rendered.
So there you have it. Sounds simple right? Well, hopefully I can find something that will meet my needs, otherwise I may have to start writing my own.