The Java Service Provider spec and sun.misc.Service

fop java tools

Looking for a lightweight plugin mechanism for microsling, I found the jar service provider spec to be good enough.

But wait...although the spec dates back from JDK 1.3, there's no implementation in the JDK before 1.6? And what's the mysterious Service class in the spec's example?

Actually there are some implementations, well hidden in obscure JDK packages. Jackrabbit for example uses javax.imageio.spi.ServiceRegistry, which looks completely out of place in that package but is otherwise well specified. And apparently it is safe to use javax packages in any VM.

For now, the final word of this story is Sun's bug 4640520 - looks like sun.misc.Service should have moved to the JDK public API long ago, but for some reason it didn't.

Thanks to the sling-dev and advanced-java folks for their help in putting this info together. Sounds like a trivial problem, and it should be, but I bet many people have lost hours on this already.

Update: Jeremias indicates that the xmlgraphics commons include such a Service class - Batik and FOP have been using that for years.