Author: mehdi
Date: Fri Apr 27 13:11:06 2012
New Revision: 1331419

URL: http://svn.apache.org/viewvc?rev=1331419&view=rev
Log:
Fixed concurrency issue re:background-image on a fo:block. Also updated a 
couple license headers in the examples

Modified:
    xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPS.java
    
xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPSSimple.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java

Modified: 
xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPS.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPS.java?rev=1331419&r1=1331418&r2=1331419&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPS.java 
(original)
+++ xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPS.java Fri 
Apr 27 13:11:06 2012
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations 
under
- * the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 /* $Id$ */
@@ -26,11 +26,13 @@ import java.io.OutputStream;
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;
+
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.render.ps.NativeTextHandler;
 import org.apache.fop.svg.PDFDocumentGraphics2DConfigurator;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;
 
 public class ExampleEPS {
 

Modified: 
xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPSSimple.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPSSimple.java?rev=1331419&r1=1331418&r2=1331419&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPSSimple.java 
(original)
+++ 
xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleEPSSimple.java 
Fri Apr 27 13:11:06 2012
@@ -1,33 +1,33 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations 
under
- * the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 /* $Id$ */
 
-
 package embedding;
 
 import java.awt.Font;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 
-import org.apache.fop.render.ps.NativeTextHandler;
 import org.apache.xmlgraphics.java2d.GraphicContext;
 import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;
 
+import org.apache.fop.render.ps.NativeTextHandler;
+
 public class ExampleEPSSimple {
 
   /**

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=1331419&r1=1331418&r2=1331419&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
 Fri Apr 27 13:11:06 2012
@@ -348,9 +348,7 @@ public class CommonBorderPaddingBackgrou
      */
     public static CommonBorderPaddingBackground getInstance(PropertyList pList)
         throws PropertyException {
-
-        CommonBorderPaddingBackground newInstance
-                = new CommonBorderPaddingBackground(pList);
+        CommonBorderPaddingBackground newInstance = new 
CommonBorderPaddingBackground(pList);
         CommonBorderPaddingBackground cachedInstance = null;
         /* if padding-* and background-position-* resolve to absolute lengths
          * the whole instance can be cached */
@@ -368,33 +366,33 @@ public class CommonBorderPaddingBackgrou
                     || newInstance.backgroundPositionVertical.isAbsolute())) {
             cachedInstance = CACHE.fetch(newInstance);
         }
-
-        /* for non-cached, or not-yet-cached instances, preload the image */
-        if ((cachedInstance == null
-                || cachedInstance == newInstance)
+        synchronized (newInstance.backgroundImage.intern()) {
+            /* for non-cached, or not-yet-cached instances, preload the image 
*/
+            if ((cachedInstance == null || cachedInstance == newInstance)
                 && !("".equals(newInstance.backgroundImage))) {
-            //Additional processing: preload image
-            String uri = URISpecification.getURL(newInstance.backgroundImage);
-            FObj fobj = pList.getFObj();
-            FOUserAgent userAgent = pList.getFObj().getUserAgent();
-            ImageManager manager = userAgent.getFactory().getImageManager();
-            ImageSessionContext sessionContext = 
userAgent.getImageSessionContext();
-            ImageInfo info;
-            try {
-                info = manager.getImageInfo(uri, sessionContext);
-                newInstance.backgroundImageInfo = info;
-            } catch (ImageException e) {
-                ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
-                        fobj.getUserAgent().getEventBroadcaster());
-                eventProducer.imageError(fobj, uri, e, fobj.getLocator());
-            } catch (FileNotFoundException fnfe) {
-                ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
-                        fobj.getUserAgent().getEventBroadcaster());
-                eventProducer.imageNotFound(fobj, uri, fnfe, 
fobj.getLocator());
-            } catch (IOException ioe) {
-                ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
-                        fobj.getUserAgent().getEventBroadcaster());
-                eventProducer.imageIOError(fobj, uri, ioe, fobj.getLocator());
+                //Additional processing: preload image
+                String uri = 
URISpecification.getURL(newInstance.backgroundImage);
+                FObj fobj = pList.getFObj();
+                FOUserAgent userAgent = pList.getFObj().getUserAgent();
+                ImageManager manager = 
userAgent.getFactory().getImageManager();
+                ImageSessionContext sessionContext = 
userAgent.getImageSessionContext();
+                ImageInfo info;
+                try {
+                    info = manager.getImageInfo(uri, sessionContext);
+                    newInstance.backgroundImageInfo = info;
+                } catch (ImageException e) {
+                    ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
+                            fobj.getUserAgent().getEventBroadcaster());
+                    eventProducer.imageError(fobj, uri, e, fobj.getLocator());
+                } catch (FileNotFoundException fnfe) {
+                    ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
+                            fobj.getUserAgent().getEventBroadcaster());
+                    eventProducer.imageNotFound(fobj, uri, fnfe, 
fobj.getLocator());
+                } catch (IOException ioe) {
+                    ResourceEventProducer eventProducer = 
ResourceEventProducer.Provider.get(
+                            fobj.getUserAgent().getEventBroadcaster());
+                    eventProducer.imageIOError(fobj, uri, ioe, 
fobj.getLocator());
+                }
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to