On 11/09/2009 15:28, Martin Gainty wrote:

//assume you have releaseNotes2document.xsl stylesheet
<?xml version="1.0"?>
<!--
   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

   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.
-->

<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     version="1.0">

   <xsl:param name="versionNumber"/>
   <xsl:include href="changes2document.xsl"/>

   <!-- Calculate path to site root, eg '../../' -->
   <xsl:variable name="root">
     <xsl:call-template name="dotdots">
       <xsl:with-param name="path" select="$path"/>
     </xsl:call-template>
   </xsl:variable>

  <!-- FIXME (JJP):  bugzilla is hardwired -->
  <xsl:variable name="bugzilla" 
select="'http://issues.apache.org/bugzilla/buglist.cgi?bug_id='"/>

  <xsl:param name="bugtracking-url" select="$bugzilla"/>

  <xsl:template match="/">
   <xsl:apply-templates select="//changes"/>
  </xsl:template>

  <xsl:template match="changes">
   <document>
    <header>
     <title>
     <xsl:choose>
      <xsl:when test="@title!=''">
        <xsl:value-of select="@title"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>Release Notes for Apache FOP</xsl:text><xsl:value-of 
select="$versionNumber"/>
      </xsl:otherwise>
     </xsl:choose>
    </title>
    </header>
    <body>
      <xsl:if test="contains($versionNumber, 'dev')">
        <warning>Version<xsl:value-of select="$versionNumber"/>  is a 
development release,
        these notes are therefore not complete, they are intended to be an 
indicator
        of the major features that are so far included in this 
version.</warning>
      </xsl:if>

      <xsl:if test="relea...@version=$versionnumber]/notes">
          <xsl:apply-templates select="relea...@version=$versionnumber]/notes"/>
      </xsl:if>

      <xsl:apply-templates select="relea...@version=$versionnumber]"/>
    </body>
   </document>
  </xsl:template>

  <xsl:template match="release">
   <section id="versio...@version}">
    <title>Major Changes in Version<xsl:value-of select="@version"/></title>
    <note>This is not a complete list of changes, a
    full list of changes in this release
    <a href="changes_{$versionNumber}.html">is available</a>.</note>
      <xsl:if test="acti...@context='Code' and @importance='high']">
        <section>
          <title>Important Changes Code Base</title>
          <ul>
           <xsl:apply-templates select="acti...@context='Code' and 
@importance='high']">
             <xsl:sort select="@type"/>
           </xsl:apply-templates>
          </ul>
        </section>
      </xsl:if>
      <xsl:if test="acti...@context='docs' and @importance='high']">
        <section>
          <title>Important Changes Documentation</title>
          <ul>
           <xsl:apply-templates select="acti...@context='docs' and 
@importance='high']">
             <xsl:sort select="@type"/>
           </xsl:apply-templates>
         </ul>
        </section>
      </xsl:if>
      <xsl:if test="acti...@context='admin' and @importance='high']">
        <section>
          <title>Important Changes Project Administration</title>
          <ul>
            <xsl:apply-templates select="acti...@context='admin' and 
@importance='high']">
             <xsl:sort select="@type"/>
           </xsl:apply-templates>
          </ul>
        </section>
      </xsl:if>
      <xsl:if test="acti...@context='design' and @importance='high']">
        <section>
          <title>Important Changes Design</title>
          <ul>
           <xsl:apply-templates select="acti...@context='design' and 
@importance='high']">
             <xsl:sort select="@type"/>
           </xsl:apply-templates>
          </ul>
        </section>
      </xsl:if>
      <xsl:if test="acti...@context='build' and @importance='high']">
        <section>
          <title>Important Changes Build</title>
          <ul>
            <xsl:apply-templates select="acti...@context='build' and 
@importance='high']">
             <xsl:sort select="@type"/>
           </xsl:apply-templates>
          </ul>
        </section>
      </xsl:if>
   </section>
  </xsl:template>

</xsl:stylesheet>

//assume the C:/Dev/FOP/temp/page-x-of-y.xml input
<?xml version="1.0" encoding="UTF-8"?>
<!--
   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

   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.
-->
<!-- $Id: table-cell_bc-child.xml 651302 2008-04-24 16:08:53Z jeremias $ -->
<testcase visual="only">
   <info>
     <p>
       This test checks the rendering of block viewports in reference areas 
generated
       by table-cells. This does not test the layout engine, only the renderer.
     </p>
   </info>
   <fo>
     <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
       <fo:layout-master-set>
         <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in" 
margin="20pt">
           <fo:region-body/>
         </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="normal">
         <fo:flow flow-name="xsl-region-body">
           <fo:table table-layout="fixed" width="4in" 
background-color="lightgray"
                 space-before="2in" space-before.conditionality="retain">
             <fo:table-column column-width="100%"/>
             <fo:table-body>
               <fo:table-row>
                 <fo:table-cell background-color="rgb(230, 230, 255)">
                   <fo:block-container absolute-position="absolute" width="100%" 
height="2em">
                     <fo:block color="red">No red text should be 
visible!</fo:block>
                   </fo:block-container>
                   <fo:block color="green">No red text should be 
visible!</fo:block>
                 </fo:table-cell>
               </fo:table-row>
               <fo:table-row>
                 <fo:table-cell padding="10pt" background-color="rgb(230, 255, 
230)">
                   <fo:block-container absolute-position="absolute" width="100%" 
height="2em" top="10pt">
                     <fo:block color="red">No red text should be 
visible!</fo:block>
                   </fo:block-container>
                   <fo:block color="green">No red text should be 
visible!</fo:block>
                 </fo:table-cell>
               </fo:table-row>
             </fo:table-body>
           </fo:table>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
     <!-- Dummy test. This test is only useful with BatchDiffer. -->
     <eval expected="1" xpath="count(//pageViewport)"/>
   </checks>
</testcase>

//you can incorporate BitmapProducePDF code into your servlet here is a snippet
public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer{

     /** @see 
org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetExtension() */
     protected String getTargetExtension() { return "pdf"; }

     /** @see 
org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
     protected String getTargetFormat() { return MimeConstants.MIME_PDF; }
     /**
      * Main method test harness borrowed from org.apache.fop.visual.BatchDiffer
      * @param args command-line arguments
      */

     public static void main(String[] args) {
         try {
             if (args.length == 0) {
                 System.err.println("FOP Configuration file is missing!");
                 printUsage();
                 System.exit(-1);
             }
             File cfgFile = new File(args[0]);
             if (!cfgFile.exists()) {
                 System.err.println("Configuration file cannot be found: " + 
args[0]);
                 printUsage();
                 System.exit(-1);
             }
             String string_timeout = new String(args[1]);

             if (!timeout) {

                 System.err.println("timeout cannot be found: " + args[1]);

                 printUsage();

                 System.exit(-1);

             }

             Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
             BatchDiffer differ = new BatchDiffer();
//at this point you have a valid cfgFile passed to runBatch
             differ.runBatch(cfgFile,string_timeout);

             System.out.println("Regular exit...");
         } catch (Exception e) {
             System.out.println("Exception caught...");
             e.printStackTrace();
         }
     }

     BitmapProducer[] producers;

     public void runBatch(Configuration cfg,String string_timeout) {
         try {
             ProducerContext context = new ProducerContext();
             
context.setTargetResolution(cfg.getChild("resolution").getValueAsInteger(72));
             String xslt = cfg.getChild("stylesheet").getValue(null);
             if (xslt != null) {
                 try {
                     
context.setTemplates(context.getTransformerFactory().newTemplates(
                             new StreamSource(xslt)));
                 } catch (TransformerConfigurationException e) {
                     log.error("Error setting up stylesheet", e);
                     throw new RuntimeException("Error setting up stylesheet");
                 }
             }
             producers= getProducers(cfg.getChild("producers"));

             //Set up directories
             File srcDir = new 
File(cfg.getChild("source-directory").getValue());
             if (!srcDir.exists()) {
                 throw new RuntimeException("source-directory does not exist: " 
+ srcDir);
             }
             final File targetDir = new 
File(cfg.getChild("target-directory").getValue());
             targetDir.mkdirs();
             if (!targetDir.exists()) {
                 throw new RuntimeException("target-directory is invalid: " + 
targetDir);
             }
             context.setTargetDir(targetDir);

             boolean stopOnException = 
cfg.getChild("stop-on-exception").getValueAsBoolean(true);
             final boolean createDiffs = 
cfg.getChild("create-diffs").getValueAsBoolean(true);

             //RUN!

             IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", 
".fo"});
             //Same filtering as in layout engine tests
             if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) {
                 filter = 
LayoutEngineTestSuite.decorateWithDisabledList(filter);
             }

             int maxfiles = cfg.getChild("max-files").getValueAsInteger(-1);
//you can setup a child node for timeout
             int n_timeout = cfg.getChild("timeout").getValueAsInteger(-1);
//if its 0 then accept the string timeout passed in
             n_timeout=(n_timeout==0) ? new 
java.lang.Integer(string_timeout).intValue() : n_timeout;

             Collection files = FileUtils.listFiles(srcDir, filter, null);
             Iterator i = files.iterator();
             while (i.hasNext()) {
                 final File f = (File)i.next();
                 try {
                     log.info("---=== " + f + " ===---");
                     long[] times = new long[producers.length];
                     final BufferedImage[] bitmaps = new 
BufferedImage[producers.length];
                     for (int j = 0; j<  producers.length; j++) {
                         times[j] = System.currentTimeMillis();
                         bitmaps[j] = produce(producers[j],f, 
context,n_timeout);
                         times[j] = System.currentTimeMillis() - times[j];
                     }
                     if (log.isDebugEnabled()) {
                         StringBuffer sb = new StringBuffer("Bitmap production 
times: ");
                         for (int j = 0; j<  producers.length; j++) {
                             if (j>  0) {
                                 sb.append(", ");
                             }
                             sb.append(times[j]).append("ms");
                         }
                         log.debug(sb.toString());
                     }
                     //Create combined image
                     if (bitmaps[0] == null) {
                         throw new RuntimeException("First producer didn't return a 
bitmap for "
                                 + f + ". Cannot continue.");
                     }

                     Runnable runnable = new Runnable() {
                         public void run() {
                             try {
                                 saveBitmaps(targetDir, f, createDiffs, 
bitmaps);
                             } catch (IOException e) {
                                 log.error("IO error while saving bitmaps: " + 
e.getMessage());
                             }
                         }
                     };
                     //This speeds it up a little on multi-core CPUs (very 
cheap, I know)
                     new Thread(runnable).start();
                 } catch (RuntimeException e) {
                     log.error("Catching RE on file " + f + ": " + 
e.getMessage());
                     if (stopOnException) {
                         log.error("rethrowing...");
                         throw e;
                     }
                 }
                 maxfiles = (maxfiles<  0 ? maxfiles : maxfiles - 1);
                 if (maxfiles == 0) {
                     break;
                 }
             }
         } catch (IOException ioe) {
             log.error("I/O problem while processing", ioe);
             throw new RuntimeException("I/O problem: " + ioe.getMessage());
         } catch (ConfigurationException e) {
             log.error("Error while configuring BatchDiffer", e);
             throw new RuntimeException("Error while configuring BatchDiffer: " 
+ e.getMessage());
         }
     }

    /*** Produces a BufferedImage from the source file by invoking the FO 
processor and
      * converting the generated output file to a bitmap image if necessary.
      * @param src the source FO or XML file
      * @param context context information for the conversion
      * @return the generated BufferedImage*/
     /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer */

// BufferedImage produce(File src, ProducerContext context);
     public BufferedImage produce(File src, ProducerContext context, int 
timeout) {    //modify for timeout
     {
         try
         {
//acquire UserAgent
             FOUserAgent userAgent = fopFactory.newFOUserAgent();
//get target
             userAgent.setTargetResolution(context.getTargetResolution());
//get source
             userAgent.setBaseURL(src.getParentFile().toURL().toString());

//output filename
             File tempOut = new File(context.getTargetDir(),
                     src.getName() + "." + getTargetExtension());

//assume png modify to acceptable binary extension
             File tempPNG = new File(context.getTargetDir(),
                     src.getName() + "." + getTargetExtension() + ".png");
             try
             {
//acquire outputStream
                 OutputStream out = new FileOutputStream(tempOut);
                 out = new BufferedOutputStream(out);
                 try
                 {
                     Fop fop = fopFactory.newFop(getTargetFormat(), userAgent, 
out);
                     SAXResult res = new SAXResult(fop.getDefaultHandler());

                     Transformer transformer = getTransformer(context);
                     transformer.transform(new StreamSource(src), res);
                 }
                 finally
                 {
                     IOUtils.closeQuietly(out);
                 }
//call convert with timeout
                 convert(tempOut, tempPNG, context, timeout);
                 BufferedImage img = BitmapComparator.getImage(tempPNG);
                 return img;
             } finally {
                 if (deleteTempFiles) {
                     if (!tempOut.delete()) {
                         log.warn("Can't delete " + tempOut);
                         tempOut.deleteOnExit();
                     }
                     if (!tempPNG.delete()) {
                         log.warn("Can't delete " + tempPNG);
                         tempPNG.deleteOnExit();
                     }
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
             log.error(e);
             return null;
         }
     }
     /*** Calls an external converter to convert the file generated by FOP to a 
bitmap.
      * @param inFile the generated output file to be converted
      * @param outFile the target filename for the bitmap
      * @param context context information (required bitmap resolution etc.)
      * @throws IOException in case the conversion fails
      * borrowed from org.apache.fop.visual.AbstractPSPDFBitmapProducer
     */
//modified convert to accept timeout parameter
     public void convert(File inFile, File outFile, ProducerContext context,int 
timeout) throws IOException {
//        outFile.delete();

         //Build command-line
         String cmd = MessageFormat.format(converter,new Object[] 
{inFile.toString(), outFile.toString(),
                     Integer.toString(context.getTargetResolution())});

//modify convert to accept timeout and outFile parameter
         convert_with_timeout(cmd, null, null, log,timeout,outFile);

         if (!outFile.exists()) {
             throw new IOException("The target file has not been generated");
         }
         outFile.delete();
     }

     /**
      * Calls an external converter application (GhostScript, for example).
      * @param cmd the full command
      * @param envp array of strings, each element of which has environment 
variable settings
      * in format name=value.
      * @param workDir the working directory of the subprocess, or null if the 
subprocess should
      * inherit the working directory of the current process.
      * @param log the logger to log output by the external application to
      * @throws IOException in case the external call fails
      */
//convert method from ConvertUtils.java ported to accept timeout parameter
//file will be the actual filename
     public static void convert_with_timeout(String cmd, String[] envp, File 
workDir, final Log log,int timeout,File filename)
                 throws IOException {
         log.debug(cmd);

         Process process = null;
         try {
             process = Runtime.getRuntime().exec(cmd, envp, null);

             //Redirect stderr output
             RedirectorLineHandler errorHandler = new 
AbstractRedirectorLineHandler() {
                 public void handleLine(String line) {
                     log.error("ERR>  " + line);
                 }
             };
             StreamRedirector errorRedirector
                 = new StreamRedirector(process.getErrorStream(), errorHandler);

             //Redirect stdout output
             RedirectorLineHandler outputHandler = new 
AbstractRedirectorLineHandler() {
                 public void handleLine(String line) {
                     log.debug("OUT>  " + line);
                 }
             };
             StreamRedirector outputRedirector
                 = new StreamRedirector(process.getInputStream(), 
outputHandler);
             new Thread(errorRedirector).start();
             new Thread(outputRedirector).start();

//use the FileUtils.waitFor to accept file and timeout parameters
//            process.waitFor();
               org.apache.commons.io.FileUtils.waitFor(file, timeout);
         }
         catch (java.lang.InterruptedException ie)
         {
             throw new IOException("The call to the external converter failed: 
" + ie.getMessage());
         } catch (java.io.IOException ioe) {
             throw new IOException("The call to the external converter failed: 
" + ioe.getMessage());
         }

         int exitValue = process.exitValue();
         if (exitValue != 0) {
             throw new IOException("The call to the external converter failed. 
Result: "
                     + exitValue);
         }
}
//more info on FileUtils.waitFor available at
http://commons.apache.org/io/api-1.2/org/apache/commons/io/FileUtils.html

//more info on Apache FOP available at
http://xmlgraphics.apache.org/fop/

pls ping me offline for any questions

Literally *any* questions?

p



Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




Date: Fri, 11 Sep 2009 12:11:00 +0100
From: ma...@apache.org
To: users@tomcat.apache.org
Subject: Re: reply_timeout

Vyv wrote:
Hi there,

I have a webservice running in Apache-Tomcat (6.0.16) on a Windows 2003
server. It's running fine for quite a while now. The WS is a process that
generates PDF documents.

Today we experienced a reply timeout, because the process of generating the
PDF took more time than usual. The PDF was created successfully, but the
client-app got the timeout error.

Is there a way of increasing the value of the reply-timeout?

Don't know. That would be a client-app setting, not a Tomcat one.

Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


_________________________________________________________________
Hotmail® is up to 70% faster. Now good news travels really fast.
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_faster:082009


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to