On 25.01.2008 12:35:50 Vincent Hennebert wrote:
> Hi Jeremias,
> Jeremias Maerki wrote:
> > That's actually one of the requirements, I just haven't discussed this
> > explicitely on the Wiki page. I assumed everyone can throw any unchecked
> > exception in the listener. Introducing a checked exception for this
> > purpose would be horrible as it would go through all of FOP which I
> > don't think would be useful. Does anyone see that differently?
> No it’s ok to me if particular implementations of FopEventListener throw
> unchecked exceptions.
> But that mentioning of exceptions just makes me wondering of the
> following: what if an unrecoverable error occurs (say, too many cells on
> a table row)? I guess I’ll trigger an event of severity
> EventSeverity.ERROR and I absolutely expect that /every/ listener will
> throw an exception in such a case? Otherwise the processing will become
You can always throw an exception right after the line where you
broadbast the event. That makes sure that the exception is thrown.
There's no need to rely on external behaviour.
We could even add a convention that for an event with
EventSeverity.FATAL the first/second/last parameter must be an Exception
class. The Exception class would have to have a constructor that takes
an EventObject as parameter for initializing the exception. The dynamic
proxy would then throw the exception right after broadcasting the
exception. Or we could change the EventProducer convention so that every
method returns the generated EventObject that you can then use to
initialize an exception. Probably easier and more flexible.
> As to the best approach, the extended one looks good to me. May I ask
> you to keep Java 1.5 in mind when designing your classes? It’s not far
> away now and there are things which are likely to become much more
> elegant with genericity. Just to take your example on the wiki page:
> in EventBroadcaster:
> public <T extends EventProducer> T getEventProducerFor(Class<T> class)
> then I can make
> BasicFOValidationEventProducer producer =
> Exit the hazardous cast and potential run-time exception :-)
Please tell me how I should "keep Java 1.5 in mind"? I cannot use
generics anywhere now. Or do you mean only on the Wiki? That would only
make the whole thing confusing and a potential source for