From: Cabler, A. <Ada...@me...> - 2009-11-24 19:18:36
|
I am doing something similar, except I am using the classpath to locate my module where you are pointing to a stream. Here is the code I'm using to replace the __tojava__ call: ScriptEngine engine = new ScriptEngineManager() .getEngineByName("python"); //call import or whatever here Class o = (Class) engine.get(name); Object ni = o.getConstructors()[0].newInstance(null); MyFcn u = (MyFcn) ni; //MyFcn is an interface implemented by the python class -----Original Message----- From: Anamitra Bhattacharyya [mailto:ana...@ya...] Sent: Tuesday, November 24, 2009 7:48 AM To: jyt...@li... Subject: [Jython-users] jsr223 and jython Hi I am trying to figure out if there is a jsr223 way to use this jyhton feature where I can use jython to extend a java class. I am looking at the Invocable interface in jsr223 and I am not sure if that has all the features to pull this. Below is the code snippet [jython specific] that I use today to do this: public Object loadScriptAsJAVAObject(Class objectClass, InputStream script, String scriptClassName, Object[] args) { PySystemState sys = Py.getSystemState(); if(sys==null) { sys = new PySystemState(); } sys.setClassLoader(getClass().getClassLoader()); PythonInterpreter interpreter = new PythonInterpreter(null, sys); interpreter.execfile(script); PyObject scriptClass = interpreter.get(scriptClassName); PyObject scriptObject = scriptClass._jcall(args); return scriptObject.__tojava__(objectClass); } I am not sure how to model this using jsr223. Any pointers is appreciated. thanks Anamitra ------------------------------------------------------------------------ ------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |