From c304a08a844a205f41a636758bd234a99709a4b0 Mon Sep 17 00:00:00 2001 From: Adrian Crum Date: Sat, 16 Feb 2013 16:31:31 +0000 Subject: [PATCH] Reverting revision 1345849 because it is not thread-safe and it doesn't work. It appears this was an attempt to create per-tenant FOP factories, but instead each tenant overwrites other tenant's FOP factory instances. A proper implementation would require a FOP factory cache keyed by delegator name. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1446913 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/webapp/view/ApacheFopWorker.java | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java b/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java index 3b25dabbfb1..b270bb17d97 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java @@ -43,10 +43,8 @@ import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.FileUtil; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.DelegatorFactory; -import org.ofbiz.entity.util.EntityUtilProperties; /** * Apache FOP worker class. @@ -67,16 +65,6 @@ public class ApacheFopWorker { * @return FopFactory The FopFactory instance */ public static FopFactory getFactoryInstance() { - Delegator delegator = DelegatorFactory.getDelegator("default"); - return getFactoryInstance(delegator); - } - - /** Returns an instance of the FopFactory class. FOP documentation recommends - * the reuse of the factory instance because of the startup time. - * @param delegator the delegator - * @return FopFactory The FopFactory instance - */ - public static FopFactory getFactoryInstance(Delegator delegator) { if (fopFactory == null) { synchronized (ApacheFopWorker.class) { if (fopFactory != null) { @@ -89,15 +77,15 @@ public static FopFactory getFactoryInstance(Delegator delegator) { fopFactory.setStrictValidation(false); try { - String fopPath = EntityUtilProperties.getPropertyValue("url.properties", "fop.path", delegator); + String ofbizHome = System.getProperty("ofbiz.home"); + String fopPath = UtilProperties.getPropertyValue("fop.properties", "fop.path", ofbizHome + "/framework/webapp/config"); File userConfigFile = FileUtil.getFile(fopPath + "/fop.xconf"); fopFactory.setUserConfig(userConfigFile); - String fopFontBasePath = EntityUtilProperties.getPropertyValue("url.properties", "fop.font.base.path", delegator); - File fopFontBasePathFile = new File(fopFontBasePath); - URL fopFontBaseUrl = FlexibleLocation.resolveLocation(fopFontBasePathFile.toString()); - fopFactory.getFontManager().setFontBaseURL(fopFontBaseUrl.toString()); + String fopFontBaseUrl = UtilProperties.getPropertyValue("fop.properties", "fop.font.base.url", "file:///" + ofbizHome + "/framework/webapp/config/"); + fopFactory.getFontManager().setFontBaseURL(fopFontBaseUrl); + Debug.logInfo("FOP-FontBaseURL: " + fopFontBaseUrl, module); } catch (Exception e) { - Debug.logWarning("Error reading FOP configuration", module); + Debug.logWarning(e, "Error reading FOP configuration", module); } } }