|
From: Bill W. <wp...@gm...> - 2005-12-08 16:44:32
|
---------- Forwarded message ---------- From: Helio R. Zwi <hz...@co...> Date: Dec 8, 2005 10:38 AM Subject: Re: [Jython-users] Getting Java interface information from a Java class in Jython To: Bill Woodward <wp...@gm...> Use <object name>.__class__.__bases__ (or <any_class_name>.__bases__) It is the list of superclasses for the given class. If the given class is a Java class (no multiple inheritance allowed), one of the elements is the actual superclass (always __bases__[0], as far as I can tell), and the remaining (if any), the superinterfaces. You can use it "recursively", e.g.: >>> java.lang.StringBuffer.__bases__[0] <jclass java.lang.AbstractStringBuilder at 25822411> >>> java.lang.StringBuffer.__bases__[0].__bases__[0] <jclass java.lang.Object at 13059400> >>> java.lang.StringBuffer.__bases__[1] <jclass java.io.Serializable at 25392329> >>> java.lang.StringBuffer.__bases__[2] <jclass java.lang.CharSequence at 5791657> >>> Helio Bill Woodward wrote: >Good morning, > >I'm using Jython 2.2a1 to do some client-side testing of a J2EE >application on a somewhat more obscure J2EE application server. In >Jython, I am able to obtain an object from JNDI and call methods on it >in Jython, very nicely, thank you very much. However, when I try to >turn that Jython code into some server-side Java code, I'm running >into a problem. In Jython, I can look at the class (using "<object >name>.__class__"), as well as getting method and variable information >about the class (using "dir(<object name>.__class__)"), but the actual >Java class that is listed is an 'Impl' class. > >In order to use this object in Java, I need to know what interface to >cast it to. The application server is not well documented in this >area, and I'm having trouble finding out what the Java interface is. >Is there any way in Jython to obtain the interface(s) that class >implements? Or should I use the Java reflection classes to get it? > >TIA, >- Bill > >-- >Bill Woodward wp...@sa... http://www.saifa.net > >"I have more trouble with D. L. Moody than with any other man I ever >met." -- D. L. Moody > s/D. L. Moody/Bill Woodward/g > > >------------------------------------------------------- >This SF.net email is sponsored by: Splunk Inc. Do you grep through log fil= es >for problems? Stop! Download the new AJAX search engine that makes >searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick >_______________________________________________ >Jython-users mailing list >Jyt...@li... >https://lists.sourceforge.net/lists/listinfo/jython-users > > > -- Bill Woodward wp...@sa... http://www.saifa.net "I have more trouble with D. L. Moody than with any other man I ever met." -- D. L. Moody s/D. L. Moody/Bill Woodward/g |