Add all jython directories found in class path to jython interpreter's path
package metadata.etl;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
+import java.util.Enumeration;
import java.util.Properties;
import org.python.core.PyDictionary;
import org.python.core.PyString;
@@ -50,7 +52,17 @@ public abstract class EtlJob extends BaseJob {
}
private void addJythonToPath(PySystemState pySystemState) {
- URL url = classLoader.getResource("jython");
+ Enumeration<URL> urls;
+ try {
+ urls = classLoader.getResources("jython/");
+ } catch (IOException e) {
+ logger.info("Failed to get resource: {}", e.getMessage());
+ return;
+ }
+
+ while (urls.hasMoreElements()) {
+ URL url = urls.nextElement();
+ logger.debug("jython url: {}", url.getPath());
if (url != null) {
File file = new File(url.getFile());
String path = file.getPath();
@@ -60,6 +72,7 @@ public abstract class EtlJob extends BaseJob {
pySystemState.path.append(new PyString(path.replace("!", "")));
}
}
+ }
/**
* Copy all properties into jython environment
