You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2009/05/28 18:11:51 UTC

svn commit: r779639 - in /ofbiz/trunk: framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml

Author: adrianc
Date: Thu May 28 16:11:50 2009
New Revision: 779639

URL: http://svn.apache.org/viewvc?rev=779639&view=rev
Log:
Fixed a problem with BsfEventHandler.java not recognizing the "component://" location syntax. Reported by Marco Risaliti - https://issues.apache.org/jira/browse/OFBIZ-2539.

I also fixed a couple other problems with the class.

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java?rev=779639&r1=779638&r2=779639&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java Thu May 28 16:11:50 2009
@@ -22,6 +22,8 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
+import java.net.URL;
+
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -29,6 +31,7 @@
 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
 import org.apache.bsf.util.IOUtils;
+import org.ofbiz.base.location.FlexibleLocation;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.webapp.control.ConfigXMLReader;
@@ -81,15 +84,19 @@
                 cacheName = event.invoke;
                 scriptString = eventCache.get(cacheName);
                 if (scriptString == null) {
-                    synchronized(this) {
+                    synchronized(eventCache) {
                         if (scriptString == null) {
-                            Debug.logInfo("Loading BSF Script from classpath at location: " + event.invoke, module);
-                            scriptStream = cl.getResourceAsStream(event.invoke);
-                            if (scriptStream == null) {
-                                throw new EventHandlerException("Could not find BSF script file at classpath location: " + event.invoke);
+                            if (Debug.verboseOn()) {
+                                Debug.logVerbose("Loading BSF Script at location: " + cacheName, module);
                             }
-                            scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream));
-                            eventCache.put(cacheName, scriptString);
+                            URL scriptUrl = FlexibleLocation.resolveLocation(cacheName);
+							if (scriptUrl == null) {
+								throw new EventHandlerException("BSF script not found at location [" + cacheName + "]");
+							}
+                            scriptStream = scriptUrl.openStream();
+							scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream));
+                            scriptStream.close();
+							eventCache.put(cacheName, scriptString);
                         }
                     }
                 }
@@ -98,13 +105,14 @@
                 cacheName = context.getServletContextName() + ":" + event.path + event.invoke;
                 scriptString = eventCache.get(cacheName);
                 if (scriptString == null) {
-                    synchronized(this) {
+                    synchronized(eventCache) {
                         if (scriptString == null) {
                             scriptStream = context.getResourceAsStream(event.path + event.invoke);
                             if (scriptStream == null) {
                                 throw new EventHandlerException("Could not find BSF script file in webapp context: " + event.path + event.invoke);
                             }
                             scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream));
+                            scriptStream.close();
                             eventCache.put(cacheName, scriptString);
                         }
                     }

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=779639&r1=779638&r2=779639&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Thu May 28 16:11:50 2009
@@ -419,7 +419,7 @@
 
     <request-map uri="processPaymentSettings">
        <security https="true" auth="false"/>
-       <event type="bsf" invoke="org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
+       <event type="bsf" invoke="component://ecommerce/script/org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
        <response name="success" type="request" value="reviewOrder"/>
        <response name="error" type="view" value="paymentinformation"/>
    </request-map>
@@ -505,7 +505,7 @@
 
     <request-map uri="quickAnonAddCreditCardToCart">
        <security https="true" auth="false"/>
-       <event type="bsf" invoke="org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
+       <event type="bsf" invoke="component://ecommerce/script/org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
        <response name="success" type="view" value="quickAnonCcInfo"/>
        <response name="error" type="view" value="quickAnonCcInfo"/>
    </request-map>
@@ -519,21 +519,21 @@
 
    <request-map uri="quickAnonAddEftAccountToCart">
        <security https="true" auth="false"/>
-       <event type="bsf" invoke="org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
+       <event type="bsf" invoke="component://ecommerce/script/org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
        <response name="success" type="view" value="quickAnonEftInfo"/>
        <response name="error" type="view" value="quickAnonEftInfo"/>
    </request-map>
 
    <request-map uri="quickAnonEnterExtOffline">
         <security https="true" auth="false"/>
-        <event type="bsf" invoke="org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
+        <event type="bsf" invoke="component://ecommerce/script/org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
         <response name="success" type="view" value="quickAnonOrderReview"/>
         <response name="error" type="view" value="quickAnonOrderReview"/>
    </request-map>
 
    <request-map uri="quickAnonAddGiftCardToCart">
        <security https="true" auth="false"/>
-       <event type="bsf" invoke="org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
+       <event type="bsf" invoke="component://ecommerce/script/org/ofbiz/ecommerce/order/ProcessPaymentSettings.groovy"/>
        <response name="success" type="request" value="quickAnonGcInfo"/>
        <response name="error" type="view" value="quickAnonGcInfo"/>
    </request-map>