diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index e99b0d13..51320c87 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -23,14 +23,20 @@ public final class TypeManager { HashMap prototypes; HashMap zipfiles; long lastCheck = 0; - // boolean rewire; + long appDirMod = 0; + // the hopobject prototype + Prototype hopobjectProto; + // the global prototype + Prototype globalProto; + final static String[] standardTypes = {"user", "global", "root", "hopobject"}; + final static String templateExtension = ".hsp"; final static String scriptExtension = ".js"; final static String actionExtension = ".hac"; final static String skinExtension = ".skin"; - + public TypeManager (Application app) { this.app = app; appDir = app.appDir; @@ -38,7 +44,7 @@ public final class TypeManager { if (appDir.list().length == 0) { for (int i=0; i appDirMod) { + appDirMod = appDir.lastModified (); + String[] list = appDir.list (); + if (list == null) + throw new RuntimeException ("Can't read app directory "+appDir+" - check permissions"); + for (int i=0; i -1) + continue; + Prototype proto = getPrototype (list[i]); + // if prototype doesn't exist, create it + if (proto == null && isValidTypeName (list[i])) { + File f = new File (appDir, list[i]); + if (f.isDirectory ()) { + // create new prototype + proto = new Prototype (list[i], app); + registerPrototype (list[i], f, proto); } } } } - // loop through prototypes and check if type.properties needs updates - // it's important that we do this _after_ potentially new prototypes - // have been created in the previous loop. - for (Iterator i=prototypes.values().iterator(); i.hasNext(); ) { - Prototype proto = (Prototype) i.next (); - // update prototype's type mapping - DbMapping dbmap = proto.getDbMapping (); - if (dbmap != null && dbmap.needsUpdate ()) { - dbmap.update (); - // set parent prototype, in case it has changed. - String parentName = dbmap.getExtends (); - if (parentName != null) - proto.setParentPrototype (getPrototype (parentName)); - else - proto.setParentPrototype (null); - } - } - // loop through zip files to check for updates for (Iterator it=zipfiles.values ().iterator (); it.hasNext (); ) { ZippedAppFile zipped = (ZippedAppFile) it.next (); @@ -139,6 +137,26 @@ public final class TypeManager { } } + // loop through prototypes and check if type.properties needs updates + // it's important that we do this _after_ potentially new prototypes + // have been created in the previous loop. + for (Iterator i=prototypes.values().iterator(); i.hasNext(); ) { + Prototype proto = (Prototype) i.next (); + // update prototype's type mapping + DbMapping dbmap = proto.getDbMapping (); + if (dbmap != null && dbmap.needsUpdate ()) { + dbmap.update (); + if (proto != hopobjectProto && proto != globalProto) { + // set parent prototype, in case it has changed. + String parentName = dbmap.getExtends (); + if (parentName != null) + proto.setParentPrototype (getPrototype (parentName)); + else if (!app.isJavaPrototype (proto.getName())) + proto.setParentPrototype (hopobjectProto); + } + } + } + } @@ -237,7 +255,7 @@ public final class TypeManager { } } - // next we check if files have been created since last update + // next we check if files have been created or removed since last update if (proto.getLastCheck() < dir.lastModified ()) { String[] list = dir.list(); for (int i=0; i