Initial event handling

From: Holger Hoffstätte (holge..izards.de)
Date: Fri Jan 17 2003 - 11:05:38 EST

  • Next message: Andrus: "Re: Initial event handling"

    I've checked in an initial version of Dirk's event handling, with some
    more ideas, tests and fixes by me. Basically it works like this:

    - DataContext goes about its business as usual, but initializes
    DataContextTransactionEventHandler to listen for notifications.

    - DataContextTransactionEventHandler registers itself for DataContext's
    events

    - before/after saveChanges() a notification will be posted to the
    ObserverManager (aka NSNotificationCenter)

    - the registered handler wakes up, creates an event with optional user
    info and notifies all observers for the appropriate subject.

    - this involves messaging registered observers via Invocations. In order
    to properly take care of the GC, the registered invocations hold weak
    references. Dead invocations (= gc'ed observer) are automagically removed.

    - in the current setting only objects which implement the
    DataObjectTransactionEvent interface get messaged by the handler;
    org.objectsyle.art.oneway.Artist has the added methods, more or less as an
    example and for the tests.

    Things I'm not yet happy with:

    - the dependency between DataContext and the DCEventHandler is dubious but
    looks unavoidable. We've tried really hard to keep the coupling as thin as
    possible, but _somewhere_ the DCEventHandler has to be initialized. This
    looks more like a traditional delegate to me, and we probably need a more
    formalized way to handle this (and other delegates in the future). I'll
    probably add another method to turn event handling for individual DCs
    on/off. Should this be on or off by default? IMHO on doesn't hurt. Maybe
    another setDefault.. method for all new DC instances.

    - the dependency between the DCEventHandler and the
    DataObjectTransactionEvents interface for the DOs is not formalized or
    visible. Something tells me there's a missing link there, but I cannot
    tell what is yet; ideas welcome.

    So, everybody feel free to have a good look and point out obvious flaws,
    good/bad things etc.
    Thanks to Dirk for the initial implementation!

    Holger



    This archive was generated by hypermail 2.0.0 : Fri Jan 17 2003 - 11:06:14 EST