diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 70f41238..fb73d582 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -46,17 +46,20 @@ public final class Application implements IPathElement, Runnable { // the name of this application private String name; + // application sources + ArrayList repositories; + // properties and db-properties ResourceProperties props; // properties and db-properties ResourceProperties dbProps; - // Helma server home directory - File home; + // This application's main directory + File appDir; - // application sources - ArrayList repositories; + // Helma server hopHome directory + File hopHome; // embedded db directory File dbDir; @@ -138,7 +141,7 @@ public final class Application implements IPathElement, Runnable { private CryptResource pwfile; // Map of java class names to object prototypes - ResourceProperties classMapping; + ResourceProperties classMapping; // Map of extensions allowed for public skins Properties skinExtensions; @@ -211,10 +214,10 @@ public final class Application implements IPathElement, Runnable { ResourceProperties sysDbProps; sysProps = sysDbProps = null; - home = null; + hopHome = null; if (server != null) { - home = server.getHopHome(); + hopHome = server.getHopHome(); if (dbDir == null) { dbDir = new File(server.getDbHome(), name); @@ -229,6 +232,13 @@ public final class Application implements IPathElement, Runnable { dbDir.mkdirs(); } + for (int i=0; i -1) { + repositories.add(idx, rep); + return true; + } + } + // no parent or parent not in app's repositories. + repositories.add(rep); + return true; + } + return false; + } + /** * Searches for the index of the given repository for this app. * The arguement must be a root argument, or -1 will be returned. @@ -1586,14 +1635,14 @@ public final class Application implements IPathElement, Runnable { * @return iterator through application repositories */ public Iterator getRepositories() { - return repositories.iterator(); + return ((List) repositories.clone()).iterator(); } /** * Return the directory of the Helma server */ public File getServerDir() { - return home; + return hopHome; } /** diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index bc10748b..11ace149 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -39,8 +39,6 @@ public final class TypeManager { final static String skinExtension = ".skin"; private Application app; - Repository[] repositories; - long[] modified; // map of prototypes private HashMap prototypes; @@ -49,6 +47,7 @@ public final class TypeManager { private long lastCheck = 0; private long lastCodeUpdate; + private long lastRepositoryScan; // app specific class loader, includes jar files in the app directory private AppClassLoader loader; @@ -62,9 +61,6 @@ public final class TypeManager { */ public TypeManager(Application app) { this.app = app; - repositories = new Repository[app.repositories.size()]; - app.repositories.toArray(repositories); - modified = new long[repositories.length]; prototypes = new HashMap(); jarfiles = new HashSet(); @@ -124,7 +120,10 @@ public final class TypeManager { for (int i = 0; i < list.length; i++) { if (list[i].isScriptRoot()) { // this is an embedded top-level script repository - checkRepository(list[i]); + if (app.addRepository(list[i])) { + // repository is new, check it + checkRepository(list[i]); + } } else { // its an prototype String name = null; @@ -162,11 +161,14 @@ public final class TypeManager { */ 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++) { - if (repositories[i].lastModified() > modified[i]) { - modified[i] = repositories[i].lastModified(); + Iterator it = app.getRepositories(); + while (it.hasNext()) { + Repository repository = (Repository) it.next(); + if (repository.lastModified() > lastRepositoryScan) { + lastRepositoryScan = Math.max(System.currentTimeMillis(), + repository.lastModified()); - checkRepository(repositories[i]); + checkRepository(repository); } }