Fork me on GitHub
Subscribe to RSS Feed

Neil Bartlett

Using EMF in OSGi

It's official -- I ♥ "EMF":! This is a surprise to me. I previously regarded modelling in general and EMF specifically as a sort of cult... obscure jargon, terrible documentation, unbearably aloof and patronising "talk abstracts": but all that's behind me now. I see the light: it's all about the industrialisation of software, which requires both _componentisation_ and _automation_. OSGi provides admirably for the first, and perhaps EMF can provide for the second. However I wouldn't say I'm an _entirely_ orthodox EMFite. I've had to hack it about a bit, primarily to get it to work properly OSGi. At first blush using EMF in OSGi may seem trivial, after all, Eclipse is an OSGi application and EMF is designed to work in Eclipse, so EMF must work well in OSGi. Also: all cats have four legs; my dog has four legs; therefore my dog is a cat. Ahem. !>/images/posts/emfosgi/semiskimmed.jpg! EMF supports running in two distinct environments, neither of which matches my requirements. The first is in a "full-fat" Eclipse SDK or Eclipse RCP application. The second is in a traditional non-OSGi Java runtime, which the EMF docs refer to as "standalone". However the middle ground -- an OSGi environment that is not Eclipse -- is not supported. That is, you cannot drop EMF into a lightweight OSGi runtime, even allowing for a few dependencies. It depends on the following eight bundles as an absolute minimum: * org.eclipse.core.runtime * org.eclipse.equinox.common * * org.eclipse.equinox.registry * org.eclipse.equinox.preferences * org.eclipse.core.contenttype * * org.eclipse.osgi The last one is the killer: Equinox itself, meaning that EMF will run only on Equinox, not any other OSGi framework implementation such as Apache Felix or Knopflerfish. There's something fishy going on, though. How can EMF run in a "standalone" non-OSGi environment -- with _no_ other JARs on the classpath -- but not run in Felix?? !