Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Reverting revision 1345849 because it is not thread-safe and it doesn…
Browse files Browse the repository at this point in the history
…'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
  • Loading branch information
adrian-crum committed Feb 16, 2013
1 parent 4867b23 commit c304a08
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java
Expand Up @@ -43,10 +43,8 @@
import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.FileUtil;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate; 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. * Apache FOP worker class.
Expand All @@ -67,16 +65,6 @@ public class ApacheFopWorker {
* @return FopFactory The FopFactory instance * @return FopFactory The FopFactory instance
*/ */
public static FopFactory getFactoryInstance() { 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) { if (fopFactory == null) {
synchronized (ApacheFopWorker.class) { synchronized (ApacheFopWorker.class) {
if (fopFactory != null) { if (fopFactory != null) {
Expand All @@ -89,15 +77,15 @@ public static FopFactory getFactoryInstance(Delegator delegator) {
fopFactory.setStrictValidation(false); fopFactory.setStrictValidation(false);


try { 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"); File userConfigFile = FileUtil.getFile(fopPath + "/fop.xconf");
fopFactory.setUserConfig(userConfigFile); fopFactory.setUserConfig(userConfigFile);
String fopFontBasePath = EntityUtilProperties.getPropertyValue("url.properties", "fop.font.base.path", delegator); String fopFontBaseUrl = UtilProperties.getPropertyValue("fop.properties", "fop.font.base.url", "file:///" + ofbizHome + "/framework/webapp/config/");
File fopFontBasePathFile = new File(fopFontBasePath); fopFactory.getFontManager().setFontBaseURL(fopFontBaseUrl);
URL fopFontBaseUrl = FlexibleLocation.resolveLocation(fopFontBasePathFile.toString()); Debug.logInfo("FOP-FontBaseURL: " + fopFontBaseUrl, module);
fopFactory.getFontManager().setFontBaseURL(fopFontBaseUrl.toString());
} catch (Exception e) { } catch (Exception e) {
Debug.logWarning("Error reading FOP configuration", module); Debug.logWarning(e, "Error reading FOP configuration", module);
} }
} }
} }
Expand Down

0 comments on commit c304a08

Please sign in to comment.