* Try a little harder to find resources in app.addRepository:
If path names don't resolve by themself, try explicitly using hopHome as parent. This is useful in cases where hopHome isn't the current or user directory, such as when running helma within tomcat. * Make app reference transient.
This commit is contained in:
parent
0592e44ad1
commit
585725d9c6
1 changed files with 22 additions and 8 deletions
|
@ -38,7 +38,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
* application specific functionality.
|
* application specific functionality.
|
||||||
*/
|
*/
|
||||||
public class ApplicationBean implements Serializable {
|
public class ApplicationBean implements Serializable {
|
||||||
Application app;
|
transient Application app;
|
||||||
WrappedMap properties = null;
|
WrappedMap properties = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,15 +144,12 @@ public class ApplicationBean implements Serializable {
|
||||||
Repository rep;
|
Repository rep;
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
String path = (String) obj;
|
String path = (String) obj;
|
||||||
File file = new File(path).getAbsoluteFile();
|
File file = findResource(null, path);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file = new File(path + ".zip").getAbsoluteFile();
|
file = findResource(app.hopHome, path);
|
||||||
}
|
}
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file = new File(path + ".js").getAbsoluteFile();
|
throw new RuntimeException("Repository path does not exist: " + file);
|
||||||
}
|
|
||||||
if (!file.exists()) {
|
|
||||||
throw new RuntimeException("Repository path does not exist: " + obj);
|
|
||||||
}
|
}
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
rep = new FileRepository(file, parent);
|
rep = new FileRepository(file, parent);
|
||||||
|
@ -163,7 +160,7 @@ public class ApplicationBean implements Serializable {
|
||||||
rep = new SingleFileRepository(file, parent);
|
rep = new SingleFileRepository(file, parent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unrecognized file type in addRepository: " + obj);
|
throw new RuntimeException("Unsupported file type in addRepository: " + file);
|
||||||
}
|
}
|
||||||
} else if (obj instanceof Repository) {
|
} else if (obj instanceof Repository) {
|
||||||
rep = (Repository) obj;
|
rep = (Repository) obj;
|
||||||
|
@ -178,6 +175,23 @@ public class ApplicationBean implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to resolve a repository path.
|
||||||
|
* @param parent the parent file
|
||||||
|
* @param path the repository path
|
||||||
|
* @return our best guess of what the file may be
|
||||||
|
*/
|
||||||
|
private File findResource(File parent, String path) {
|
||||||
|
File file = new File(parent, path).getAbsoluteFile();
|
||||||
|
if (!file.exists()) {
|
||||||
|
file = new File(parent, path + ".zip").getAbsoluteFile();
|
||||||
|
}
|
||||||
|
if (!file.exists()) {
|
||||||
|
file = new File(parent, path + ".js").getAbsoluteFile();
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the app's classloader
|
* Get the app's classloader
|
||||||
* @return the app's classloader
|
* @return the app's classloader
|
||||||
|
|
Loading…
Add table
Reference in a new issue