Laurent, Thanks for the pointers. This is helpful and reinforces what I was wondering to do (repackage clojure or use serialization) I'll evaluate the different approaches
Thanks, Rama On Monday, July 1, 2013 10:00:07 AM UTC-7, Laurent PETIT wrote: > > 2013/7/1 Rama Shenai <rsh...@climate.com <javascript:>>: > > Hi, > > > > I have an OSGI (Karaf) setup where I have two isolated instances of > Clojure > > deployed & running in two bundles (within the same JVM), > > and I am seeing a problem where passing Clojure Objects (such as > > PersistentArrayMaps) from one clojure bundle to another, breaks clojure > > interfaces > > at the receiving end. The two bundles communicate via a OSGI services. > > > > The specific problem/example is as follows: > > > > Lets say that I have two Clojure bundle instances running in Apache > Karaf > > (clj-bundle-A) and (clj-bundle-B) > > > > clj-bundle-A registers an interface implementation with the OSGI > registry. > > The interface looks like: > > public interface clojureCall { > > Object callMethod(Object request); > > } > > > > clj-bundle-B looks up the interface from the OSGI registry and calls the > > method, the code looks like this: > > (defn call-bundle-a [] > > ; service is an instance of clojureCall implemented in clj-bundle-a > > (let [service (lookup-osgi-registry-bundle-a)] > > ; send a map as a request > > (.callMethod service {"hello" "world"}))) > > > > > > An instance of the PersistentHashMap {"hello" "world"} is sent from > > clj-bundle-B to clj-bundle-A; > > However, clj-bundle-A only sees it as a Java object with its clojure > > interfaces not realized. > > > > For example on clj-bundle-A, the passed in argument looks like > >> (println request) > > #<PersistentArrayMap {"hello" "world"} <== I would expect it to print > > {"hello" "map"} instead it is realizing this as a Java object. > > > >> (println (type request)) > > clojure.lang.PersistentHashMap <== The type information is saved, but > the > > interface is broken > > > >> (map? request) > > false > > > >> (instance? java.util.Map request) <== the java interfaces are realized > >> correctly > > true > > > > I figure that the problem may be related to the two Clojure-Bundles are > not > > sharing any classes between them, since they are running in different > > isolated bundles. > > I want to have to multiple instances of clojures running so as to run > > multiple versions of the sample clj file in the same JVM > > > > I am wondering if anyone has any suggestions on how to avoid this > problem. > > Hello, > > indeed, you have 2 clojure instances in 2 separate classloader > environments. So they share nothing, even if you might think so, > misguided by the fact that the fully qualified class names look > identical. > > An interesting solution would be to refactor Clojure to extract all > the interfaces into a third bundle, then make each clojure instance > depend on that bundle made only of interfaces. This way, you would be > able to share objects via their interfaces. > > Or else, at the boundaries, you'll have to serialize / deserialize the > objects to / from edn, even within the same JVM. > > HTH, > > -- > Laurent > > > > > Thanks, > > Rama > > > > -- > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clo...@googlegroups.com<javascript:> > > Note that posts from new members are moderated - please be patient with > your > > first post. > > To unsubscribe from this group, send email to > > clojure+u...@googlegroups.com <javascript:> > > 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+u...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- -- 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.