Scripted Java objects now have a prototype that only has the
href() and renderSkin() functions, without all the other functions in Helma objectmodel Nodes that don't apply to Java objects. This was a problem because it "covered" methods in the Java objects with the same name, e.g. list(), delete() etc.
This commit is contained in:
parent
f3ea5d79a2
commit
c56befd4d4
2 changed files with 39 additions and 50 deletions
|
@ -455,14 +455,6 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
|||
nmgr.clearCache ();
|
||||
}
|
||||
|
||||
/**
|
||||
* redundant method for clearCache() in order to be able to clear cache from
|
||||
* self-scripting base app - would otherwise interfere with ESNode.clearCache().
|
||||
*/
|
||||
public void clearAppCache () {
|
||||
nmgr.clearCache ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application's root element to an arbitrary object. After this is called
|
||||
* with a non-null object, the helma node manager will be bypassed. This function
|
||||
|
@ -699,7 +691,6 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
|||
|
||||
if (rootproto != null && rootproto.equals (getPrototypeName (p)))
|
||||
break;
|
||||
|
||||
b.insert (0, divider);
|
||||
|
||||
// users always have a canonical URL like /users/username
|
||||
|
@ -708,9 +699,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
|||
p = users;
|
||||
break;
|
||||
}
|
||||
|
||||
b.insert (0, URLEncoder.encode (getElementName (p)));
|
||||
|
||||
p = getParentElement (p);
|
||||
|
||||
if (loopWatch++ > 20)
|
||||
|
@ -1005,10 +994,13 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
|||
Prototype proto = (Prototype) typemgr.prototypes.get (typename);
|
||||
if (proto != null) {
|
||||
String protoname = m.getExtends ();
|
||||
if (protoname == null)
|
||||
// only use hopobject prototype if we're scripting HopObjects, not
|
||||
// java objects.
|
||||
boolean isjava = isJavaPrototype (typename);
|
||||
if (protoname == null && !isjava)
|
||||
protoname = "hopobject";
|
||||
Prototype parentProto = (Prototype) typemgr.prototypes.get (protoname);
|
||||
if (parentProto == null)
|
||||
if (parentProto == null && !isjava)
|
||||
parentProto = (Prototype) typemgr.prototypes.get ("hopobject");
|
||||
if (parentProto != null)
|
||||
proto.setParentPrototype (parentProto);
|
||||
|
@ -1020,6 +1012,18 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a prototype is for scripting a java class, i.e. if there's an entry
|
||||
* for it in the class.properties file.
|
||||
*/
|
||||
protected boolean isJavaPrototype (String typename) {
|
||||
for (Enumeration en = classMapping.elements(); en.hasMoreElements(); ) {
|
||||
String value = (String) en.nextElement ();
|
||||
if (typename.equals (value))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DbSource object for a given name. A DbSource is a relational database defined
|
||||
|
|
|
@ -33,16 +33,16 @@ public class Prototype {
|
|||
|
||||
Prototype parent;
|
||||
|
||||
// Tells us whether this prototype is used to script a generic Java object,
|
||||
// as opposed to a Helma objectmodel node object.
|
||||
boolean isJavaPrototype;
|
||||
|
||||
public Prototype (String name, Application app) {
|
||||
|
||||
// app.logEvent ("Constructing Prototype "+app.getName()+"/"+name);
|
||||
|
||||
this.app = app;
|
||||
this.name = name;
|
||||
|
||||
isJavaPrototype = app.isJavaPrototype (name);
|
||||
lastUpdate = 0; // System.currentTimeMillis ();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,24 +52,6 @@ public class Prototype {
|
|||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an action defined for this prototype
|
||||
*/
|
||||
public Action getActionOrTemplate (String aname) {
|
||||
|
||||
Action retval = null;
|
||||
if (aname == null || "".equals (aname))
|
||||
aname = "main";
|
||||
retval = (Action) actions.get (aname);
|
||||
// check if it's allowed to access templates via URL
|
||||
// this should be cached in the future
|
||||
if (retval == null && "true".equalsIgnoreCase (app.props.getProperty ("exposetemplates")))
|
||||
retval = (Action) templates.get (aname);
|
||||
// if still not found, check if the action is defined for the generic node prototype
|
||||
if (retval == null && parent != null)
|
||||
retval = parent.getActionOrTemplate (aname);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent prototype of this prototype, i.e. the prototype this one inherits from.
|
||||
|
@ -167,6 +149,9 @@ public class Prototype {
|
|||
}
|
||||
}
|
||||
if (!"global".equalsIgnoreCase (name) && !"hopobject".equalsIgnoreCase (name) && opp == null) {
|
||||
if (isJavaPrototype)
|
||||
opp = reval.esObjectPrototype;
|
||||
else
|
||||
opp = reval.esNodePrototype;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue