Change Application.getRepositories() to return a List instead of an Iterator
This commit is contained in:
parent
514d9a353c
commit
c7d2534811
3 changed files with 17 additions and 14 deletions
|
@ -1636,8 +1636,8 @@ public final class Application implements IPathElement, Runnable {
|
||||||
* Returns the repositories of this application
|
* Returns the repositories of this application
|
||||||
* @return iterator through application repositories
|
* @return iterator through application repositories
|
||||||
*/
|
*/
|
||||||
public Iterator getRepositories() {
|
public List getRepositories() {
|
||||||
return ((List) repositories.clone()).iterator();
|
return Collections.unmodifiableList(repositories);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package helma.framework.core;
|
package helma.framework.core;
|
||||||
|
|
||||||
import helma.objectmodel.db.DbMapping;
|
import helma.objectmodel.db.DbMapping;
|
||||||
import helma.framework.repository.ZipRepository;
|
|
||||||
import helma.framework.repository.Resource;
|
import helma.framework.repository.Resource;
|
||||||
import helma.framework.repository.Repository;
|
import helma.framework.repository.Repository;
|
||||||
import helma.framework.repository.ResourceTracker;
|
import helma.framework.repository.ResourceTracker;
|
||||||
|
@ -47,7 +46,7 @@ public final class TypeManager {
|
||||||
|
|
||||||
private long lastCheck = 0;
|
private long lastCheck = 0;
|
||||||
private long lastCodeUpdate;
|
private long lastCodeUpdate;
|
||||||
private long lastRepositoryScan;
|
private long[] lastRepoScan;
|
||||||
|
|
||||||
// app specific class loader, includes jar files in the app directory
|
// app specific class loader, includes jar files in the app directory
|
||||||
private AppClassLoader loader;
|
private AppClassLoader loader;
|
||||||
|
@ -125,7 +124,7 @@ public final class TypeManager {
|
||||||
checkRepository(list[i]);
|
checkRepository(list[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// its an prototype
|
// it's an prototype
|
||||||
String name = null;
|
String name = null;
|
||||||
name = list[i].getShortName();
|
name = list[i].getShortName();
|
||||||
Prototype proto = getPrototype(name);
|
Prototype proto = getPrototype(name);
|
||||||
|
@ -160,13 +159,17 @@ public final class TypeManager {
|
||||||
* there are any prototypes to be created.
|
* there are any prototypes to be created.
|
||||||
*/
|
*/
|
||||||
private void checkRepositories() throws IOException {
|
private void checkRepositories() throws IOException {
|
||||||
// check if any files have been created/removed since last time we checked...
|
List list = app.getRepositories();
|
||||||
Iterator it = app.getRepositories();
|
// first check if we need to create or adapt our array of last scans
|
||||||
while (it.hasNext()) {
|
if (lastRepoScan == null || lastRepoScan.length != list.size()) {
|
||||||
Repository repository = (Repository) it.next();
|
lastRepoScan = new long[list.size()];
|
||||||
if (repository.lastModified() > lastRepositoryScan) {
|
}
|
||||||
lastRepositoryScan = Math.max(System.currentTimeMillis(),
|
|
||||||
repository.lastModified());
|
// 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);
|
checkRepository(repository);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ public final class ResourceProperties extends Properties {
|
||||||
/* next we try to load properties from the application's
|
/* next we try to load properties from the application's
|
||||||
repositories, if we blong to any application */
|
repositories, if we blong to any application */
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
Iterator iterator = app.getRepositories();
|
Iterator iterator = app.getRepositories().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
try {
|
try {
|
||||||
Repository repository = (Repository) iterator.next();
|
Repository repository = (Repository) iterator.next();
|
||||||
|
@ -267,7 +267,7 @@ public final class ResourceProperties extends Properties {
|
||||||
long checksum = 0;
|
long checksum = 0;
|
||||||
|
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
Iterator iterator = app.getRepositories();
|
Iterator iterator = app.getRepositories().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
try {
|
try {
|
||||||
Repository repository = (Repository) iterator.next();
|
Repository repository = (Repository) iterator.next();
|
||||||
|
|
Loading…
Add table
Reference in a new issue