Hello

I am newbie to Clojure. Been using for a couple of months now. With that 
disclaimer out of the way, we have use-cases where we would like multiple 
clojure run times with in the same JVM  and have these run times share 
clojure data structures among themselves. We attempted to solve this 
problem with some help from OSGI (since our use-case was mostly OSGI 
bundles running clojure). This post to share our approach and solicit 
feedback / comments from others.

- OSGI provides individual bundle class loaders for each OSGI bundle. So 
given this running multiple clojure run times inside a single JVM is 
straight forward. However in order to share clojure data structures across 
these run times, several data structure interfaces from clojure.lang (IMap 
etc) must be loaded by a common class loader. However clojure.lang package 
also includes other classes, implementations and not to mention the clojure 
runtime (RT.java) and compiler (Compiler.java)

- Given the fact that clojure uses Thread Context Class Loader (TCCL) to 
load its classes, plus given that OSGI bundles can export packages, we were 
able to create a class loader that loaded all clojure.lang interfaces using 
a common class loader and things like RT / Compiler etc from individual 
bundle class loaders. Thus we have run time isolation with data structure 
sharing.

However we ran into some issues with sharing clojure.lang.IKeywordLookup. 
This interface references "clojure.lang.Keyword". If one were to load 
"clojure.lang.IKeywordLookup" at some point it would also load 
"clojure.lang.Keyword" using the same class loader. "clojure.lang.Keyword" 
is also referenced else where in clojure (clojure.core, other 
implementation classes in clojure.lang). Therefore "clojure.lang.Keyword" 
would be loaded by different class loaders and this causes a java class 
loader linkage error, since while linking say a class A, that uses Keyword 
by itself and IKeywordLookup, JVM does not know which version of Keyword 
class should be used to resolve the class fully.

We worked around it by NOT sharing IKeywordLookup across run times. We can 
still share maps, vectors, lists etc. So this gets us most of what we want. 
However i was wondering if the issue we faced with IKeywordLookup / Keyword 
fixable in some other way. In the absence of a IKeyword interface we could 
not think of any.

Would be happy to hear what others think.
-Giri


-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to