jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@opensource.lk
Subject [PATCH] fixed .. unable to declare a bean after any evaluation of a javascript
Date Fri, 18 Jun 2004 09:20:27 GMT
please accept this patch for above problem


--- OrigJavaScriptEngine.java	2004-06-15 08:25:06.000000000 +0600
+++ JavaScriptEngine.java	2004-06-18 14:56:57.000000000 +0600
@@ -142,16 +142,23 @@
     }

     public void declareBean(BSFDeclaredBean bean) throws BSFException {
-        if ((bean.bean instanceof Number) ||
-            (bean.bean instanceof String) ||
-            (bean.bean instanceof Boolean)) {
-            global.put(bean.name, global, bean.bean);
-        }
-        else {
-            // Must wrap non-scriptable objects before presenting to Rhino
-            Scriptable wrapped = Context.toObject(bean.bean, global);
-            global.put(bean.name, global, wrapped);
-        }
+	Context cx;
+	try{
+		if ((bean.bean instanceof Number) ||
+	            (bean.bean instanceof String) ||
+	            (bean.bean instanceof Boolean)) {
+	            global.put(bean.name, global, bean.bean);
+	        }
+	        else {
+	            // Must wrap non-scriptable objects before presenting to Rhino
+	            Scriptable wrapped = Context.toObject(bean.bean, global);
+	            global.put(bean.name, global, wrapped);
+	        }
+	}finally
+	{
+		Context.exit();
+	}
+
     }

     /**

---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org


Mime
View raw message