From b98f8b67512245aa7b0966966f51ec53a11e9e4a Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 25 Jun 2003 15:13:46 +0000 Subject: [PATCH] Internally replace '.' with '_' in action names. Implement proxy method for Application.getSkin() that takes care of per-request caching. --- src/helma/scripting/rhino/RhinoEngine.java | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index 9f656f0e..796956d1 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -262,7 +262,7 @@ public final class RhinoEngine implements ScriptingEngine { } } - Object f = ScriptableObject.getProperty(eso, functionName); + Object f = ScriptableObject.getProperty(eso, functionName.replace('.', '_')); if ((f == ScriptableObject.NOT_FOUND) || !(f instanceof Function)) { return null; @@ -343,7 +343,7 @@ public final class RhinoEngine implements ScriptingEngine { */ public boolean hasFunction(Object obj, String fname) { // System.err.println ("HAS_FUNC: "+fname); - return core.hasFunction(app.getPrototypeName(obj), fname); + return core.hasFunction(app.getPrototypeName(obj), fname.replace('.', '_')); } /** @@ -444,4 +444,26 @@ public final class RhinoEngine implements ScriptingEngine { public RhinoCore getCore() { return core; } + + /** + * Get a skin for the given prototype and skin name. This method considers the + * skinpath set in the current response object and does per-response skin + * caching. + */ + public Skin getSkin(String protoName, String skinName) { + SkinKey key = new SkinKey(protoName, skinName); + + Skin skin = reval.res.getCachedSkin(key); + + if (skin == null) { + // retrieve res.skinpath, an array of objects that tell us where to look for skins + // (strings for directory names and INodes for internal, db-stored skinsets) + Object[] skinpath = reval.res.getSkinpath(); + core.unwrapSkinpath(skinpath); + skin = app.getSkin(protoName, skinName, skinpath); + reval.res.cacheSkin(key, skin); + } + return skin; + } + }