diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-04-18 12:03:24 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-04-18 12:03:24 +0000 |
commit | 070382fa9bc83afed2acabb5fc1f37e5762ed9f9 (patch) | |
tree | a2d0b691cfcab4f336522ddf879d8a388e639614 /src/java/org | |
parent | 85946488d7551416767aaa896680f6bd5fe9827b (diff) | |
download | xmlgraphics-fop-070382fa9bc83afed2acabb5fc1f37e5762ed9f9.tar.gz xmlgraphics-fop-070382fa9bc83afed2acabb5fc1f37e5762ed9f9.zip |
Bugfix: If the first event is not issued over an event producer, the fallback logging event listener was not installed.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@649477 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/apps/FOUserAgent.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 307087f74..eea7f3926 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -39,7 +39,7 @@ import org.apache.fop.Version; import org.apache.fop.events.DefaultEventBroadcaster; import org.apache.fop.events.Event; import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.events.EventProducer; +import org.apache.fop.events.EventListener; import org.apache.fop.events.FOPEventListenerProxy; import org.apache.fop.events.LoggingEventListener; import org.apache.fop.fo.FOEventHandler; @@ -549,11 +549,25 @@ public class FOUserAgent { private class FOPEventBroadcaster extends DefaultEventBroadcaster { - private FOPEventListenerProxy rootListener; + private EventListener rootListener; public FOPEventBroadcaster() { - this.rootListener = new FOPEventListenerProxy( - this.listeners, FOUserAgent.this); + //Install a temporary event listener that catches the first event to + //do some initialization. + this.rootListener = new EventListener() { + public void processEvent(Event event) { + if (!listeners.hasEventListeners()) { + //Backwards-compatibility: Make sure at least the LoggingEventListener is + //plugged in so no events are just silently swallowed. + addEventListener( + new LoggingEventListener(LogFactory.getLog(FOUserAgent.class))); + } + //Replace with final event listener + rootListener = new FOPEventListenerProxy( + listeners, FOUserAgent.this); + rootListener.processEvent(event); + } + }; } /** {@inheritDoc} */ @@ -561,18 +575,6 @@ public class FOUserAgent { rootListener.processEvent(event); } - /** {@inheritDoc} */ - protected EventProducer createProxyFor(Class clazz) { - if (!this.listeners.hasEventListeners()) { - //Backwards-compatibility: Make sure at least the LoggingEventListener is plugged - //in so no events are just silently swallowed. - addEventListener( - new LoggingEventListener(LogFactory.getLog(FOUserAgent.class))); - - } - return super.createProxyFor(clazz); - } - } } |