There is rarely need to embed a runtime/framework into the OSGi container itself. All that is needed is to refactor the Clojure runtime to let OSGi do the class/resource loading. The goal would be to get a central Clojure bundle and deploy application code into separate bundles. For statically compiled code this is not a very hard conversion. You just call Bundle.loadClass() on the application bundle to get OSGi do the heavy lifting for you. Clojure however compiles code at runtime. Currently the OSGi class load sequence does not have a slot for pluggable compilers. If it did than the bundle ClassLoader would call out to the clojure compiler giving it a chance to convert resources found in the bundle into byte codes. Since such support is not available the next best thing is to compile the clojure code *before* it is reaches OSGi. This technique is not yet widely used but I expect it do become ever more popular. The clojure runtime must register a "clojure:" URL handler with the OSGi continer. It can than intercept bundles installed from locations like "clojure:http:// acme.com/device.jar". The clojure runtime will compile the source code found inside and literally generate an OSGi bundle on the fly. Magic! :)
I am not sure if the clojure runtime can hotswap individual functions. In case it can this OSGi conversion will increase the granularity of dynamic deployment/hotswap from a function to a bundle. The REPL itself can also be deployed as a bundle. It can even plug into one of the generic text console manager bundles. The Felix TUI bundle for example. In summary - I am relatively confident Clojure can be converted into a set of bundles that run against the generic OSGi API. If this will be useful is a different question :) On Oct 5, 10:54 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > It's possible to modify Clojure to run under OSGi (search the list > archives) but fundamentally they don't fit. OSGi assumes that it has > sole control of class loading. But Clojure needs its own > classloader. To make them cooperate, I think you would need to > integrate Clojure with the OSGi container itself. > > -SS > > On Oct 5, 9:54 am, Todor Boev <rinsvind.r...@gmail.com> wrote: > > > Hi, > > I am an OSGi enthusiast. Lately I have been looking at scheme and > > clojure. I can't help but wonder if there are any genuine benefits > > clojure can get from being a full OSGi citizen. It seems to me that > > OSGi is to statically compiled Java what the REPL is for Clojure. > > Except the REPL is more powerful. Currently OSGi seems like a nice > > interoperation environment for clojure and the other JVM based > > languages. This alone is a sufficient motivation to make clojure OSGi > > compatible, which it currently is not because it's internal class > > loading does not play nice with OSGi's own dynamic class loading. > > > The devilish question however is: if all our code was in clojure would > > running withing OSGi bring any genuine benefits? Does OSGi as a > > dynamic runtime for the JVM provide anything that the REPL does not > > already have? > > > Cheers, > > Todor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---