Counterclockwise, the Eclipse plugin for Clojure is written in mixed Java and Clojure. It uses Clojure.osgi 1.2.10.
So this is living proof of the concept that it is possible. And AFAIK, counterclockwise has been used successfully by hundreds of people.
There are some limitations, tho: Clojure namespace is "global" for some "root class loader". EG. if you pack Clojure inside a package named, say, myapp.clojure, then you will likely have many other packages that require myapp.clojure. Say for example myapp.bundle1, myapp.bundle2. When you do this, and from each package load (require) the package namespaces into memory, each of them will be loaded from the required ClassLoader class (the namespaces myapp.bundle1 will be loaded into the class class container myapp.bundle1 and the namespaces myapp.bundle2 will be loaded into the context class loader myapp.bundle2). This is great because it allows java interaction to work fine.
But just remember that at the end, the namespace downloaded from bundle1 and bundle2 will be held by the "global namespace" in the myapp.clojure package.
Honestly, this has not yet proven a problem for Counterclockwise. Since inside the same function, when packages have one single instance of Clojure, almost everything is fine.
Potential disadvantages:
- if you use third-party libraries, for example. tools.logging, you cannot have a namespace in myapp.bundle1, it depends on the X version of tools.logging, and at the same time myapp.bundle2 depends on the version Y of tools.logging. That is, inside your function, where you have a common Clojure through the myapp.clojure package, you work as if the OSGi rules were not applied, for example, the operation of web applications.
- doesn't scale well if massively applied: if each Eclipse function had to repack its own version of Clojure, there would be some memory loss. But this flaw is more theoretical than practical. And this is a problem that can be solved later, when it becomes necessary.
Please note that for the RCP Eclipse product, unlike the Eclipse plugin, these shortcomings disappear.
If you want to see how Counterclockwise repackaged Clojure and uses Clojure.osgi, you can see its source code:
http://github.com/laurentpetit/ccw.clojure.git http://github.com/laurentpetit/ccw.git
NTN
- Laurent
Laurent petit
source share