Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
58 naveen 1
/**
2
 * 
3
 */
4
package in.shop2020.util;
5
 
6
import org.python.util.PythonInterpreter;
7
 
8
/**
70 naveen 9
 * Wrapper around work done by Jython scripts
10
 * 
58 naveen 11
 * @author naveen
12
 *
13
 */
14
public class JythonWrapper {
15
 
16
	/**
63 naveen 17
	 * Private Python interpreter instance
58 naveen 18
	 */
70 naveen 19
	protected PythonInterpreter py = null;
20
 
58 naveen 21
 
22
	/**
70 naveen 23
	 * Initialises PythonInterpreter instance 
58 naveen 24
	 */
63 naveen 25
	public void initialize() {
26
		if(this.py == null) {
27
			this.py = new PythonInterpreter();
28
		}
29
	}
30
 
31
	/**
70 naveen 32
	 * Resets current PythonInterpreter instance
63 naveen 33
	 */
70 naveen 34
	public void reset() {
35
		this.py = null;
63 naveen 36
	}
37
 
38
	/**
58 naveen 39
	 * Executes Jython script given absolute path
40
	 * 
41
	 * @param filename
42
	 */
43
	public void exec(String filename) {
70 naveen 44
		this.initialize();
58 naveen 45
 
46
		this.py.execfile(filename);
47
	}
48
}