]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
There an easier way to throw exceptions from certain event otherwise not causing...
authorJeremias Maerki <jeremias@apache.org>
Thu, 3 Sep 2009 07:24:43 +0000 (07:24 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 3 Sep 2009 07:24:43 +0000 (07:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@810792 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/trunk/events.xml

index 51a1bb6cc37a5e96f214df76bae2b9ce1c2d8ba4..4ba6014c820604a462ca216f898a301a963e4fd0 100644 (file)
@@ -152,7 +152,28 @@ foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener());]]
         <p>
           By default, FOP continues processing even if an image wasn't found. If you have
           more strict requirements and want FOP to stop if an image is not available, you can
-          do something like the following:
+          do something like the following in the simplest case:
+        </p>
+        <source><![CDATA[public class MyEventListener implements EventListener {
+
+    public void processEvent(Event event) {
+        if ("org.apache.fop.events.ResourceEventProducer".equals(
+                event.getEventGroupID())) {
+            event.setSeverity(EventSeverity.FATAL);
+        } else {
+            //ignore all other events (or do something of your choice)
+        }
+    }
+    
+}]]></source>
+        <p>
+          Increasing the event severity to FATAL will signal the event broadcaster to throw
+          an exception and stop further processing. In the above case, all resource-related
+          events will cause FOP to stop processing.
+        </p>
+        <p>
+          You can also customize the exception to throw (you can may throw a RuntimeException
+          or subclass yourself) and/or which event to respond to:
         </p>
         <source><![CDATA[public class MyEventListener implements EventListener {