/*
 * Copyright (c) 2012 Mateusz Parzonka, Eric Bodden
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Mateusz Parzonka - initial API and implementation
 */
package prm4j.indexing.realtime;

import java.util.ArrayDeque;
import java.util.Deque;

import prm4j.indexing.staticdata.MetaNode;

/**
 * {@link DefaultNodeStore} which is aware of all nodes it produces and retrieves.
 */
public class AwareDefaultNodeStore extends DefaultNodeStore {

    private final Deque<Node> retrievedNodes;

    public AwareDefaultNodeStore(MetaNode metaTree) {
	super(metaTree);
	retrievedNodes = new ArrayDeque<Node>();
    }

    @Override
    public Node getNode(LowLevelBinding[] bindings) {
	Node node = super.getNode(bindings);
	getListOfNodes().add(node);
	return node;
    }

    @Override
    public Node getNode(LowLevelBinding[] bindings, int[] parameterMask) {
	Node node = super.getNode(bindings, parameterMask);
	getListOfNodes().add(node);
	return node;
    }

    public Deque<Node> getListOfNodes() {
	return retrievedNodes;
    }

}

@@ -401,24 +401,60 @@
 .realtime;%0A%0A
+import java.lang.ref.WeakReference;%0A
 import java.
@@ -717,21 +717,36 @@
 l Deque%3C
+WeakReference%3C
 Node%3E
+%3E
  retriev
@@ -860,21 +860,36 @@
 ayDeque%3C
+WeakReference%3C
 Node%3E
+%3E
 ();%0A    
@@ -1012,35 +1012,60 @@
 tOfNodes().add(n
-ode
+ew WeakReference%3CNode%3E(node)
 );%0A%09return node;
@@ -1237,19 +1237,44 @@
 ().add(n
-ode
+ew WeakReference%3CNode%3E(node)
 );%0A%09retu
@@ -1306,21 +1306,36 @@
 c Deque%3C
+WeakReference%3C
 Node%3E
+%3E
  getList

Use WeakReferences in AwareDefaultNodeStore