Running Scripted Command in separate namespaces?

keith preston <[email protected]> Wed, 30 Dec 2009 14:36:40 -0600
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
--0016e6d7dfd4857fa9047bf81827
Content-Type: text/plain; charset=ISO-8859-1

I've noticed that all scriptedCommands are executed in the Global
Namespace.   I see two problems with this:

1. Misbehaving scripts can pollute the global namespace if they have
subfunctions or global variable in the scriptedCommand.  This give
rise to the possibility of name collisions.
2. In long running scripts that use lots of scriptedCommands, all of
the compiled form of the scripted commands is kept in memory.   This
can cause a lot of extra memory to be used (possibly running out).

I've actually run into both of these in my use of the Beanshell
engine.   I propose the following patch to beanshell that modifies
scriptedCommands to run in a seperate namespace, which solves both of
these problems.


Keith Preston

--0016e6d7dfd4857fa9047bf81827
Content-Type: text/x-diff; charset=US-ASCII;
	name="namespacedScriptedCommands.patch"
Content-Disposition: attachment; filename="namespacedScriptedCommands.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_g3ukziqr0

SW5kZXg6IHNyYy9ic2gvTmFtZVNwYWNlLmphdmEKPT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gc3JjL2JzaC9OYW1l
U3BhY2UuamF2YQkocmV2aXNpb24gNDIpCisrKyBzcmMvYnNoL05hbWVTcGFjZS5qYXZhCSh3b3Jr
aW5nIGNvcHkpCkBAIC0xMTg2LDkgKzExODYsMTAgQEAKIAkJSW50ZXJwcmV0ZXIgaW50ZXJwcmV0
ZXIgKQogCQl0aHJvd3MgVXRpbEV2YWxFcnJvcgogCXsKKwkJTmFtZVNwYWNlIGNvbW1hbmRuYW1l
c3BhY2UgPSBuZXcgTmFtZVNwYWNlKHRoaXMsICJjb21tYW5kXyIgKyBuYW1lKTsKIAkJdHJ5IHsK
IAkJCWludGVycHJldGVyLmV2YWwoIAotCQkJCW5ldyBJbnB1dFN0cmVhbVJlYWRlcihpbiksIHRo
aXMsIHJlc291cmNlUGF0aCApOworCQkJCW5ldyBJbnB1dFN0cmVhbVJlYWRlcihpbiksIGNvbW1h
bmRuYW1lc3BhY2UsIHJlc291cmNlUGF0aCApOwogCQl9IGNhdGNoICggRXZhbEVycm9yIGUgKSB7
CiAJCS8qIAogCQkJSGVyZSB3ZSBjYXRjaCBhbnkgRXZhbEVycm9yIGZyb20gdGhlIGludGVycHJl
dGVyIGJlY2F1c2Ugd2UgYXJlCkBAIC0xMjAxLDcgKzEyMDIsNyBAQAogCQl9CiAKIAkJLy8gTG9v
ayBmb3IgdGhlIGxvYWRlZCBjb21tYW5kIAotCQlCc2hNZXRob2QgbWV0aCA9IGdldE1ldGhvZCgg
bmFtZSwgYXJnVHlwZXMgKTsKKwkJQnNoTWV0aG9kIG1ldGggPSBjb21tYW5kbmFtZXNwYWNlLmdl
dE1ldGhvZCggbmFtZSwgYXJnVHlwZXMgKTsKIAkJLyoKIAkJaWYgKCBtZXRoID09IG51bGwgKQog
CQkJdGhyb3cgbmV3IFV0aWxFdmFsRXJyb3IoIkxvYWRlZCByZXNvdXJjZTogIiArIHJlc291cmNl
UGF0aCArCg==
--0016e6d7dfd4857fa9047bf81827
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--0016e6d7dfd4857fa9047bf81827
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Beanshell-developers mailing list
Beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/beanshell-developers

--0016e6d7dfd4857fa9047bf81827--