Update of /cvsroot/plexus/plexus-components/python-factory/src/main/org/apache/plexus/service/repository/factory/python
In directory eng.werken.com:/tmp/cvs-serv2443
Modified Files:
PythonServiceFactory.java
Log Message:
o Adding config param for the cachedir
o We are using one python system state per factory and one interpreter per
component retrieval. Still working out the details as I need to look inside
the belly of Jython.
Index: PythonServiceFactory.java
===================================================================
RCS file: /cvsroot/plexus/plexus-components/python-factory/src/main/org/apache/plexus/service/repository/factory/python/PythonServiceFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- PythonServiceFactory.java 24 Apr 2003 00:12:45 -0000 1.1.1.1
+++ PythonServiceFactory.java 24 Apr 2003 01:22:39 -0000 1.2
@@ -27,15 +27,20 @@
{
/** */
private String componentScript = "org/apache/plexus/service/repository/factory/python/conf.py";
-
/** */
private String pythonHome;
-
/** */
private String pythonPath;
-
+ /** */
+ private String pythonCachedir;
/** */
private ClassLoader classLoader;
+ /** */
+ //private PythonInterpreter interp;
+ /** */
+ private PySystemState pythonSystemState;
+ /** */
+ private Properties pythonSystemStateProperties;
// ----------------------------------------------------------------------
// Lifecylce Management
@@ -55,16 +60,26 @@
{
pythonHome = configuration.getChild( "python-home" ).getValue();
pythonPath = configuration.getChild( "python-path" ).getValue();
+ pythonCachedir = configuration.getChild( "python-cachedir" ).getValue();
}
public void initialize()
throws Exception
{
- Properties p = new Properties();
- p.setProperty( "python.home", pythonHome );
- p.setProperty( "python.path", pythonPath );
+ pythonSystemStateProperties = new Properties();
+ pythonSystemStateProperties.setProperty( "python.home", pythonHome );
+ pythonSystemStateProperties.setProperty( "python.path", pythonPath );
+ pythonSystemStateProperties.setProperty( "python.cachedir", pythonCachedir );
- PySystemState.initialize( p, p, null, classLoader );
+ // This is just the way jython is, don't look at me. You cannot
+ // create an instance of the system state without initializing first.
+ PySystemState.initialize();
+
+ pythonSystemState = new PySystemState();
+ pythonSystemState.initialize( pythonSystemStateProperties, null, null );
+ pythonSystemState.setClassLoader( classLoader );
+
+ Py.setSystemState( pythonSystemState );
}
public Object newInstance( String name, ClassLoader classLoader )
@@ -74,8 +89,7 @@
try
{
- PythonInterpreter interp = new PythonInterpreter();
- Py.getSystemState().setClassLoader( classLoader );
+ PythonInterpreter interp = new PythonInterpreter( null, pythonSystemState );
// Execute the component script.
InputStream is = classLoader.getResourceAsStream( componentScript );
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.