Add parent nodes with updated child collections to NodeChangeListener protocol.
Make Node.setLastSubnodeChange() public.
This commit is contained in:
parent
f042bbd36a
commit
d1b5b820ad
5 changed files with 33 additions and 19 deletions
|
@ -324,7 +324,7 @@ public final class Node implements INode, Serializable {
|
|||
* Called by the transactor on registered parent nodes to mark the
|
||||
* child index as changed
|
||||
*/
|
||||
void setLastSubnodeChange(long t) {
|
||||
public void setLastSubnodeChange(long t) {
|
||||
lastSubnodeChange = t;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ import java.util.List;
|
|||
public interface NodeChangeListener {
|
||||
|
||||
/**
|
||||
* Called when a transaction is committed that has created, modified or
|
||||
* deleted one or more nodes.
|
||||
* Called when a transaction is committed that has created, modified,
|
||||
* deleted or changed the child collection one or more nodes.
|
||||
*/
|
||||
public void nodesChanged(List inserted, List updated, List deleted);
|
||||
public void nodesChanged(List inserted, List updated, List deleted, List parents);
|
||||
|
||||
}
|
||||
|
|
|
@ -1829,12 +1829,12 @@ public final class NodeManager {
|
|||
/**
|
||||
* Called by transactors after committing.
|
||||
*/
|
||||
protected void fireNodeChangeEvent(List inserted, List updated, List deleted) {
|
||||
protected void fireNodeChangeEvent(List inserted, List updated, List deleted, List parents) {
|
||||
int l = listeners.size();
|
||||
|
||||
for (int i=0; i<l; i++) {
|
||||
try {
|
||||
((NodeChangeListener) listeners.get(i)).nodesChanged(inserted, updated, deleted);
|
||||
((NodeChangeListener) listeners.get(i)).nodesChanged(inserted, updated, deleted, parents);
|
||||
} catch (Error e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -102,10 +102,11 @@ public class Replicator implements Runnable, NodeChangeListener {
|
|||
|
||||
|
||||
/**
|
||||
* Called when a transaction is committed that has created, modified or
|
||||
* deleted one or more nodes.
|
||||
* Called when a transaction is committed that has created, modified,
|
||||
* deleted or changed the child collection one or more nodes.
|
||||
*/
|
||||
public synchronized void nodesChanged(List inserted, List updated, List deleted) {
|
||||
public synchronized void nodesChanged(List inserted, List updated,
|
||||
List deleted, List parents) {
|
||||
add.addAll(inserted);
|
||||
add.addAll(updated);
|
||||
delete.addAll(deleted);
|
||||
|
|
|
@ -225,15 +225,23 @@ public class Transactor extends Thread {
|
|||
int updated = 0;
|
||||
int deleted = 0;
|
||||
|
||||
if (!dirtyNodes.isEmpty()) {
|
||||
Object[] dirty = dirtyNodes.values().toArray();
|
||||
|
||||
ArrayList insertedNodes = new ArrayList();
|
||||
ArrayList updatedNodes = new ArrayList();
|
||||
ArrayList deletedNodes = new ArrayList();
|
||||
ArrayList insertedNodes = null;
|
||||
ArrayList updatedNodes = null;
|
||||
ArrayList deletedNodes = null;
|
||||
ArrayList modifiedParentNodes = null;
|
||||
// if nodemanager has listeners collect dirty nodes
|
||||
boolean hasListeners = nmgr.hasNodeChangeListeners();
|
||||
|
||||
if (hasListeners) {
|
||||
insertedNodes = new ArrayList();
|
||||
updatedNodes = new ArrayList();
|
||||
deletedNodes = new ArrayList();
|
||||
modifiedParentNodes = new ArrayList();
|
||||
}
|
||||
|
||||
if (!dirtyNodes.isEmpty()) {
|
||||
Object[] dirty = dirtyNodes.values().toArray();
|
||||
|
||||
// the set to collect DbMappings to be marked as changed
|
||||
HashSet dirtyDbMappings = new HashSet();
|
||||
|
||||
|
@ -307,9 +315,6 @@ public class Transactor extends Thread {
|
|||
nmgr.idgen.dirty = false;
|
||||
}
|
||||
|
||||
if (hasListeners) {
|
||||
nmgr.fireNodeChangeEvent(insertedNodes, updatedNodes, deletedNodes);
|
||||
}
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -319,8 +324,16 @@ public class Transactor extends Thread {
|
|||
for (Iterator i = parentNodes.iterator(); i.hasNext(); ) {
|
||||
Node node = (Node) i.next();
|
||||
node.setLastSubnodeChange(now);
|
||||
if (hasListeners) {
|
||||
modifiedParentNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasListeners) {
|
||||
nmgr.fireNodeChangeEvent(insertedNodes, updatedNodes,
|
||||
deletedNodes, modifiedParentNodes);
|
||||
}
|
||||
|
||||
// clear the node collections
|
||||
dirtyNodes.clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue