* Make TypeManager.createPrototypes() and TypeManager.checkPrototypes() throw IOException

* Propagate IOException in the callers of the above methods
This commit is contained in:
hns 2005-03-23 12:32:50 +00:00
parent e5514d7099
commit 11257b4765
5 changed files with 16 additions and 18 deletions

View file

@ -277,7 +277,11 @@ public final class Application implements IPathElement, Runnable {
// create and init type mananger
typemgr = new TypeManager(this);
typemgr.createPrototypes();
try {
typemgr.createPrototypes();
} catch (Exception x) {
logError("Error creating prototypes", x);
}
// set the context classloader. Note that this must be done before
// using the logging framework so that a new LogFactory gets created

View file

@ -94,14 +94,14 @@ public final class TypeManager {
* Run through application's prototype directories and create prototypes, but don't
* compile or evaluate any scripts.
*/
public void createPrototypes() {
public void createPrototypes() throws IOException {
// create standard prototypes.
for (int i = 0; i < standardTypes.length; i++) {
createPrototype(standardTypes[i], null);
}
// loop through directories and create prototypes
checkFiles();
checkRepositories();
}
/**
@ -109,14 +109,12 @@ public final class TypeManager {
* has been updated.
* If so, update prototypes and scripts.
*/
public synchronized void checkPrototypes() {
public synchronized void checkPrototypes() throws IOException {
if ((System.currentTimeMillis() - lastCheck) < 1000L) {
return;
}
try {
checkFiles();
} catch (Exception ignore) {}
checkRepositories();
lastCheck = System.currentTimeMillis();
}
@ -162,17 +160,13 @@ public final class TypeManager {
* Run through application's prototype sources and check if
* there are any prototypes to be created.
*/
private void checkFiles() {
private void checkRepositories() throws IOException {
// check if any files have been created/removed since last time we checked...
for (int i = 0; i < repositories.length; i++) {
try {
if (repositories[i].lastModified() > modified[i]) {
modified[i] = repositories[i].lastModified();
if (repositories[i].lastModified() > modified[i]) {
modified[i] = repositories[i].lastModified();
checkRepository(repositories[i]);
}
} catch (IOException iox) {
iox.printStackTrace();
checkRepository(repositories[i]);
}
}

View file

@ -61,7 +61,7 @@ public interface ScriptingEngine {
* evaluation is entered to let the Engine know it should update
* its prototype information
*/
public void updatePrototypes();
public void updatePrototypes() throws IOException, ScriptingException;
/**
* This method is called when an execution context for a request

View file

@ -310,7 +310,7 @@ public final class RhinoCore implements ScopeProvider {
* here is to check for update those prototypes which already have been compiled
* before. Others will be updated/compiled on demand.
*/
public synchronized void updatePrototypes() {
public synchronized void updatePrototypes() throws IOException {
if ((System.currentTimeMillis() - lastUpdate) < 1000L) {
return;
}

View file

@ -149,7 +149,7 @@ public class RhinoEngine implements ScriptingEngine {
* This method is called before an execution context is entered to let the
* engine know it should update its prototype information.
*/
public void updatePrototypes() {
public void updatePrototypes() throws IOException {
context = Context.enter();
context.setCompileFunctionsWithDynamicScope(true);
context.setApplicationClassLoader(app.getClassLoader());