svn commit: r927217 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r927217 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

adrianc
Author: adrianc
Date: Wed Mar 24 23:01:16 2010
New Revision: 927217

URL: http://svn.apache.org/viewvc?rev=927217&view=rev
Log:
Some improvements to GroovyEngine.java to make Groovy services work more like mini-language and/or screen widgets.

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java?rev=927217&r1=927216&r2=927217&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java Wed Mar 24 23:01:16 2010
@@ -18,13 +18,16 @@
  *******************************************************************************/
 package org.ofbiz.service.engine;
 
+import static org.ofbiz.base.util.UtilGenerics.cast;
+import groovy.lang.Script;
+
 import java.util.Map;
 
+import javolution.util.FastMap;
+
 import org.codehaus.groovy.runtime.InvokerHelper;
-import groovy.lang.Script;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.GroovyUtil;
-import static org.ofbiz.base.util.UtilGenerics.cast;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
@@ -62,7 +65,12 @@ public final class GroovyEngine extends
         if (UtilValidate.isEmpty(modelService.location)) {
             throw new GenericServiceException("Cannot run Groovy service with empty location");
         }
+        Map<String, Object> params = FastMap.newInstance();
+        params.putAll(context);
+        context.put("parameters", params);
         context.put("dctx", dispatcher.getLocalContext(localName));
+        context.put("dispatcher", dispatcher);
+        context.put("delegator", dispatcher.getDelegator());
         try {
             Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService)), GroovyUtil.getBinding(context));
             Object resultObj = null;