Re: Event handling progress

From: Holger Hoffstätte (holge..izards.de)
Date: Wed Jan 22 2003 - 14:34:27 EST

  • Next message: Andrus Adamchik: "Re: Event handling progress"

    Andrus wrote:
    > I included your test case in Cayenne under the name DataContextEventsTst.
    > Indeed MySQL fails miserably on attempts to save a null value in a NOT NULL
    > column. Guess what happens? It quietly saves an empty string ("") instead
    > of NULL. Can you imagine that!!!

    This is in fact related to Craig's similar problems with timestamps. Read
    about MySQL's way to treat NULL values here:
    http://www.mysql.com/doc/en/CREATE_TABLE.html - this is so totally
    unbelievable bad that I don't know what to say. I guess we really need a
    PostgreSQL plugin ASAP..
    Btw, PostgreSQL will likely have a 'native' (non-Cygwin) Win32 version
    with 7.4! This should help its popularity a lot.

    > As expected, Sybase and Oracle correctly rollback failed transaction.

    Great!

    > 1. [Fixed] Sometimes CommitObserver would not unregister as listener.

    Weird. Putting the unregister.. into a finally block is the right thing in
    any case.

    > 2. [Fixed] CommitObserver would react on events generated by all other
    > DataContexts. This doesn't make sense, so I added a check in notification
    > methods, so that all but the right DataContext will be ignored.

    This was more or less by design, but indeed an oversight - thanks for
    fixing it. Current event handling really acts as undirected broadcast,
    with one dimension less than e.g. NSNotifcationcenter: you cannot register
    for events sent by a specific sender. I'll add this later, it was on my
    list of things to do anyway.

    Testing things with the help of DataContext/CommitObserver is interesting,
    since it raises many problems because of their tight coupling. Normally
    you'd have a one-to-many communication between sender and listeners.

    > 3. [Unfixed] I don't remember if we discussed this before, but EventHandler
    > (or rather its internal collections) is totally unsynchronized. This really

    I mentioned it shortly - I didn't yet review everything but essentially
    all of EventManager must be completely synchronized, simply because all
    hell will break loose otherwise. Will do it tomorrow or so. Unfortunately
    I have absolutely no idea about how to test this reliably.

    > Another consideration. I changed DataContext events default to "off". I am
    > open for discussion on that and I didn't mean to mess up other's code. My

    It's not really used anyhwere yet. Personally I would rather see it on,
    just for consistency; that was Dirk's motivation for the optional
    DataObject.. interface. I imagine that other (future) events might be
    useful to be sent always as well. EOF doesn't really suffer from that
    either; the really expensive operations are DB roundtrips,
    loading/instantiating objects etc., and when you're about to write
    something to the database, iterating over a couple of objects (sometimes
    just one or two) is not a problem. The event itself is really small, just
    like an iterator.

    > I suggest a User Guide chapter on event handling in Cayenne where we can
    > describe all these things in greater detail.

    Sure. We wanted to kick around the code some more before writing that,
    just like the JavaDoc comments. I am probably busy with 'real' work until
    the end of next week or so, but definitely have time again after that.

    There's one more thing that I'll fix regarding the coupling between an
    EventSubject and the interface that listeners have to implement. Curently
    there's none, and ironically that's not good since neither senders nor
    listeners have no way of making sure they are sending/receiving the right
    event class, which might lead to ClassCastExceptions. I already have a
    very small, clean, nonintrusive fix for that in mind, though.

    thanks
    Holger



    This archive was generated by hypermail 2.0.0 : Wed Jan 22 2003 - 14:35:27 EST