Author: adrianc
Date: Sat Feb 16 16:31:31 2013
New Revision: 1446913

URL: http://svn.apache.org/r1446913
Log:
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.

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java

Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java?rev=1446913&r1=1446912&r2=1446913&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java 
(original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java 
Sat Feb 16 16:31:31 2013
@@ -43,10 +43,8 @@ import org.apache.fop.apps.MimeConstants
 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 class ApacheFopWorker {
                 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);
                 }
             }
         }


Reply via email to