I was poking around with this sort of stuff a while ago
so I could write ant tasks in jython.

As far as I can tell, there is no easy way to make
a jython class look like a java bean. In general, jython
is great at making java classes look like python classes,
but jython classes don't look like java classes.

If someone knows a trick for doing this (other than
jythonc), I'd love to know it.

Maybe some
unholy combination of java.lang.reflect.Proxy and
java.util.BeanInfo be used to proxy through
to a jython class and adapt it to meet the javabeans
spec? Except that a Proxy must implement
some predefined interfaces...

-----Original Message-----
From: Nick Collier [mailto:nick.collier@verizon.net]
Sent: Wednesday, June 26, 2002 12:11 PM
To: jython-users@lists.sourceforge.net
Subject: [Jython-users] reflection / property question


Some background. I'm working with the repast simulation framework for
creating agent based simulations. Typically you write your model in
java, "load" it into repast and off it goes. Repast identifies and
displays a models starting parameters by calling getInitParam on the
model which returns a list of property names. (These are standard bean
like properties where the presence of a get / set accesor method
identifies a property. So, getVal and/or setVal "defines" the val
property.) Repast takes this list of property names uses reflection to
go find the appropriate methods in the model. So a property name of
"val" makes repast look for a getVal and a setVal.

What I'd like to be able to do is to write the models in jython.
Everything seems to work fine as far as subclassing the repast base
models with my jython code. However, although repast does call the
appropriate method and receive the list of property names, it can't find
the get/set accessor methods in my jython model. Short of compiling the
jython into java and using the "@sig" comments, is there any way to get
this kind of bean property reflection working on the jython side.



Nick Collier
Social Science Research Computing
University of Chicago

This sf.net email is sponsored by:ThinkGeek
No, I will not fix your computer.
Jython-users mailing list