From: Adam B. <sir...@ya...> - 2001-05-08 18:11:18
|
Well, I've been playing with Jython a bit, and I still don't fully understand it. I'm even sad to say that I find the javadoc sadly lacking. I'm hoping, then, that some more knowledgable person can take pity on me and give me a hand. I'm going to describe what I want to do, in as much detail as I can think of, and I'm hoping someone can explain how to do it. I have a class written in Java with a few methods defined. I want the user of my program to be able to extend this class in Jython by writing a .py file with a known name. Then, when a certain event occurs in my program, I wish to load this class (including reloading it, if it has changed since the last time we used it), instantiate it, and call a method with a known name/signature (that is, one of the methods defined in the parent class). In addition, since there will be multiple python files floating around (that is, the user can define more than one class in python, although they all will extend the same java base class), I want to make sure there are no side effects; that is, I don't want definitions and such to hang around between calls to python classes. How should I even begin to do this? I don't know whether it is better to compile or interpret, in this case, even. Speed is actually a relatively important factor, which is a point for compiling, but only if there's a way to recompile and reload classes without restarting the VM (preferably a prettier way than the usual hack for doing this in java). On the other hand, while interpreting seems easier at first, I can't find a way to enforce the contract that the .py file contain only a class, and nothing else. Also, unless we create a new interpreter each time (which may, I wouldn't be surprised, take longer than just recompiling a class), I don't see a way to guarantee no side effects between calls. Whatever help or advice you can give would be appreciated. The more low-level (pseudocode, example code, whatever) the better. I'm 95% sure that what I'm asking for is possible, and 100% sure it should be possible, so if I find out that it's not, for whatever reason, I do intend to hack Jython until it is. If I end up doing this, I really will need all the detail I can get, before I try to grok the code on my own. Adam Berger __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ |