On 12 Feb., 05:33, [EMAIL PROTECTED] wrote:
>
> My question is: is it possible to (efficiently) serialize my session
> scope such that no values in the global scope are serialized with the
> session? This would work like ScriptableOutputStream except that it
> would always choose to stub values that are present in the global
> scope, instead of just when they have been added as excluded names. If
> I am not mistaken, this means that I need to be able to work backwards
> from an arbitrary Scriptable reference to a fully qualified name with
> respect to the global scope. Can this be done? Any suggestions are
> appreciated.

Yes, this is possible. I think it's simpler to exclude the global
scope as a whole instead of each of its properties. In Helma, we have
an interface called SerializationProxy [1], and one class implementing
it is GlobalProxy which is a placeholder for the global scope. All you
have to do then is subclass  ScriptableOutputStream and
ScriptableInputStream. In ScriptableOutputStream, override
replaceObject(Object obj) to replace your global scope with a proxy
object, and in ScriptableInputStream, override resolveObject(Object
obj) to replace the proxy object back to the current global scope. For
an example, look at the serialize()/deserialize() methods in our
RhinoEngine class [2].

[1] 
http://dev.helma.org/trac/helma/browser/helma/helma/trunk/src/helma/scripting/rhino/SerializationProxy.java
[2] 
http://dev.helma.org/trac/helma/browser/helma/helma/trunk/src/helma/scripting/rhino/RhinoEngine.java

Of course, it is easiest to do this if you use a special class for the
global scope (such as ImporterTopLevel or a custom subclass), but I
think it shouldn't be striclty necessary.

hannes

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to