Hello Andrus,
I have a good and a bad news.
The bad one is that event retaining the listener nothing happened.
The good new is that, sniffing the source code of ObjectStore I've
modified this code
EventManager.getDefaultManager().addListener(
customListener,
"snapshotsChanged",
SnapshotEvent.class,
cache.getSnapshotEventSubject(),
cache
);
into
EventManager.getDefaultManager().addNonBlockingListener(
customListener,
"snapshotsChanged",
SnapshotEvent.class,
cache.getSnapshotEventSubject()
);
i.e. I've removed the last parameter, and I've also added the following
into the listener method:
if ( event.getPostedBy() != cache
|| event.getSource() == dataContext.getObjectStore() )
{
return;
}
In this way it worked.
That said I have two more things for you:
1. As soon as I access my first object the following messages appears on
standard output:
DEBUG BeanUtils:
setProperty(org.objectstyle.cayenne.event.JavaGroupsBridg..20893,
configURL, <NULL>)
DEBUG ConvertUtils: Convert string 'null' to class 'java.lang.String'
DEBUG ConvertUtils: Using converter
org.apache.commons.beanutils.converters.StringConverte..e3115
DEBUG BeanUtils:
setProperty(org.objectstyle.cayenne.event.JavaGroupsBridg..20893,
multicastAddress, 228.0.0.5)
DEBUG ConvertUtils: Convert string '228.0.0.5' to class
'java.lang.String'
DEBUG ConvertUtils: Using converter
org.apache.commons.beanutils.converters.StringConverte..e3115
DEBUG BeanUtils:
setProperty(org.objectstyle.cayenne.event.JavaGroupsBridg..20893,
multicastPort, 22222)
DEBUG ConvertUtils: Convert string '22222' to class
'java.lang.String'
DEBUG ConvertUtils: Using converter
org.apache.commons.beanutils.converters.StringConverte..e3115
There is a way to disable them?
2. JavaGroups changed into Jgroups and the last JAR (2.2.1) doesn't work
with Cayenne M6 because packages and some class names changed. Please
when you will upgrade to jgroups 2.2.x put really visibile note on the
readme because all of us using JavaGroups *must* upgrade to the new jar.
Thanks
CLaudio
------------------------------------
Advanced Ccomputer Systems S.p.A.
Claudio Rosati
Project Manager
claudio.rosat..csys.it
via Della Bufalotta 378
00139 Roma, RM
Italy
tel: +39 06 8709 0516
www.acsmultimedia.com
------------------------------------
> -----Original Message-----
> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
> Sent: Friday, May 07, 2004 11:34 AM
> To: cayenne-use..bjectstyle.org
> Subject: Re: event handling
>
>
>
> Hi Claudio,
>
> One thing to check is that your listener is retained
> elsewhere in your Java code. EventManager keeps a weak
> reference to subjects and listeners to avoid memory leaks,
> and it is a user responsibility to retain them in the
> application. In this respect EventManager is different from
> say Swing even sources.
>
> If this doesn't help, I'll need to try out your code when I
> come home next week.
>
> Andrus
>
>
>
> > Hello all,
> >
> > I've tried Cayenne with JavaGroups. I've a problem.
> >
> > I launch the same application on two PC. I've a GUI that show the
> > properties of a Cayenne object. I modify the object on the first
> > application and, after a manual update of the GUI (i.e. a
> repaint of
> > the propertes of a previously loaded - and displayed -
> instance of the
> > Cayenne object) I see the modified values.
> >
> > Now I would like to use events in order to perform an automatic GUI
> > update when the same object is modified elsewhere. I have used the
> > following code:
> >
> > dataContext = DataContext.createDataContext();
> >
> > DataRowStore cache = dataContext.getObjectStore().getDataRowCache();
> > SnapshotEventListener customListener = new SnapshotEventListener() {
> > public void snapshotsChanged ( SnapshotEvent event ) {
> > System.out.println("*** Something ghanged! ***");
> > }
> > };
> >
> > EventManager.getDefaultManager().addListener(
> > customListener,
> > "snapshotsChanged",
> > SnapshotEvent.class,
> > cache.getSnapshotEventSubject(),
> > cache
> > );
> >
> > ... read the object and display it on the GUI ...
> >
> >
> >
> > What happened is: nothing! The listener is never called.
> >
> > Now the questions:
> >
> > 1. Why? What I am missing?
> > 2. In which thread the snapshotsChanged method is called?
> The same of
> > GUI (Swing/AWT) events?
> >
> > Thanks in advance.
> >
> > Claudio
> >
>
>
This archive was generated by hypermail 2.0.0 : Fri May 07 2004 - 10:43:46 EDT