Do not use the currently evaluated code repository as parent/root repository for repositories added via app.addRepository(). I don't know why I did this in the first place, but it messes up code evaluation order because multiple repositories end up with the same root repository.

This commit is contained in:
hns 2008-10-15 10:29:18 +00:00
parent 3e1df369bf
commit fc8ce41184
3 changed files with 3 additions and 32 deletions

View file

@ -1735,28 +1735,6 @@ public final class Application implements Runnable {
return Collections.unmodifiableList(repositories); return Collections.unmodifiableList(repositories);
} }
/**
* Set the code resource currently being evaluated/compiled. This is used
* to set the proper parent repository when a new repository is added
* via app.addRepository().
*
* @param resource the resource being currently evaluated/compiled
*/
public void setCurrentCodeResource(Resource resource) {
currentCodeResource = resource;
}
/**
* Set the code resource currently being evaluated/compiled. This is used
* to set the proper parent repository when a new repository is added
* via app.addRepository().
* @return the resource being currently evaluated/compiled
*/
public Resource getCurrentCodeResource() {
return currentCodeResource;
}
/** /**
* Return the directory of the Helma server * Return the directory of the Helma server
*/ */

View file

@ -138,9 +138,6 @@ public class ApplicationBean implements Serializable {
* @param obj the repository, relative or absolute path to the library. * @param obj the repository, relative or absolute path to the library.
*/ */
public synchronized void addRepository(Object obj) { public synchronized void addRepository(Object obj) {
Resource current = app.getCurrentCodeResource();
Repository parent = current == null ?
null : current.getRepository().getRootRepository();
Repository rep; Repository rep;
if (obj instanceof String) { if (obj instanceof String) {
String path = (String) obj; String path = (String) obj;
@ -152,12 +149,12 @@ public class ApplicationBean implements Serializable {
throw new RuntimeException("Repository path does not exist: " + file); throw new RuntimeException("Repository path does not exist: " + file);
} }
if (file.isDirectory()) { if (file.isDirectory()) {
rep = new FileRepository(file, parent); rep = new FileRepository(file);
} else if (file.isFile()) { } else if (file.isFile()) {
if (file.getName().endsWith(".zip")) { if (file.getName().endsWith(".zip")) {
rep = new ZipRepository(file, parent); rep = new ZipRepository(file);
} else { } else {
rep = new SingleFileRepository(file, parent); rep = new SingleFileRepository(file);
} }
} else { } else {
throw new RuntimeException("Unsupported file type in addRepository: " + file); throw new RuntimeException("Unsupported file type in addRepository: " + file);

View file

@ -799,9 +799,6 @@ public final class RhinoCore implements ScopeProvider {
String sourceName = code.getName(); String sourceName = code.getName();
Reader reader = null; Reader reader = null;
Resource previousCurrentResource = app.getCurrentCodeResource();
app.setCurrentCodeResource(code);
String encoding = app.getProperty("sourceCharset"); String encoding = app.getProperty("sourceCharset");
try { try {
@ -837,7 +834,6 @@ public final class RhinoCore implements ScopeProvider {
wrappercache.clear(); wrappercache.clear();
} }
} finally { } finally {
app.setCurrentCodeResource(previousCurrentResource);
if (reader != null) { if (reader != null) {
try { try {
reader.close(); reader.close();