I cannot seem to get the syntax quite right for this: I have a Jython script and a Java application loaded into the same JVM (for testing).
I need to access a particular part of the application through a Singleton class from the Jython script. How do I do this?
Thanks
EDIT:
The set up is for automated testing, so assume that the Jython script already has access to the classes/classpath of the Java application.
Let's say my Java application has a singleton class some.pkg.MySingleton
.. how do I invoke MySingleton.getInstance() from开发者_StackOverflow中文版 my Jython script?Didn't this work?
from some.pkg import MySingleton
myInstance = MySingleton.getInstance()
If that doesn't work, try this: (I'm not sure if this works)
mySingletonClass = MySingleton(MySingleton)
myInstance = mySingletonClass.getInstance()
精彩评论