Author: doogie
Date: Mon Nov 17 22:09:58 2008 New Revision: 718491 URL: http://svn.apache.org/viewvc?rev=718491&view=rev Log: Implement multiple resource loading from the classpath; this means that framework doesn't have to reference transforms that exist in later components. Added: ofbiz/trunk/applications/content/config/freemarkerTransforms.properties - copied unchanged from r681276, ofbiz/trunk/framework/webapp/config/applicationTransforms.properties ofbiz/trunk/framework/webapp/config/freemarkerTransforms.properties - copied, changed from r566645, ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties ofbiz/trunk/framework/widget/config/freemarkerTransforms.properties - copied, changed from r566645, ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties Removed: ofbiz/trunk/framework/webapp/config/applicationTransforms.properties Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=718491&r1=718490&r2=718491&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Mon Nov 17 22:09:58 2008 @@ -28,6 +28,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Date; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -89,29 +90,31 @@ } catch (TemplateException e) { Debug.logError("Unable to set date/time and number formats in FreeMarker: " + e, module); } - // Load framework transforms first. // Transforms properties file set up as key=transform name, property=transform class name - Properties props = UtilProperties.getProperties(FRAMEWORK_TRANSFORMS); - if (props == null || props.isEmpty()) { - Debug.logError("Unable to locate properties file " + FRAMEWORK_TRANSFORMS, module); - } else { - loadTransforms(props); - } - - // Load application transforms next. - props = UtilProperties.getProperties(APPLICATION_TRANSFORMS); - if (props == null || props.isEmpty()) { - Debug.logWarning("Unable to locate properties file " + APPLICATION_TRANSFORMS + ". If you are using only the OFBiz framework, then this warning can be ignored.", module); - } else { - loadTransforms(props); + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + Enumeration<URL> resources; + try { + resources = loader.getResources("freemarkerTransforms.properties"); + } catch (IOException e) { + Debug.logError(e, "Could not load list of freemarkerTransforms.properties", module); + throw (InternalError) new InternalError(e.getMessage()).initCause(e); + } + while (resources.hasMoreElements()) { + URL propertyURL = resources.nextElement(); + Debug.logInfo("loading properties: " + propertyURL, module); + Properties props = UtilProperties.getProperties(propertyURL); + if (props == null || props.isEmpty()) { + Debug.logError("Unable to locate properties file " + propertyURL, module); + } else { + loadTransforms(loader, props); + } } } /** * Protected helper method. */ - protected static void loadTransforms(Properties props) { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); + protected static void loadTransforms(ClassLoader loader, Properties props) { for (Iterator<Object> i = props.keySet().iterator(); i.hasNext();) { String key = (String)i.next(); String className = props.getProperty(key); Copied: ofbiz/trunk/framework/webapp/config/freemarkerTransforms.properties (from r566645, ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/config/freemarkerTransforms.properties?p2=ofbiz/trunk/framework/webapp/config/freemarkerTransforms.properties&p1=ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties&r1=566645&r2=718491&rev=718491&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties (original) +++ ofbiz/trunk/framework/webapp/config/freemarkerTransforms.properties Mon Nov 17 22:09:58 2008 @@ -27,4 +27,3 @@ ofbizAmount=org.ofbiz.webapp.ftl.OfbizAmountTransform setRequestAttribute=org.ofbiz.webapp.ftl.SetRequestAttributeMethod renderWrappedText=org.ofbiz.webapp.ftl.RenderWrappedTextTransform -menuWrap=org.ofbiz.widget.menu.MenuWrapTransform Copied: ofbiz/trunk/framework/widget/config/freemarkerTransforms.properties (from r566645, ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/config/freemarkerTransforms.properties?p2=ofbiz/trunk/framework/widget/config/freemarkerTransforms.properties&p1=ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties&r1=566645&r2=718491&rev=718491&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/config/frameworkTransforms.properties (original) +++ ofbiz/trunk/framework/widget/config/freemarkerTransforms.properties Mon Nov 17 22:09:58 2008 @@ -21,10 +21,4 @@ # entries are in the form: key=transform name, property=transform class name -ofbizUrl=org.ofbiz.webapp.ftl.OfbizUrlTransform -ofbizContentUrl=org.ofbiz.webapp.ftl.OfbizContentTransform -ofbizCurrency=org.ofbiz.webapp.ftl.OfbizCurrencyTransform -ofbizAmount=org.ofbiz.webapp.ftl.OfbizAmountTransform -setRequestAttribute=org.ofbiz.webapp.ftl.SetRequestAttributeMethod -renderWrappedText=org.ofbiz.webapp.ftl.RenderWrappedTextTransform menuWrap=org.ofbiz.widget.menu.MenuWrapTransform |
Free forum by Nabble | Edit this page |