On 09/21/2011 12:43 AM, Alexios Giotis wrote:
Hi Bernard,
As far as I know there is no build-in support in FOP to cancel the rendering.
In Java, the only way to achieve it (except the deprecated stop()), is to get
the thread that is executing it and call the interrupt() method. The problem is
that there is no guarantee that the thread will interrupt it's execution and
the behavior really depends on the code it is running. Typically if the thread
is making calculations (and is not blocking on I/O requests or is not executing
a method that throws InterruptedException, ....), then it will not respond to
your interrupt. In this case, the only way to interrupt is if you execute code
like
if(Thread.interrupted()) // clears the interrupted status
throw SomeException();
IMO the best way to make it cancelable is to run fop out-of-process in a
separate VM instance that you can kill using the standard OS methods.
That's what I think I'll end up doing when I need to support
cancellation. It's a bit of a pain and has some performance cost because
you can't re-use the fop factory for multiple runs or benefit from some
of fop's other caching. Perhaps more importantly it means you can't run
under a standard SecurityManager since you need to be able to spawn new
JVM instances. OTOH, it eliminates potential memory leaks / unwanted
threadlocals / caches.
--
Craig Ringer
POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088 Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org