From 7db0c07fe272a44ddfdda94b68a535e0e0bcd7b4 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 24 Jun 2003 14:06:53 +0000 Subject: [PATCH] Make classMapping case sensitive, add method for prototype to java class name lookup. Add simple constructor taking just a name argument. --- src/helma/framework/core/Application.java | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index dfa88bb2..d072757c 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -126,7 +126,7 @@ public final class Application implements IPathElement, Runnable { private CryptFile pwfile; // Map of java class names to object prototypes - Properties classMapping; + SystemProperties classMapping; // Map of extensions allowed for public skins Properties skinExtensions; @@ -145,6 +145,13 @@ public final class Application implements IPathElement, Runnable { private Vector cronJobs = null; Hashtable customCronJobs = null; + /** + * Simple constructor for dead application instances. + */ + public Application(String name) { + this.name = name; + } + /** * Build an application with the given name in the app directory. No Server-wide * properties are created or used. @@ -241,6 +248,7 @@ public final class Application implements IPathElement, Runnable { File classMappingFile = new File(appDir, "class.properties"); classMapping = new SystemProperties(classMappingFile.getAbsolutePath()); + classMapping.setIgnoreCase(false); // get class name of root object if defined. Otherwise native Helma objectmodel will be used. rootObjectClass = classMapping.getProperty("root"); @@ -1471,6 +1479,23 @@ public final class Application implements IPathElement, Runnable { return false; } + /** + * Return the java class that a given prototype wraps, or null. + */ + public String getJavaClassForPrototype(String typename) { + + for (Iterator it = classMapping.entrySet().iterator(); it.hasNext();) { + Map.Entry entry = (Map.Entry) it.next(); + + if (typename.equals(entry.getValue())) { + return (String) entry.getKey(); + } + } + + return null; + } + + /** * Return a DbSource object for a given name. A DbSource is a relational database defined * in a db.properties file.