Python Rocks! and other rants 26.8.2004
Weblog of Kent S Johnson


Jython and Spring Framework

I am trying out Spring Framework in a current project and I like it. I especially like the support for Hibernate transactions. The only reservation I have is that Spring won't work with Jython classes.

I have made a start at implementing Jython support. I have classes that allow a Jython bean to be instantiated from the IoC framework. Setting properties on the beans is awkward, the bean has to implement an interface that defines the setter methods. But it's a start!

One of the limitations of Jython is that it doesn't play very well with Java introspection. If you want your Jython methods to be visible to Java introspection you have two choices:

  • compile your scripts with jythonc
  • implement a Java interface containing the methods of interest

The first option is problematic (I have had too much trouble with jythonc). To work with Spring setter injection, the second requires that every setter is declared in an interface; not really practical. Since the Spring Inversion of Control framework is built on top of an introspection engine, this is a problem for using it with Jython :-( Rod Johnson (Spring author) says this may be fixable in the framework.

You can learn more from this thread on the Spring support forum:

posted at 20:32:00    #    comment []    trackback []
August 2004
2 3 4 5 6 7 8

Comments about life, the universe and Python, from the imagination of Kent S Johnson.

XML-Image Letterimage


© 2004, Kent Johnson