[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] BSF, Groovy, class/OSGi resolution

Yes that was my experience...  had to add all those methods to BundleClassloaderAdapter in Groovy Monkey for that reason.  Works great though.


On Fri, Oct 17, 2008 at 7:34 AM, Craig Phillips <lcphillips@xxxxxxxxxxxxx> wrote:
Update to a former post (of which I deleted) on the same subject -- I did manage to get bsf/groovy working in an OSGi container and do class resolution...  I was on the right track, thanks to and appreciate of support from J. Ervin as well as postings around the net -- to write and plug in a custom class loader...
My problem was that I did not implement all the methods and method signature variants... I blame that on Sun because: Classloader should be an interface, not something you extend;
When using BSF/groovy in an OSGi container, you want to write a custom class loader (be sure to implement findClass() as well as loadClass() -- bsf uses loadClass() while groovy uses findClass() -- go figure) that will search through the registered bundles in the OSGi container for a class, noting that Bundle has a method called loadClass() [what, no findClass() ??? LOL];
Anyway, you register your custom class loader to bsf and groovy a la:  BsfManager.setClassLoader()...
BTW - be sure to consult the context class loader as well -- useful for core classes as well as when junit testing....
Lastly, I did not implement getResource() and variations thereof -- Bundle does not, IIRC, have anything equivalent [and, I think that makes sense]...
For what it's worth, Craig Phillips, Praxis

equinox-dev mailing list

James E. Ervin, IV

A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.
-Robert A. Heinlein

Blog: http://iacobus.blogspot.com