Author: jonesde
Date: Thu Jul 26 05:28:33 2007 New Revision: 559793 URL: http://svn.apache.org/viewvc?view=rev&rev=559793 Log: Much better error handling, just in case some actually wants to use this, like for testing or something Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java 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?view=diff&rev=559793&r1=559792&r2=559793 ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java Thu Jul 26 05:28:33 2007 @@ -29,6 +29,7 @@ import org.apache.bsf.BSFManager; import org.apache.bsf.util.IOUtils; +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.cache.UtilCache; /** @@ -54,8 +55,9 @@ if (cl == null) cl = this.getClass().getClassLoader(); - if (context == null) + if (context == null) { throw new EventHandlerException("Problem getting ServletContext"); + } try { // create the BSF manager @@ -80,13 +82,16 @@ if (scriptString == null) { synchronized(this) { if (scriptString == null) { + Debug.logInfo("Loading BSF Script from classpath at location: " + eventMethod, module); scriptStream = cl.getResourceAsStream(eventMethod); + if (scriptStream == null) { + throw new EventHandlerException("Could not find BSF script file at classpath location: " + eventMethod); + } scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream)); eventCache.put(cacheName, scriptString); } } } - } else { // we are a script in the webapp - load by resource cacheName = context.getServletContextName() + ":" + eventPath + eventMethod; @@ -95,6 +100,9 @@ synchronized(this) { if (scriptString == null) { scriptStream = context.getResourceAsStream(eventPath + eventMethod); + if (scriptStream == null) { + throw new EventHandlerException("Could not find BSF script file in webapp context: " + eventPath + eventMethod); + } scriptString = IOUtils.getStringFromReader(new InputStreamReader(scriptStream)); eventCache.put(cacheName, scriptString); } @@ -111,7 +119,6 @@ } return (String) result; - } catch(BSFException e) { throw new EventHandlerException("BSF Error", e); } catch (IOException e) { |
Free forum by Nabble | Edit this page |