Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-125
Here is an overview of the issue:
---------------------------------------------------------------------
Key: CAY-125
Summary: EventManager.getDefaultManager().addListener doesn't work
Type: Bug
Status: Assigned
Priority: Major
Project: Cayenne
Components:
Cayenne Core Library
Versions:
1.1 [DEV]
Assignee: Andrus Adamchik
Reporter: Claudio Rosati
Created: Thu, 13 May 2004 6:05 AM
Updated: Thu, 13 May 2004 6:05 AM
Environment: Win XP, J2SE 1.4.2_04, JavaGroups
Description:
EventManager.getDefaultManager().addListener (5 parameters version) doesn't work.
I've tried Cayenne with JavaGroups. I've the following 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 and customListener are retained elsewhere):
dataContext = DataContext.createDataContext();
DataRowStore cache = dataContext.getObjectStore().getDataRowCache();
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.
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.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://objectstyle.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
This archive was generated by hypermail 2.0.0 : Thu May 13 2004 - 06:07:48 EDT