diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 93d4f798..9acff1d3 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -1636,8 +1636,8 @@ public final class Application implements IPathElement, Runnable { * Returns the repositories of this application * @return iterator through application repositories */ - public Iterator getRepositories() { - return ((List) repositories.clone()).iterator(); + public List getRepositories() { + return Collections.unmodifiableList(repositories); } /** diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index 415cadc5..b1b3b8ce 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -17,7 +17,6 @@ package helma.framework.core; import helma.objectmodel.db.DbMapping; -import helma.framework.repository.ZipRepository; import helma.framework.repository.Resource; import helma.framework.repository.Repository; import helma.framework.repository.ResourceTracker; @@ -47,7 +46,7 @@ public final class TypeManager { private long lastCheck = 0; private long lastCodeUpdate; - private long lastRepositoryScan; + private long[] lastRepoScan; // app specific class loader, includes jar files in the app directory private AppClassLoader loader; @@ -125,7 +124,7 @@ public final class TypeManager { checkRepository(list[i]); } } else { - // its an prototype + // it's an prototype String name = null; name = list[i].getShortName(); Prototype proto = getPrototype(name); @@ -160,13 +159,17 @@ public final class TypeManager { * there are any prototypes to be created. */ private void checkRepositories() throws IOException { - // check if any files have been created/removed since last time we checked... - Iterator it = app.getRepositories(); - while (it.hasNext()) { - Repository repository = (Repository) it.next(); - if (repository.lastModified() > lastRepositoryScan) { - lastRepositoryScan = Math.max(System.currentTimeMillis(), - repository.lastModified()); + List list = app.getRepositories(); + // first check if we need to create or adapt our array of last scans + if (lastRepoScan == null || lastRepoScan.length != list.size()) { + lastRepoScan = new long[list.size()]; + } + + // walk through repositories and check if any of them have changed. + for (int i = 0; i < lastRepoScan.length; i++) { + Repository repository = (Repository) list.get(i); + if (repository.lastModified() != lastRepoScan[i]) { + lastRepoScan[i] = repository.lastModified(); checkRepository(repository); } diff --git a/src/helma/util/ResourceProperties.java b/src/helma/util/ResourceProperties.java index 6dab2bc5..964f81cd 100644 --- a/src/helma/util/ResourceProperties.java +++ b/src/helma/util/ResourceProperties.java @@ -160,7 +160,7 @@ public final class ResourceProperties extends Properties { /* next we try to load properties from the application's repositories, if we blong to any application */ if (app != null) { - Iterator iterator = app.getRepositories(); + Iterator iterator = app.getRepositories().iterator(); while (iterator.hasNext()) { try { Repository repository = (Repository) iterator.next(); @@ -267,7 +267,7 @@ public final class ResourceProperties extends Properties { long checksum = 0; if (app != null) { - Iterator iterator = app.getRepositories(); + Iterator iterator = app.getRepositories().iterator(); while (iterator.hasNext()) { try { Repository repository = (Repository) iterator.next();