[Opensource] How can i create Listener Objects for DBObject?
fjm
fzxfjl at public.cz.js.cn
Wed Jul 9 19:08:29 PDT 2003
Hello, Gaspar Gonzalez Oliva,
We found the same problem, and have added following code into DBObject.java:
//=============== begin ====
private static Vector listeners = null;
public void deleteNotify(String keyFieldValue, ErrorCollection ee)
throws DBException {
DBListener oneListener = null;
if (listeners != null) {
Vector theListeners = null;
synchronized(listeners) {
theListeners = (Vector)listeners.clone();
}
for (Enumeration e = theListeners.elements(); e.hasMoreElements();) {
oneListener = (DBListener)e.nextElement();
oneListener.deletedAction(this.getName(),keyFieldValue,ee);
}
}
}
public void addNotify(String keyFieldValue, ErrorCollection ee) throws DBException {
DBListener oneListener = null;
if (listeners != null) {
Vector theListeners = null;
synchronized(listeners) {
theListeners = (Vector)listeners.clone();
}
for (Enumeration e = theListeners.elements(); e.hasMoreElements();) {
oneListener = (DBListener)e.nextElement();
oneListener.addedAction(this.getName(),keyFieldValue,ee);
}
}
}
public void codeUpgradeNotify(String keyFieldValue, ErrorCollection ee) throws DBException {
DBListener oneListener = null;
if (listeners != null) {
Vector theListeners = null;
synchronized(listeners) {
theListeners = (Vector)listeners.clone();
}
for (Enumeration e = theListeners.elements(); e.hasMoreElements();) {
oneListener = (DBListener)e.nextElement();
oneListener.codeUpgradedAction(this.getName(),keyFieldValue,ee);
}
}
}
/**
* Adds a DBListener object to list of listeners
*
* @param listener DBListener The object that wants to listen in on DBObject add/delete
*/
public static synchronized void addListener(DBListener listener) {
if (listeners == null) {
listeners = new Vector(4);
}
listeners.add(listener);
}
//=============== end ====
and DBListener.java:
-------------------------------------------------------------------------------
package com.jsite.expresso.misc;
import com.jcorporate.expresso.core.controller.ErrorCollection;
import com.jcorporate.expresso.core.db.DBException;
public interface DBListener {
public void deletedAction(String dbobjName, String keyFieldValue, ErrorCollection ee)
throws DBException;
public void addedAction(String dbobjName, String keyFieldValue, ErrorCollection ee)
throws DBException;
}
-------------------------------------------------------------------------------
>Hi,
>
>I see that Expresso 5.0.4 have a DBObject method called <addCacheEventListener>, but is
>marked deprecated, that let us register another object to "listening"
>(updates/adds/deletes) to this DBObject. This method is deprecated, my question is:
>
>1-What another option i have to do this, "listening"?. is the <notifyListeners>
>method, the solution?.
>2-Since what version of Expresso it is deprecated?
>
>Gaspar
>
>
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/
= = = = = = = = = = = = = = = = = = = =
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fjm
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fzxfjl at public.cz.js.cn
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2003-07-10
More information about the Opensource
mailing list