Re: Event Listeners

From: Gilberto Rodriguez (gilberto.rodrigue..onviveon.com)
Date: Thu Feb 16 2006 - 14:31:22 EST

  • Next message: Tomi NA: "Re: pumping data: mssql->pgsql"

    Thanks Andrus....

    On Feb 15, 2006, at 11:26 PM, Andrus Adamchik wrote:

    > Hi,
    >
    > Things have changed in 1.2 and the outdated 1.1 documentation is
    > falling behind. A static EventManager is no longer used. Instead an
    > EventManager is attached to a DataDomain. So you can do something
    > like this:
    >
    > DataDomain domain = Configuration.getSharedConfiguration().getDomain
    > ();
    > DataRowStore cache = domain.getSharedSnapshotCache();
    >
    > domain.getEventManager().addListener(this, "snapshotsChanged",
    > SnapshotEvent.class, cache.getSnapshotEventSubject());
    >
    >
    > Andrus
    >
    > P.S. Thanks to Cris and Kevin, we now have all 1.1 documentation
    > residing on Wiki, so it should improve significantly in the
    > following releases.
    >
    >
    >
    > On Feb 15, 2006, at 5:47 PM, Gilberto Rodriguez wrote:
    >> Hi I'm new to cayenne and I am trying to create a Listener class
    >> that listens to snapshots changes. So far I haven't been
    >> successful in doing so. Could some one give some hints in how to
    >> do something like that.
    >>
    >> I used to do it in WebObjects with the following code:
    >>
    >> NSNotificationCenter.defaultCenter().addObserver(this, new
    >> NSSelector("publishChange", new Class[] { NSNotification.class }),
    >> EOObjectStoreCoordinator.ObjectsChangedInStoreNotification,
    >> EOObjectStoreCoordinator.defaultCoordinator());
    >>
    >> In cayenne I am doing the following unsuccessfully:
    >>
    >> public class IMWSEventListener implements SnapshotEventListener {
    >>
    >> private static IMWSEventListener customListener = null;
    >>
    >> private DataRowStore cache;
    >>
    >> private IMWSEventListener() {
    >> super();
    >> DataContext dataContext = DataContext.createDataContext();
    >> cache = dataContext.getObjectStore().getDataRowCache();
    >> EventManager.getDefaultManager().addListener(this,
    >> "snapshotsChanged", SnapshotEvent.class,
    >> cache.getSnapshotEventSubject());
    >> }
    >>
    >> public static void init() {
    >> if (customListener == null) {
    >> customListener = new IMWSEventListener();
    >> }
    >> }
    >>
    >> public void snapshotsChanged(SnapshotEvent event) {
    >> System.out.println("\n\n ---- > > > > INSIDE THE LISTENER < < <
    >> < < ------- \n\n\n");
    >> System.out.println("EVENT = " + event);
    >> }
    >>
    >> }
    >>
    >> Any help would be appreciated.
    >>
    >>
    >>
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Thu Feb 16 2006 - 14:31:26 EST