[Mulgara-svn] r1071 - in trunk/src/jar: resolver-store/java/org/mulgara/store/statement/xa store-nodepool-xa/java/org/mulgara/store/nodepool/xa store-stringpool-xa/java/org/mulgara/store/stringpool/xa tuples-hybrid/java/org/mulgara/store/xa util-xa/java/org/mulgara/store/xa

pag at mulgara.org pag at mulgara.org
Tue Jul 8 16:15:41 UTC 2008


Author: pag
Date: 2008-07-08 09:15:40 -0700 (Tue, 08 Jul 2008)
New Revision: 1071

Removed:
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/ObjectPool.java
Modified:
   trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
   trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java
   trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
   trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
   trunk/src/jar/store-nodepool-xa/java/org/mulgara/store/nodepool/xa/XANodePoolImpl.java
   trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
   trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
   trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFileTest.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLNode.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/AbstractBlockFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/Block.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFileTest.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeListTest.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFileTest.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFileTest.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFile.java
   trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFileTest.java
Log:
Deleted ObjectPool and all references to it.

This is a real architectural change, as the use of these pools was pervasive in the lower layers.

In JDK 1.4, object pools were required for efficient operation, however, improvements in memory
management in JDK 1.5 changed the recommendations from Sun to eliminate object pools partly
to help the garbage collector, and partly because allocation was typically much faster:
  http://java.sun.com/docs/hotspot/HotSpotFAQ.html#gc_pooling
Since we no longer support JDK 1.4, then this is an overdue change. Apparently JDK 1.6 offers
even better performance.

A number of changes resulted in poor formatting, so this was cleaned up at the same time.
Also, a number of warnings were removed (e.g. non-typed WeakReferences and phase lists
in the FreeList class). This was outside of the scope of removing the object pools, but
the opportunity to make the modification was there, and these classes are unlikely to be
revisited in the foreseeable future.



Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -96,6 +96,7 @@
 
   private final static int PAYLOAD_SIZE = IDX_BLOCK_ID + 1;
 
+  @SuppressWarnings("unused")
   private File file;
 
   private AVLFile avlFile;
@@ -124,14 +125,11 @@
   /**
    * CONSTRUCTOR TripleAVLFile TO DO
    *
-   * @param objectPool PARAMETER TO DO
    * @param file PARAMETER TO DO
    * @param sortOrder PARAMETER TO DO
    * @throws IOException EXCEPTION TO DO
    */
-  public TripleAVLFile(
-      ObjectPool objectPool, File file, int[] sortOrder
-  ) throws IOException {
+  public TripleAVLFile(File file, int[] sortOrder) throws IOException {
     this.file = file;
     this.sortOrder = sortOrder;
 
@@ -140,10 +138,8 @@
     order2 = sortOrder[2];
     order3 = sortOrder[3];
 
-    avlFile = new AVLFile(objectPool, file, PAYLOAD_SIZE);
-    blockFile = new ManagedBlockFile(
-        objectPool, file + BLOCKFILE_EXT, BLOCK_SIZE, BlockFile.IOType.DEFAULT
-    );
+    avlFile = new AVLFile(file, PAYLOAD_SIZE);
+    blockFile = new ManagedBlockFile(file + BLOCKFILE_EXT, BLOCK_SIZE, BlockFile.IOType.DEFAULT);
     avlComparator = new TripleAVLComparator(sortOrder);
     tripleComparator = new TripleComparator(sortOrder);
 
@@ -154,15 +150,12 @@
   /**
    * CONSTRUCTOR TripleAVLFile TO DO
    *
-   * @param objectPool PARAMETER TO DO
    * @param fileName PARAMETER TO DO
    * @param sortOrder PARAMETER TO DO
    * @throws IOException EXCEPTION TO DO
    */
-  public TripleAVLFile(
-      ObjectPool objectPool, String fileName, int[] sortOrder
-  ) throws IOException {
-    this(objectPool, new File(fileName), sortOrder);
+  public TripleAVLFile(String fileName, int[] sortOrder) throws IOException {
+    this(new File(fileName), sortOrder);
   }
 
 
@@ -665,37 +658,30 @@
     /**
      * Adds a triple to the graph.
      *
-     * @param objectPool The feature to be added to the Triple attribute
      * @param node0 The 0 node of the triple.
      * @param node1 The 1 node of the triple.
      * @param node2 The 2 node of the triple.
      * @param node3 The 3 node of the triple.
      * @throws IOException EXCEPTION TO DO
      */
-    public void addTriple(
-        ObjectPool objectPool,
-        long node0, long node1, long node2, long node3
-    ) throws IOException {
-      addTriple(objectPool, new long[] {node0, node1, node2, node3});
+    public void addTriple(long node0, long node1, long node2, long node3) throws IOException {
+      addTriple(new long[] {node0, node1, node2, node3});
     }
 
 
     /**
      * Adds a triple to the graph.
      *
-     * @param objectPool The feature to be added to the Triple attribute
      * @param triple The triple to add
      * @throws IOException EXCEPTION TO DO
      */
-    void addTriple(ObjectPool objectPool, long[] triple) throws IOException {
-      if (this != currentPhase) {
-        throw new IllegalStateException("Attempt to modify a read-only phase.");
-      }
+    void addTriple(long[] triple) throws IOException {
+      if (this != currentPhase) throw new IllegalStateException("Attempt to modify a read-only phase.");
 
       if (tripleWriteThread != null) tripleWriteThread.drain();
 
       try {
-        syncAddTriple(objectPool, triple);
+        syncAddTriple(triple);
       } finally {
         releaseCache();
       }
@@ -705,16 +691,11 @@
     /**
      * Adds multiple triples to the graph.
      *
-     * @param objectPool The feature to be added to the Triple attribute
      * @param triples The triples to add
      * @throws IOException EXCEPTION TO DO
      */
-    void syncAddTriples(
-        ObjectPool objectPool, long[][] triples
-    ) throws IOException {
-      if (this != currentPhase) {
-        throw new IllegalStateException("Attempt to modify a read-only phase.");
-      }
+    void syncAddTriples(long[][] triples) throws IOException {
+      if (this != currentPhase) throw new IllegalStateException("Attempt to modify a read-only phase.");
 
       Arrays.sort(triples, tripleComparator);
       try {
@@ -724,7 +705,7 @@
 
           // Add the triple to the TripleAVLFile and check that the triple
           // wasn't already there.
-          syncAddTriple(objectPool, triple);
+          syncAddTriple(triple);
         }
       } finally {
         releaseCache();
@@ -737,7 +718,6 @@
         if (cachedNode != null) cachedNode.release();
         if (cachedBlock != null) {
           cachedBlock.write();
-          cachedBlock.release();
         }
       } finally {
         cachedNode = null;
@@ -749,7 +729,6 @@
     private void releaseBlockToCache(Block block) throws IOException {
       if (cachedBlock != null) {
         cachedBlock.write();
-        cachedBlock.release();
       }
       cachedBlock = block;
     }
@@ -776,16 +755,13 @@
     /**
      * Adds a triple to the graph.
      *
-     * @param objectPool The feature to be added to the Triple attribute
      * @param triple The triple to add
      * @throws IOException EXCEPTION TO DO
      */
-    private void syncAddTriple(
-        ObjectPool objectPool, long[] triple
-    ) throws IOException {
+    private void syncAddTriple(long[] triple) throws IOException {
       AVLNode startNode;
       if (cachedNode == null) {
-        startNode = avlFilePhase.getRootNode(objectPool);
+        startNode = avlFilePhase.getRootNode();
       } else {
         startNode = cachedNode;
         cachedNode = null;
@@ -796,8 +772,8 @@
 
       if (findResult == null) {
         // Tree is empty.  Create a node and allocate a triple block.
-        Block newTripleBlock = blockFilePhase.allocateBlock(objectPool);
-        AVLNode newNode = avlFilePhase.newAVLNodeInstance(objectPool);
+        Block newTripleBlock = blockFilePhase.allocateBlock();
+        AVLNode newNode = avlFilePhase.newAVLNodeInstance();
         newNode.putPayloadLong(IDX_LOW_TRIPLE, triple[0]);
         newNode.putPayloadLong(IDX_LOW_TRIPLE + 1, triple[1]);
         newNode.putPayloadLong(IDX_LOW_TRIPLE + 2, triple[2]);
@@ -880,7 +856,7 @@
         long blockId = node.getPayloadLong(IDX_BLOCK_ID);
         tripleBlock = getCachedBlock(blockId);
         if (tripleBlock == null) {
-          tripleBlock = blockFilePhase.readBlock(objectPool, blockId);
+          tripleBlock = blockFilePhase.readBlock(blockId);
         } else {
           // Blocks in the cache are always dirty.
           tripleBlockDirty = true;
@@ -913,8 +889,8 @@
           assert splitPoint > 0 || index == 0;
           assert splitPoint < MAX_TRIPLES || index == MAX_TRIPLES;
 
-          Block newTripleBlock = blockFilePhase.allocateBlock(objectPool);
-          AVLNode newNode = avlFilePhase.newAVLNodeInstance(objectPool);
+          Block newTripleBlock = blockFilePhase.allocateBlock();
+          AVLNode newNode = avlFilePhase.newAVLNodeInstance();
 
           // Low triple.
           if (splitPoint < MAX_TRIPLES) {
@@ -1010,7 +986,6 @@
             nrTriples = MAX_TRIPLES - splitPoint;
             index -= splitPoint;
             if (tripleBlockDirty) tripleBlock.write();
-            tripleBlock.release();
             tripleBlock = newTripleBlock;
             node.write();
             node.release();
@@ -1018,7 +993,6 @@
           } else {
             nrTriples = splitPoint;
             newTripleBlock.write();
-            newTripleBlock.release();
             newNode.write();
             newNode.release();
           }
@@ -1054,7 +1028,6 @@
       } finally {
         if (tripleBlock != null) {
           if (tripleBlockDirty) releaseBlockToCache(tripleBlock);
-          else tripleBlock.release();
         }
         AVLFile.release(findResult);
         releaseNodeToCache(node);
@@ -1079,17 +1052,13 @@
     /**
      * Remove a triple from the graph.
      *
-     * @param objectPool PARAMETER TO DO
      * @param node0 The 0 node of the triple to remove.
      * @param node1 The 1 node of the triple to remove.
      * @param node2 The 2 node of the triple to remove.
      * @param node3 PARAMETER TO DO
      * @throws IOException EXCEPTION TO DO
      */
-    public void removeTriple(
-        ObjectPool objectPool,
-        long node0, long node1, long node2, long node3
-    ) throws IOException {
+    public void removeTriple(long node0, long node1, long node2, long node3) throws IOException {
       if (this != currentPhase) {
         throw new IllegalStateException("Attempt to modify a read-only phase.");
       }
@@ -1098,13 +1067,10 @@
 
       if (tripleWriteThread != null) tripleWriteThread.drain();
 
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
 
       if (findResult == null || findResult.length == 2) {
-        if (findResult != null) {
-          AVLFile.release(findResult);
-        }
+        if (findResult != null) AVLFile.release(findResult);
         // Triple not found
         return;
       }
@@ -1156,18 +1122,12 @@
       }
 
       // Get the triple block.
-      Block tripleBlock = blockFilePhase.readBlock(
-          objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-      );
+      Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
       try {
         // Find the triple.
-        int index = binarySearch(
-            tripleBlock, tripleComparator, 0, nrTriples, triple
-        );
-        if (index < 0) {
-          // Triple not found
-          return;
-        }
+        int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
+        // If triple not found
+        if (index < 0) return;
 
         // Duplicate both the AVLNode and the triple block.
         node.modify();
@@ -1194,40 +1154,31 @@
         decNrTriples();
         return;
       } finally {
-        tripleBlock.release();
         node.release();
       }
     }
 
-    public StoreTuples findTuples(
-        ObjectPool objectPool, long node0
-    ) throws IOException {
+    public StoreTuples findTuples(long node0) throws IOException {
       long[] startTriple = new long[SIZEOF_TRIPLE];
       long[] endTriple = new long[SIZEOF_TRIPLE];
       startTriple[order0] = node0;
       endTriple[order0] = node0 + 1;
-      return new TuplesImpl(objectPool, startTriple, endTriple, 1);
+      return new TuplesImpl(startTriple, endTriple, 1);
     }
 
 
-    public StoreTuples findTuples(
-        ObjectPool objectPool,
-        long node0, long node1
-    ) throws IOException {
+    public StoreTuples findTuples(long node0, long node1) throws IOException {
       long[] startTriple = new long[SIZEOF_TRIPLE];
       long[] endTriple = new long[SIZEOF_TRIPLE];
       startTriple[order0] = node0;
       startTriple[order1] = node1;
       endTriple[order0] = node0;
       endTriple[order1] = node1 + 1;
-      return new TuplesImpl(objectPool, startTriple, endTriple, 2);
+      return new TuplesImpl(startTriple, endTriple, 2);
     }
 
 
-    public StoreTuples findTuples(
-        ObjectPool objectPool,
-        long node0, long node1, long node2
-    ) throws IOException {
+    public StoreTuples findTuples(long node0, long node1, long node2) throws IOException {
       long[] startTriple = new long[SIZEOF_TRIPLE];
       long[] endTriple = new long[SIZEOF_TRIPLE];
       startTriple[order0] = node0;
@@ -1236,79 +1187,57 @@
       endTriple[order0] = node0;
       endTriple[order1] = node1;
       endTriple[order2] = node2 + 1;
-      return new TuplesImpl(objectPool, startTriple, endTriple, 3);
+      return new TuplesImpl(startTriple, endTriple, 3);
     }
 
 
-    public StoreTuples allTuples(ObjectPool objectPool) {
-      return new TuplesImpl(objectPool);
+    public StoreTuples allTuples() {
+      return new TuplesImpl();
     }
 
 
-    public boolean existsTriples(ObjectPool objectPool, long node0)
-         throws IOException {
+    public boolean existsTriples(long node0) throws IOException {
       long[] triple = new long[SIZEOF_TRIPLE];
       triple[order0] = node0;
 
-      if (this == currentPhase && tripleWriteThread != null)
-        tripleWriteThread.drain();
+      if (this == currentPhase && tripleWriteThread != null) tripleWriteThread.drain();
 
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
-      if (findResult == null) {
-        // Triplestore is empty.
-        return false;
-      }
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
+      // If Triplestore is empty.
+      if (findResult == null) return false;
 
       try {
         // Found the node.
         AVLNode node = findResult[findResult.length == 1 ? 0 : 1];
-        if (node == null) {
-          // Triple is less than the minimum or greater than the maximum.
-          return false;
-        }
+        // If Triple is less than the minimum or greater than the maximum.
+        if (node == null) return false;
 
         int nrTriples = node.getPayloadInt(IDX_NR_TRIPLES_I);
-        if (findResult.length == 1 && nrTriples == 1) {
-          // Exact match on a node that only contains one triple.
-          return true;
-        }
+        // If exact match on a node that only contains one triple.
+        if (findResult.length == 1 && nrTriples == 1) return true;
 
         // See if it matches the high or low triple.
-        if (node.getPayloadLong(IDX_LOW_TRIPLE + order0) == node0) {
-          return true;
-        }
-        if (findResult.length == 2) {
-          // This triple's value falls between two nodes.
-          return false;
-        }
-        if (node.getPayloadLong(IDX_HIGH_TRIPLE + order0) == node0) {
-          return true;
-        }
-        if (nrTriples == 2) {
-          // There is no point looking inside the triple block since we have
-          // already checked the only two triples for this node.
-          return false;
-        }
+        if (node.getPayloadLong(IDX_LOW_TRIPLE + order0) == node0) return true;
+        // If this triple's value falls between two nodes.
+        if (findResult.length == 2) return false;
+        if (node.getPayloadLong(IDX_HIGH_TRIPLE + order0) == node0) return true;
 
+        // Check if there is no point looking inside the triple block since we have
+        // already checked the only two triples for this node.
+        if (nrTriples == 2) return false;
+
         // Get the triple block.
-        Block tripleBlock = blockFilePhase.readBlock(
-            objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-        );
+        Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
 
         // Find the triple.
-        int index = binarySearch(
-            tripleBlock, tripleComparator, 0, nrTriples, triple
-        );
+        int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
         boolean exists;
         if (index >= 0) {
           exists = true;
         } else {
           index = -index - 1;
-          exists = index < nrTriples &&
-              tripleBlock.getLong(index * SIZEOF_TRIPLE + order0) == node0;
+          exists = index < nrTriples && tripleBlock.getLong(index * SIZEOF_TRIPLE + order0) == node0;
         }
-        tripleBlock.release();
         return exists;
       } finally {
         AVLFile.release(findResult);
@@ -1316,35 +1245,26 @@
     }
 
 
-    public boolean existsTriples(ObjectPool objectPool, long node0, long node1)
-         throws IOException {
+    public boolean existsTriples(long node0, long node1) throws IOException {
       long[] triple = new long[SIZEOF_TRIPLE];
       triple[order0] = node0;
       triple[order1] = node1;
 
-      if (this == currentPhase && tripleWriteThread != null)
-        tripleWriteThread.drain();
+      if (this == currentPhase && tripleWriteThread != null)tripleWriteThread.drain();
 
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
-      if (findResult == null) {
-        // Triplestore is empty.
-        return false;
-      }
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
+      // If Triplestore is empty.
+      if (findResult == null) return false;
 
       try {
         // Found the node.
         AVLNode node = findResult[findResult.length == 1 ? 0 : 1];
-        if (node == null) {
-          // Triple is less than the minimum or greater than the maximum.
-          return false;
-        }
+        // Check if Triple is less than the minimum or greater than the maximum.
+        if (node == null) return false;
 
         int nrTriples = node.getPayloadInt(IDX_NR_TRIPLES_I);
-        if (nrTriples == 1) {
-          // Exact match on a node that only contains one triple.
-          return true;
-        }
+        // Check if exact match on a node that only contains one triple.
+        if (nrTriples == 1) return true;
 
         // See if it matches the high or low triple.
         if (
@@ -1353,31 +1273,23 @@
         ) {
           return true;
         }
-        if (findResult.length == 2) {
-          // This triple's value falls between two nodes.
-          return false;
-        }
+        // Check if this triple's value falls between two nodes.
+        if (findResult.length == 2) return false;
         if (
             node.getPayloadLong(IDX_HIGH_TRIPLE + order0) == node0 &&
             node.getPayloadLong(IDX_HIGH_TRIPLE + order1) == node1
         ) {
           return true;
         }
-        if (nrTriples == 2) {
-          // There is no point looking inside the triple block since we have
-          // already checked the only two triples for this node.
-          return false;
-        }
+        // Check if there is no point looking inside the triple block since we have
+        // already checked the only two triples for this node.
+        if (nrTriples == 2) return false;
 
         // Get the triple block.
-        Block tripleBlock = blockFilePhase.readBlock(
-            objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-        );
+        Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
 
         // Find the triple.
-        int index = binarySearch(
-            tripleBlock, tripleComparator, 0, nrTriples, triple
-        );
+        int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
         boolean exists;
         if (index >= 0) {
           exists = true;
@@ -1387,7 +1299,6 @@
               tripleBlock.getLong(index * SIZEOF_TRIPLE + order0) == node0 &&
               tripleBlock.getLong(index * SIZEOF_TRIPLE + order1) == node1;
         }
-        tripleBlock.release();
         return exists;
       } finally {
         AVLFile.release(findResult);
@@ -1395,37 +1306,27 @@
     }
 
 
-    public boolean existsTriples(
-        ObjectPool objectPool, long node0, long node1, long node2
-    ) throws IOException {
+    public boolean existsTriples(long node0, long node1, long node2) throws IOException {
       long[] triple = new long[SIZEOF_TRIPLE];
       triple[order0] = node0;
       triple[order1] = node1;
       triple[order2] = node2;
 
-      if (this == currentPhase && tripleWriteThread != null)
-        tripleWriteThread.drain();
+      if (this == currentPhase && tripleWriteThread != null) tripleWriteThread.drain();
 
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
-      if (findResult == null) {
-        // Triplestore is empty.
-        return false;
-      }
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
+      // Check if Triplestore is empty.
+      if (findResult == null) return false;
 
       try {
         // Found the node.
         AVLNode node = findResult[findResult.length == 1 ? 0 : 1];
-        if (node == null) {
-          // Triple is less than the minimum or greater than the maximum.
-          return false;
-        }
+        // Check if Triple is less than the minimum or greater than the maximum.
+        if (node == null) return false;
 
         int nrTriples = node.getPayloadInt(IDX_NR_TRIPLES_I);
-        if (nrTriples == 1) {
-          // Exact match on a node that only contains one triple.
-          return true;
-        }
+        // Check if exact match on a node that only contains one triple.
+        if (nrTriples == 1) return true;
 
         // See if it matches the high or low triple.
         if (
@@ -1435,10 +1336,9 @@
         ) {
           return true;
         }
-        if (findResult.length == 2) {
-          // This triple's value falls between two nodes.
-          return false;
-        }
+        // Check if this triple's value falls between two nodes.
+        if (findResult.length == 2) return false;
+
         if (
             node.getPayloadLong(IDX_HIGH_TRIPLE + order0) == node0 &&
             node.getPayloadLong(IDX_HIGH_TRIPLE + order1) == node1 &&
@@ -1446,21 +1346,14 @@
         ) {
           return true;
         }
-        if (nrTriples == 2) {
-          // There is no point looking inside the triple block since we have
-          // already checked the only two triples for this node.
-          return false;
-        }
-
+        // Check if there is no point looking inside the triple block since we have
+        // already checked the only two triples for this node.
+        if (nrTriples == 2) return false;
         // Get the triple block.
-        Block tripleBlock = blockFilePhase.readBlock(
-            objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-        );
+        Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
 
         // Find the triple.
-        int index = binarySearch(
-            tripleBlock, tripleComparator, 0, nrTriples, triple
-        );
+        int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
         boolean exists;
         if (index >= 0) {
           exists = true;
@@ -1471,24 +1364,22 @@
               tripleBlock.getLong(index * SIZEOF_TRIPLE + order1) == node1 &&
               tripleBlock.getLong(index * SIZEOF_TRIPLE + order2) == node2;
         }
-        tripleBlock.release();
         return exists;
       } finally {
         AVLFile.release(findResult);
       }
+      
     }
 
 
-    public boolean existsTriple(
-        ObjectPool objectPool, long node0, long node1, long node2, long node3
-    ) throws IOException {
+    public boolean existsTriple(long node0, long node1, long node2, long node3) throws IOException {
       long[] triple = new long[SIZEOF_TRIPLE];
       triple[order0] = node0;
       triple[order1] = node1;
       triple[order2] = node2;
       triple[order3] = node3;
 
-      return existsTriple(objectPool, triple);
+      return existsTriple(triple);
     }
 
 
@@ -1501,12 +1392,8 @@
       if (this == currentPhase && tripleWriteThread != null)
         tripleWriteThread.drain();
 
-      ObjectPool objectPool = ObjectPool.newInstance();
-      AVLNode node = avlFilePhase.getRootNode(objectPool);
-      if (node == null) {
-        objectPool.release();
-        return 0;
-      }
+      AVLNode node = avlFilePhase.getRootNode();
+      if (node == null) return 0;
 
       node = node.getMinNode_R();
       long[] prevTriple = new long[] {0, 0, 0, 0};
@@ -1542,9 +1429,7 @@
 
         Block block;
         try {
-          block = blockFilePhase.readBlock(
-              objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-          );
+          block = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
         } catch (IOException ex) {
           throw new Error("I/O Error", ex);
         }
@@ -1577,7 +1462,6 @@
           }
           System.arraycopy(triple, 0, prevTriple, 0, SIZEOF_TRIPLE);
         }
-        block.release();
 
         triple[0] = node.getPayloadLong(IDX_HIGH_TRIPLE);
         triple[1] = node.getPayloadLong(IDX_HIGH_TRIPLE + 1);
@@ -1599,7 +1483,6 @@
         totalNrTriples += nrTriples;
       } while ((node = node.getNextNode_R()) != null);
 
-      objectPool.release();
       if (totalNrTriples != nrFileTriples) {
         throw new Error(
             "nrFileTriples (" + nrFileTriples +
@@ -1630,31 +1513,24 @@
     }
 
 
-    private boolean existsTriple(ObjectPool objectPool, long[] triple)
+    private boolean existsTriple(long[] triple)
          throws IOException {
       if (this == currentPhase && tripleWriteThread != null)
         tripleWriteThread.drain();
 
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
-      if (findResult == null) {
-        // Triplestore is empty.
-        return false;
-      }
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
+      // Check if Triplestore is empty.
+      if (findResult == null) return false;
 
       try {
-        if (findResult.length == 2) {
-          // Triple not found.
-          return false;
-        }
+        // Check if triple not found.
+        if (findResult.length == 2) return false;
 
         // Found the node.
         AVLNode node = findResult[0];
 
         int nrTriples = node.getPayloadInt(IDX_NR_TRIPLES_I);
-        if (nrTriples == 1) {
-          return true;
-        }
+        if (nrTriples == 1) return true;
 
         // See if it matches the high or low triple.
         if (
@@ -1680,15 +1556,10 @@
         }
 
         // Get the triple block.
-        Block tripleBlock = blockFilePhase.readBlock(
-            objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-        );
+        Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
 
         // Find the triple.
-        int index = binarySearch(
-            tripleBlock, tripleComparator, 0, nrTriples, triple
-        );
-        tripleBlock.release();
+        int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
         return index >= 0;
       } finally {
         AVLFile.release(findResult);
@@ -1696,20 +1567,14 @@
     }
 
 
-    private TripleLocation findTriple(ObjectPool objectPool, long[] triple)
-         throws IOException {
-      AVLNode[] findResult =
-          avlFilePhase.find(objectPool, avlComparator, triple);
-      if (findResult == null) {
-        return null;
-      }
+    private TripleLocation findTriple(long[] triple) throws IOException {
+      AVLNode[] findResult = avlFilePhase.find(avlComparator, triple);
+      if (findResult == null) return null;
 
       AVLNode node;
       if (findResult.length == 2) {
         node = findResult[1];
-        if (node != null) {
-          node.incRefCount();
-        }
+        if (node != null) node.incRefCount();
         AVLFile.release(findResult);
         return new TripleLocation(node, 0);
       }
@@ -1751,18 +1616,11 @@
       }
 
       // Get the triple block.
-      Block tripleBlock = blockFilePhase.readBlock(
-          objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-      );
+      Block tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
 
       // Find the triple.
-      int index = binarySearch(
-          tripleBlock, tripleComparator, 0, nrTriples, triple
-      );
-      tripleBlock.release();
-      if (index < 0) {
-        index = -index - 1;
-      }
+      int index = binarySearch(tripleBlock, tripleComparator, 0, nrTriples, triple);
+      if (index < 0) index = -index - 1;
       return new TripleLocation(node, index);
     }
 
@@ -1821,8 +1679,6 @@
 
       private Token token;
 
-      private ObjectPool objectPool;
-
       private long nrTriples;
 
       private boolean nrTriplesValid = false;
@@ -1856,27 +1712,22 @@
       /**
        * CONSTRUCTOR TuplesImpl TO DO
        *
-       * @param objectPool PARAMETER TO DO
        * @param startTriple PARAMETER TO DO
        * @param endTriple PARAMETER TO DO
        * @param prefixLength PARAMETER TO DO
        * @throws IOException EXCEPTION TO DO
        */
       TuplesImpl(
-          ObjectPool objectPool,
           long[] startTriple, long[] endTriple,
           int prefixLength
       ) throws IOException {
         assert prefixLength >= 1 && prefixLength < SIZEOF_TRIPLE;
 
-        if (Phase.this == currentPhase && tripleWriteThread != null)
-          tripleWriteThread.drain();
+        if (Phase.this == currentPhase && tripleWriteThread != null) tripleWriteThread.drain();
 
-        this.objectPool = objectPool;
         this.startTriple = startTriple;
         this.endTriple = endTriple;
         this.prefixLength = prefixLength;
-        objectPool.incRefCount();
 
         int nrColumns = SIZEOF_TRIPLE - prefixLength;
 
@@ -1891,19 +1742,14 @@
           variables[i] = StatementStore.VARIABLES[columnMap[i]];
         }
 
-        start = findTriple(objectPool, startTriple);
-        end = findTriple(objectPool, endTriple);
+        start = findTriple(startTriple);
+        end = findTriple(endTriple);
 
         if (end != null && end.node != null) {
           endBlockId = end.node.getId();
           endOffset = end.offset;
         }
-        if (
-            start != null && start.node != null && (
-                start.node.getId() != endBlockId ||
-                start.offset < endOffset
-            )
-        ) {
+        if (start != null && start.node != null && (start.node.getId() != endBlockId || start.offset < endOffset)) {
           token = use();
           beforeStart = true;
         } else {
@@ -1914,16 +1760,10 @@
 
       /**
        * CONSTRUCTOR TuplesImpl TO DO
-       *
-       * @param objectPool PARAMETER TO DO
        */
-      TuplesImpl(ObjectPool objectPool) {
-        if (Phase.this == currentPhase && tripleWriteThread != null)
-          tripleWriteThread.drain();
+      TuplesImpl() {
+        if (Phase.this == currentPhase && tripleWriteThread != null) tripleWriteThread.drain();
 
-        this.objectPool = objectPool;
-        objectPool.incRefCount();
-
         this.nrTriples = Phase.this.nrFileTriples;
         this.nrTriplesValid = true;
 
@@ -1936,13 +1776,10 @@
         };
 
         startTriple = new long[SIZEOF_TRIPLE];
-        endTriple = new long[] {
-            Constants.MASK63, Constants.MASK63,
-            Constants.MASK63, Constants.MASK63
-        };
+        endTriple = new long[] { Constants.MASK63, Constants.MASK63, Constants.MASK63, Constants.MASK63 };
         prefixLength = 0;
 
-        AVLNode node = avlFilePhase.getRootNode(objectPool);
+        AVLNode node = avlFilePhase.getRootNode();
         if (node != null) {
           start = new TripleLocation(node.getMinNode_R(), 0);
           token = use();
@@ -1965,9 +1802,7 @@
 
       public long getColumnValue(int column) throws TuplesException {
         try {
-          return tripleBlock.getLong(
-              offset * SIZEOF_TRIPLE + columnMap[column]
-          );
+          return tripleBlock.getLong(offset * SIZEOF_TRIPLE + columnMap[column]);
         } catch (ArrayIndexOutOfBoundsException ex) {
           if (column < 0 || column >= variables.length) {
             throw new TuplesException("Column index out of range: " + column);
@@ -1975,8 +1810,7 @@
           throw ex;
         } catch (NullPointerException ex) {
           if (beforeStart || node == null) {
-            throw new TuplesException("No current row.  Before start: " +
-                beforeStart + " node: " + node);
+            throw new TuplesException("No current row.  Before start: " + beforeStart + " node: " + node);
           }
           throw ex;
         }
@@ -1992,14 +1826,10 @@
       }
 
       public long getRowCount() throws TuplesException {
-        if (nrTriplesValid) {
-          return nrTriples;
-        }
+        if (nrTriplesValid)  return nrTriples;
         nrTriplesValid = true;
 
-        if (start == null) {
-          return nrTriples = 0;
-        }
+        if (start == null) return nrTriples = 0;
 
         long n = endOffset - start.offset;
         AVLNode curNode = start.node;
@@ -2021,11 +1851,8 @@
       }
 
 
-      public int getRowCardinality() throws TuplesException
-      {
-        if (rowCardinality != -1) {
-          return rowCardinality;
-        }
+      public int getRowCardinality() throws TuplesException {
+        if (rowCardinality != -1) return rowCardinality;
         Tuples temp = (Tuples)this.clone();
         temp.beforeFirst();
         if (!temp.next()) {
@@ -2044,9 +1871,7 @@
 
       public int getColumnIndex(Variable variable) throws TuplesException {
         for (int i = 0; i < variables.length; ++i) {
-          if (variables[i].equals(variable)) {
-            return i;
-          }
+          if (variables[i].equals(variable)) return i;
         }
 
         throw new TuplesException("variable doesn't match any column");
@@ -2084,45 +1909,33 @@
 
 
       public boolean next() throws TuplesException {
-        if (prefix.length > variables.length) {
-          throw new TuplesException("prefix too long: " + prefix.length);
-        }
+        if (prefix.length > variables.length) throw new TuplesException("prefix too long: " + prefix.length);
 
         // Move to the next row.
         if (!advance()) {
           return false;
         }
-        if (prefix.length == 0) {
-          return true;
-        }
+        if (prefix.length == 0) return true;
 
         // See if the current row matches the prefix.
         RowComparator comparator = getComparator();
         int c = comparator.compare(prefix, this);
-        if (c == 0) {
-          return true;
-        }
+        if (c == 0) return true;
 
         closeIterator();
-        if (c < 0) {
-          return false;
-        }
+        if (c < 0) return false;
 
         // Reorder the prefix to create a triple.
         System.arraycopy(startTriple, 0, tmpTriple, 0, SIZEOF_TRIPLE);
-        for (int i = 0; i < prefix.length; ++i) {
-          tmpTriple[columnMap[i]] = prefix[i];
-        }
+        for (int i = 0; i < prefix.length; ++i) tmpTriple[columnMap[i]] = prefix[i];
 
         // Check if the prefix is past the end triple.
-        if (tripleComparator.compare(tmpTriple, endTriple) >= 0) {
-          return false;
-        }
+        if (tripleComparator.compare(tmpTriple, endTriple) >= 0) return false;
 
         // Locate the first triple greater than or equal to the prefix.
         TripleLocation tLoc;
         try {
-          tLoc = findTriple(objectPool, tmpTriple);
+          tLoc = findTriple(tmpTriple);
         } catch (IOException ex) {
           throw new TuplesException("I/O error", ex);
         }
@@ -2141,14 +1954,9 @@
       }
 
 
-      public void beforeFirst(long[] prefix, int suffixTruncation)
-           throws TuplesException {
-        if (prefix == null) {
-          throw new IllegalArgumentException("Null \"prefix\" parameter");
-        }
-        if (suffixTruncation != 0) {
-          throw new TuplesException("Suffix truncation not implemented");
-        }
+      public void beforeFirst(long[] prefix, int suffixTruncation) throws TuplesException {
+        if (prefix == null) throw new IllegalArgumentException("Null \"prefix\" parameter");
+        if (suffixTruncation != 0) throw new TuplesException("Suffix truncation not implemented");
 
         beforeStart = true;
         this.prefix = prefix;
@@ -2173,20 +1981,13 @@
        */
       public void renameVariables(Constraint constraint) {
         if (logger.isDebugEnabled()) {
-          logger.debug(
-              "Renaming variables.  before: " + Arrays.asList(variables) +
-              " constraint: " + constraint
-          );
+          logger.debug("Renaming variables.  before: " + Arrays.asList(variables) + " constraint: " + constraint);
         }
 
-        for (int i = 0; i < columnMap.length; ++i) {
-          variables[i] = (Variable) constraint.getElement(columnMap[i]);
-        }
+        for (int i = 0; i < columnMap.length; ++i) variables[i] = (Variable) constraint.getElement(columnMap[i]);
 
         if (logger.isDebugEnabled()) {
-          logger.debug(
-              "Renaming variables.  after: " + Arrays.asList(variables)
-          );
+          logger.debug("Renaming variables.  after: " + Arrays.asList(variables));
         }
       }
 
@@ -2204,9 +2005,7 @@
           for (int i = 0; i < variables.length; i++) {
             buffer.append(variables[i]);
 
-            for (int j = 0; j < (6 - variables[i].toString().length()); j++) {
-              buffer.append(" ");
-            }
+            for (int j = 0; j < (6 - variables[i].toString().length()); j++) buffer.append(" ");
 
             buffer.append("  ");
           }
@@ -2228,7 +2027,6 @@
           while (cloned.next()) {
             if (++rowNo > 20) {
               buffer.append("..." + eol);
-
               break;
             }
 
@@ -2262,11 +2060,8 @@
           TuplesImpl copy = (TuplesImpl) super.clone();
           tmpTriple = new long[SIZEOF_TRIPLE];
           if (start != null) {
-            objectPool.incRefCount();
             start.node.incRefCount();
-            if (end.node != null) {
-              end.node.incRefCount();
-            }
+            if (end.node != null) end.node.incRefCount();
             copy.token = use();
             copy.tripleBlock = null;
             copy.node = null;
@@ -2294,24 +2089,16 @@
           token = null;
         }
 
-        if (objectPool != null) {
-          startTriple = null;
-          if (start != null) {
-            if (start.node != null) {
-              start.node.release();
-            }
-            start = null;
-          }
-          endTriple = null;
-          if (end != null) {
-            if (end.node != null) {
-              end.node.release();
-            }
-            end = null;
-          }
-          objectPool.release();
-          objectPool = null;
+        startTriple = null;
+        if (start != null) {
+          if (start.node != null) start.node.release();
+          start = null;
         }
+        endTriple = null;
+        if (end != null) {
+          if (end.node != null) end.node.release();
+          end = null;
+        }
         stack = null;
       }
 
@@ -2333,9 +2120,7 @@
         if (o == null) {
           return false;
         }
-        if (o == this) {
-          return true;
-        }
+        if (o == this) return true;
 
         // Make sure the object is a Tuples.
         Tuples t;
@@ -2348,20 +2133,12 @@
         Tuples t1 = null;
         Tuples t2 = null;
         try {
-          if (getRowCount() != t.getRowCount()) {
-            return false;
-          }
-          if (getRowCount() == 0) {
-            return true;
-          }
+          if (getRowCount() != t.getRowCount()) return false;
+          if (getRowCount() == 0) return true;
 
           // Return false if the column variable names don't match or the number
           // of columns differ.
-          if (!Arrays.asList(getVariables()).equals(
-              Arrays.asList(t.getVariables())
-          )) {
-            return false;
-          }
+          if (!Arrays.asList(getVariables()).equals(Arrays.asList(t.getVariables()))) return false;
 
           // Clone the two Tuples objects.
           t1 = (Tuples) this.clone();
@@ -2373,21 +2150,15 @@
           t1.beforeFirst();
           t2.beforeFirst();
           while (t1.next()) {
-            if (!t2.next() || comp.compare(t1, t2) != 0) {
-              return false;
-            }
+            if (!t2.next() || comp.compare(t1, t2) != 0) return false;
           }
           return !t2.next();
         } catch (TuplesException ex) {
           throw new RuntimeException(ex.toString(), ex);
         } finally {
           try {
-            if (t1 != null) {
-              t1.close();
-            }
-            if (t2 != null) {
-              t2.close();
-            }
+            if (t1 != null) t1.close();
+            if (t2 != null) t2.close();
           } catch (TuplesException ex) {
             throw new RuntimeException(ex.toString(), ex);
           }
@@ -2410,7 +2181,6 @@
         } else if (node != null) {
           if (++offset == nrBlockTriples) {
             offset = 0;
-            tripleBlock.release();
             tripleBlock = null;
             node = node.getNextNode_R();
           }
@@ -2428,10 +2198,7 @@
 
 
       private void closeIterator() {
-        if (tripleBlock != null) {
-          tripleBlock.release();
-          tripleBlock = null;
-        }
+        if (tripleBlock != null) tripleBlock = null;
         if (node != null) {
           node.release();
           node = null;
@@ -2443,9 +2210,7 @@
         if (tripleBlock == null && node != null) {
           nrBlockTriples = node.getPayloadInt(IDX_NR_TRIPLES_I);
           try {
-            tripleBlock = blockFilePhase.readBlock(
-                objectPool, node.getPayloadLong(IDX_BLOCK_ID)
-            );
+            tripleBlock = blockFilePhase.readBlock(node.getPayloadLong(IDX_BLOCK_ID));
           } catch (IOException ex) {
             throw new TuplesException("I/O error", ex);
           }

Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -38,10 +38,8 @@
 
 // Locally written packages
 import org.mulgara.store.*;
-import org.mulgara.store.statement.xa.*;
 import org.mulgara.store.tuples.Tuples;
 import org.mulgara.store.xa.Block;
-import org.mulgara.store.xa.ObjectPool;
 import org.mulgara.util.Constants;
 import org.mulgara.util.TempDir;
 
@@ -76,10 +74,7 @@
   /**
    * Description of the Field
    */
-  private static Block metaroot = Block.newInstance(
-      ObjectPool.newInstance(),
-      TripleAVLFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG
-      );
+  private static Block metaroot = Block.newInstance(TripleAVLFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
 
   /**
    * Description of the Field
@@ -87,12 +82,6 @@
   private TripleAVLFile tripleAVLFile;
 
   /**
-   * Description of the Field
-   */
-  private ObjectPool objectPool = null;
-
-
-  /**
    * Named constructor.
    *
    * @param name The name of the test.
@@ -141,9 +130,8 @@
   public void setUp() throws IOException {
     boolean exceptionOccurred = true;
     try {
-      objectPool = ObjectPool.newInstance();
       tripleAVLFile = new TripleAVLFile(
-          objectPool, new File(TempDir.getTempDir(), "tavlftest"),
+          new File(TempDir.getTempDir(), "tavlftest"),
           new int[] {0, 1, 2, 3}
       );
       exceptionOccurred = false;
@@ -163,14 +151,8 @@
   public void tearDown() throws IOException {
     if (tripleAVLFile != null) {
       try {
-        if (objectPool != null) {
-          objectPool.release();
-          objectPool = null;
-        }
-
         tripleAVLFile.close();
-      }
-      finally {
+      } finally {
         tripleAVLFile = null;
       }
     }
@@ -188,10 +170,10 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
     tripleAVLFile.new Phase(phase0);
     token0.release();
@@ -209,13 +191,13 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    assertTrue("Found node in empty tree", !phase1.existsTriple(objectPool, 1, 2, 4, 2));
+    assertTrue("Found node in empty tree", !phase1.existsTriple(1, 2, 4, 2));
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
 
-    assertTrue("Node missing from tree", phase1.existsTriple(objectPool, 1, 2, 4, 2));
+    assertTrue("Node missing from tree", phase1.existsTriple(1, 2, 4, 2));
 
     tripleAVLFile.new Phase(phase0);
     token0.release();
@@ -233,39 +215,39 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.removeTriple(objectPool, 1, 2, 3, 1);
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.removeTriple(1, 2, 3, 1);
+    assertTrue(!phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.removeTriple(objectPool, 1, 2, 4, 2);
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.removeTriple(1, 2, 4, 2);
+    assertTrue(!phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(!phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.removeTriple(objectPool, 2, 5, 6, 3);
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(!phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.removeTriple(2, 5, 6, 3);
+    assertTrue(!phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(!phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(!phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.removeTriple(objectPool, 3, 2, 3, 4);
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(!phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(!phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.removeTriple(3, 2, 3, 4);
+    assertTrue(!phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(!phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(!phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(!phase1.existsTriple(3, 2, 3, 4));
 
     tripleAVLFile.new Phase(phase0);
     token0.release();
@@ -283,27 +265,27 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.removeTriple(objectPool, 1, 2, 3, 1);
-    assertTrue(!phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.removeTriple(1, 2, 3, 1);
+    assertTrue(!phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    phase1.addTriple(1, 2, 3, 1);
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
     // set up for testPersist()
     phase1.writeToBlock(metaroot, 0);
@@ -322,10 +304,10 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
     tripleAVLFile.new Phase(phase0);
     token0.release();
@@ -343,45 +325,45 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
     TripleAVLFile.Phase.Token token1 = phase1.use();
     TripleAVLFile.Phase phase2 = tripleAVLFile.new Phase();
 
-    phase2.removeTriple(objectPool, 1, 2, 3, 1);
-    assertTrue(!phase2.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase2.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase2.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase2.existsTriple(objectPool, 3, 2, 3, 4));
+    phase2.removeTriple(1, 2, 3, 1);
+    assertTrue(!phase2.existsTriple(1, 2, 3, 1));
+    assertTrue(phase2.existsTriple(1, 2, 4, 2));
+    assertTrue(phase2.existsTriple(2, 5, 6, 3));
+    assertTrue(phase2.existsTriple(3, 2, 3, 4));
 
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase1.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase1.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase1.existsTriple(objectPool, 3, 2, 3, 4));
+    assertTrue(phase1.existsTriple(1, 2, 3, 1));
+    assertTrue(phase1.existsTriple(1, 2, 4, 2));
+    assertTrue(phase1.existsTriple(2, 5, 6, 3));
+    assertTrue(phase1.existsTriple(3, 2, 3, 4));
 
-    phase2.addTriple(objectPool, 1, 2, 3, 1);
-    assertTrue(phase2.existsTriple(objectPool, 1, 2, 3, 1));
-    assertTrue(phase2.existsTriple(objectPool, 1, 2, 4, 2));
-    assertTrue(phase2.existsTriple(objectPool, 2, 5, 6, 3));
-    assertTrue(phase2.existsTriple(objectPool, 3, 2, 3, 4));
+    phase2.addTriple(1, 2, 3, 1);
+    assertTrue(phase2.existsTriple(1, 2, 3, 1));
+    assertTrue(phase2.existsTriple(1, 2, 4, 2));
+    assertTrue(phase2.existsTriple(2, 5, 6, 3));
+    assertTrue(phase2.existsTriple(3, 2, 3, 4));
 
     try {
-      phase1.removeTriple(objectPool, 1, 2, 3, 1);
+      phase1.removeTriple(1, 2, 3, 1);
       fail("Able to remove from a read-only phase");
     } catch (IllegalStateException ex) {
       // NO-OP
     }
 
     try {
-      phase1.addTriple(objectPool, 4, 2, 3, 6);
+      phase1.addTriple(4, 2, 3, 6);
       fail("Able to insert into a read-only phase");
     } catch (IllegalStateException ex) {
       // NO-OP
@@ -404,12 +386,12 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    Tuples tuples = phase1.findTuples(objectPool, 1);
+    Tuples tuples = phase1.findTuples(1);
     tuples.close();
 
     tripleAVLFile.new Phase(phase0);
@@ -428,12 +410,12 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    Tuples tuples = phase1.findTuples(objectPool, 1);
+    Tuples tuples = phase1.findTuples(1);
 
     // move to the first triple
     tuples.beforeFirst();
@@ -475,11 +457,11 @@
 
     for (int i = 1; i < 5; i++) {
       for (int j = 1; j <= 500; j++) {
-        phase1.addTriple(objectPool, i, j, 7, 6);
+        phase1.addTriple(i, j, 7, 6);
       }
     }
 
-    Tuples tuples = phase1.findTuples(objectPool, 3);
+    Tuples tuples = phase1.findTuples(3);
 
     tuples.beforeFirst();
     for (int j = 1; j <= 500; j++) {
@@ -510,15 +492,15 @@
     TripleAVLFile.Phase.Token token0 = phase0.use();
     TripleAVLFile.Phase phase1 = tripleAVLFile.new Phase();
 
-    phase1.addTriple(objectPool, 1, 2, 3, 1);
-    phase1.addTriple(objectPool, 1, 2, 4, 2);
-    phase1.addTriple(objectPool, 2, 5, 6, 3);
-    phase1.addTriple(objectPool, 2, 6, 7, 3);
-    phase1.addTriple(objectPool, 2, 6, 8, 3);
-    phase1.addTriple(objectPool, 2, 7, 9, 3);
-    phase1.addTriple(objectPool, 3, 2, 3, 4);
+    phase1.addTriple(1, 2, 3, 1);
+    phase1.addTriple(1, 2, 4, 2);
+    phase1.addTriple(2, 5, 6, 3);
+    phase1.addTriple(2, 6, 7, 3);
+    phase1.addTriple(2, 6, 8, 3);
+    phase1.addTriple(2, 7, 9, 3);
+    phase1.addTriple(3, 2, 3, 4);
 
-    Tuples tuples = phase1.findTuples(objectPool, 2);
+    Tuples tuples = phase1.findTuples(2);
 
     // move to the first triple
     tuples.beforeFirst(new long[]{6}, 0);

Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -35,7 +35,6 @@
 
 // Locally written packages
 import org.mulgara.store.statement.*;
-import org.mulgara.store.xa.ObjectPool;
 
 final class TripleWriteThread extends Thread {
 
@@ -48,8 +47,6 @@
 
   private static final int QUEUE_MAX_BUFFERS = 10;
 
-  private ObjectPool objectPool = ObjectPool.newInstance();
-
   /** The current phase of the TripleAVLFile. */
   private TripleAVLFile.Phase phase;
 
@@ -155,7 +152,7 @@
         }
 
         try {
-          phase.syncAddTriples(objectPool, buffer);
+          phase.syncAddTriples(buffer);
         } catch (Throwable t) {
           reportException(t);
         } finally {
@@ -168,8 +165,6 @@
       logger.error("Unhandled exception in " + getName(), t);
     }
 
-    objectPool.release();
-
     synchronized (this) {
       threadRunning = false;
       notifyAll();

Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -46,7 +46,6 @@
 import org.mulgara.store.xa.Block;
 import org.mulgara.store.xa.BlockFile;
 import org.mulgara.store.xa.LockFile;
-import org.mulgara.store.xa.ObjectPool;
 import org.mulgara.store.xa.PersistableMetaRoot;
 import org.mulgara.store.xa.SimpleXAResourceException;
 import org.mulgara.store.xa.XAStatementStore;
@@ -227,11 +226,6 @@
   private String fileName;
 
   /**
-   * Description of the Field
-   */
-  private ObjectPool objectPool;
-
-  /**
    * The LockFile that protects the graph from being opened twice.
    */
   private LockFile lockFile;
@@ -315,8 +309,6 @@
 
     lockFile = LockFile.createLockFile(fileName + ".g.lock");
 
-    objectPool = ObjectPool.newInstance();
-
     try {
       // Check that the metaroot file was created with a compatible version
       // of the triplestore.
@@ -345,8 +337,7 @@
 
       for (int i = 0; i < NR_INDEXES; ++i) {
         tripleAVLFiles[i] = new TripleAVLFile(
-            objectPool, fileName + ".g_" +
-                orders[i][0] + orders[i][1] + orders[i][2] + orders[i][3],
+            fileName + ".g_" + orders[i][0] + orders[i][1] + orders[i][2] + orders[i][3],
             orders[i]
         );
       }
@@ -481,9 +472,7 @@
       currentPhase.removeTriple(node0, node1, node2, node3);
     } else {
       // Find all the tuples matching the specification and remove them.
-      StoreTuples tuples = currentPhase.findTuples(
-          objectPool, node0, node1, node2, node3
-      );
+      StoreTuples tuples = currentPhase.findTuples(node0, node1, node2, node3);
       try {
         try {
           if (!tuples.isEmpty()) {
@@ -537,7 +526,7 @@
   ) throws StatementStoreException {
     checkInitialized();
     dirty = false;
-    return currentPhase.findTuples(objectPool, node0, node1, node2, node3);
+    return currentPhase.findTuples(node0, node1, node2, node3);
   }
 
   
@@ -559,7 +548,7 @@
     checkInitialized();
     dirty = false;
     if (!checkMask(mask, node0, node1, node2, node3)) throw new StatementStoreException("Bad explicit index selection for given node pattern.");
-    return currentPhase.findTuples(objectPool, mask, node0, node1, node2, node3);
+    return currentPhase.findTuples(mask, node0, node1, node2, node3);
   }
 
   /**
@@ -598,9 +587,7 @@
   ) throws StatementStoreException {
     checkInitialized();
     dirty = false;
-    return currentPhase.findTuples(
-        objectPool, node0Bound, node1Bound, node2Bound, node3Bound
-    );
+    return currentPhase.findTuples(node0Bound, node1Bound, node2Bound, node3Bound);
   }
 
 
@@ -619,7 +606,7 @@
       long node0, long node1, long node2, long node3
   ) throws StatementStoreException {
     checkInitialized();
-    return currentPhase.existsTriples(objectPool, node0, node1, node2, node3);
+    return currentPhase.existsTriples(node0, node1, node2, node3);
   }
 
 
@@ -656,11 +643,6 @@
           }
         }
 
-        if (objectPool != null) {
-          objectPool.release();
-          objectPool = null;
-        }
-
         if (metarootFile != null) {
           try {
             metarootFile.close();
@@ -698,19 +680,12 @@
 
         for (int i = 0; i < NR_INDEXES; ++i) {
           try {
-            if (tripleAVLFiles[i] != null) {
-              tripleAVLFiles[i].delete();
-            }
+            if (tripleAVLFiles[i] != null) tripleAVLFiles[i].delete();
           } catch (IOException ex) {
             savedEx = ex;
           }
         }
 
-        if (objectPool != null) {
-          objectPool.release();
-          objectPool = null;
-        }
-
         if (metarootFile != null) {
           try {
             metarootFile.delete();
@@ -837,7 +812,6 @@
       logger.debug("Prepare " + this.getClass() + ":" + System.identityHashCode(this));
     }
     checkInitialized();
-    objectPool.flush();
 
     if (prepared) {
       // prepare already performed.
@@ -1149,14 +1123,8 @@
     }
 
     if (metarootFile != null) {
-      if (metarootBlocks[0] != null) {
-        metarootBlocks[0].release();
-        metarootBlocks[0] = null;
-      }
-      if (metarootBlocks[1] != null) {
-        metarootBlocks[1].release();
-        metarootBlocks[1] = null;
-      }
+      if (metarootBlocks[0] != null) metarootBlocks[0] = null;
+      if (metarootBlocks[1] != null) metarootBlocks[1] = null;
       metarootFile.unmap();
     }
   }
@@ -1221,8 +1189,8 @@
         metarootFile.setNrBlocks(NR_METAROOTS);
       }
 
-      metarootBlocks[0] = metarootFile.readBlock(objectPool, 0);
-      metarootBlocks[1] = metarootFile.readBlock(objectPool, 1);
+      metarootBlocks[0] = metarootFile.readBlock(0);
+      metarootBlocks[1] = metarootFile.readBlock(1);
     }
 
     if (clear) {
@@ -1259,18 +1227,14 @@
 
     private Phase.Token token = null;
 
-    private ObjectPool objectPool = null;
 
-
     /**
      * CONSTRUCTOR ReadOnlyGraph TO DO
      */
     ReadOnlyGraph() {
       synchronized (committedPhaseLock) {
         if (committedPhaseToken == null) {
-          throw new IllegalStateException(
-              "Cannot create read only view of uninitialized Graph."
-          );
+          throw new IllegalStateException("Cannot create read only view of uninitialized Graph.");
         }
       }
     }
@@ -1340,7 +1304,7 @@
     public synchronized StoreTuples findTuples(
         long node0, long node1, long node2, long node3
     ) throws StatementStoreException {
-      return phase.findTuples(objectPool, node0, node1, node2, node3);
+      return phase.findTuples(node0, node1, node2, node3);
     }
 
     /**
@@ -1359,7 +1323,7 @@
         int mask, long node0, long node1, long node2, long node3
     ) throws StatementStoreException {
       if (!checkMask(mask, node0, node1, node2, node3)) throw new StatementStoreException("Bad explicit index selection for given node pattern.");
-      return phase.findTuples(objectPool, mask, node0, node1, node2, node3);
+      return phase.findTuples(mask, node0, node1, node2, node3);
     }
 
 
@@ -1380,16 +1344,14 @@
         boolean node0Bound, boolean node1Bound, boolean node2Bound,
         boolean node3Bound
     ) throws StatementStoreException {
-      return phase.findTuples(
-          objectPool, node0Bound, node1Bound, node2Bound, node3Bound
-      );
+      return phase.findTuples(node0Bound, node1Bound, node2Bound, node3Bound);
     }
 
 
     public synchronized boolean existsTriples(
         long node0, long node1, long node2, long node3
     ) throws StatementStoreException {
-      return phase.existsTriples(objectPool, node0, node1, node2, node3);
+      return phase.existsTriples(node0, node1, node2, node3);
     }
 
 
@@ -1404,9 +1366,7 @@
 
 
     public void close() {
-      throw new UnsupportedOperationException(
-          "Trying to close a read-only graph."
-      );
+      throw new UnsupportedOperationException("Trying to close a read-only graph.");
     }
 
 
@@ -1425,17 +1385,10 @@
         logger.debug("Releasing " + this.getClass() + ":" + System.identityHashCode(this));
       }
       try {
-        if (token != null) {
-          token.release();
-        }
-        if (objectPool != null) {
-          objectPool.flush();
-          objectPool.release();
-        }
+        if (token != null) token.release();
       } finally {
         phase = null;
         token = null;
-        objectPool = null;
       }
     }
 
@@ -1444,16 +1397,11 @@
       if (logger.isDebugEnabled()) {
         logger.debug("Refreshing " + this.getClass() + ":" + System.identityHashCode(this));
       }
-      if (objectPool == null) {
-        objectPool = ObjectPool.newInstance();
-      }
 
       synchronized (committedPhaseLock) {
         Phase committedPhase = committedPhaseToken.getPhase();
         if (phase != committedPhase) {
-          if (token != null) {
-            token.release();
-          }
+          if (token != null) token.release();
           phase = committedPhase;
           token = phase.use();
         }
@@ -1591,26 +1539,21 @@
 
 
     public String toString() {
-      ObjectPool objectPool = ObjectPool.newInstance();
-      try {
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < NR_INDEXES; ++i) {
-          StoreTuples ts = tripleAVLFilePhases[i].allTuples(objectPool);
+      StringBuffer sb = new StringBuffer();
+      for (int i = 0; i < NR_INDEXES; ++i) {
+        StoreTuples ts = tripleAVLFilePhases[i].allTuples();
+        try {
+          sb.append(ts).append('\n');
+        } finally {
           try {
-            sb.append(ts).append('\n');
-          } finally {
-            try {
-              ts.close();
-            } catch (TuplesException ex) {
-              logger.warn("TuplesException while closing Tuples", ex);
-              return ex.toString();
-            }
+            ts.close();
+          } catch (TuplesException ex) {
+            logger.warn("TuplesException while closing Tuples", ex);
+            return ex.toString();
           }
         }
-        return sb.toString();
-      } finally {
-        objectPool.release();
       }
+      return sb.toString();
     }
 
 
@@ -1692,9 +1635,7 @@
 
       try {
         for (int i = 0; i < NR_INDEXES; ++i) {
-          tripleAVLFilePhases[i].removeTriple(
-              objectPool, node0, node1, node2, node3
-          );
+          tripleAVLFilePhases[i].removeTriple(node0, node1, node2, node3);
         }
 
         if (RELEASE_NODE_LISTENERS_ENABLED) {
@@ -1704,10 +1645,10 @@
           // on every removeTriple.
 
           if (
-              !tripleAVLFilePhases[TI_0123].existsTriples(objectPool, node0) &&
-              !tripleAVLFilePhases[TI_1203].existsTriples(objectPool, node0) &&
-              !tripleAVLFilePhases[TI_2013].existsTriples(objectPool, node0) &&
-              !tripleAVLFilePhases[TI_3012].existsTriples(objectPool, node0)
+              !tripleAVLFilePhases[TI_0123].existsTriples(node0) &&
+              !tripleAVLFilePhases[TI_1203].existsTriples(node0) &&
+              !tripleAVLFilePhases[TI_2013].existsTriples(node0) &&
+              !tripleAVLFilePhases[TI_3012].existsTriples(node0)
           ) {
             try {
               notifyReleaseNodeListeners(node0);
@@ -1720,10 +1661,10 @@
 
           if (node1 != node0) {
             if (
-                !tripleAVLFilePhases[TI_0123].existsTriples(objectPool, node1) &&
-                !tripleAVLFilePhases[TI_1203].existsTriples(objectPool, node1) &&
-                !tripleAVLFilePhases[TI_2013].existsTriples(objectPool, node1) &&
-                !tripleAVLFilePhases[TI_3012].existsTriples(objectPool, node1)
+                !tripleAVLFilePhases[TI_0123].existsTriples(node1) &&
+                !tripleAVLFilePhases[TI_1203].existsTriples(node1) &&
+                !tripleAVLFilePhases[TI_2013].existsTriples(node1) &&
+                !tripleAVLFilePhases[TI_3012].existsTriples(node1)
             ) {
               try {
                 notifyReleaseNodeListeners(node1);
@@ -1737,10 +1678,10 @@
 
           if (node2 != node0 && node2 != node1) {
             if (
-                !tripleAVLFilePhases[TI_0123].existsTriples(objectPool, node2) &&
-                !tripleAVLFilePhases[TI_1203].existsTriples(objectPool, node2) &&
-                !tripleAVLFilePhases[TI_2013].existsTriples(objectPool, node2) &&
-                !tripleAVLFilePhases[TI_3012].existsTriples(objectPool, node2)
+                !tripleAVLFilePhases[TI_0123].existsTriples(node2) &&
+                !tripleAVLFilePhases[TI_1203].existsTriples(node2) &&
+                !tripleAVLFilePhases[TI_2013].existsTriples(node2) &&
+                !tripleAVLFilePhases[TI_3012].existsTriples(node2)
             ) {
               try {
                 notifyReleaseNodeListeners(node2);
@@ -1754,10 +1695,10 @@
 
           if (node3 != node0 && node3 != node1 && node3 != node2) {
             if (
-                !tripleAVLFilePhases[TI_0123].existsTriples(objectPool, node3) &&
-                !tripleAVLFilePhases[TI_1203].existsTriples(objectPool, node3) &&
-                !tripleAVLFilePhases[TI_2013].existsTriples(objectPool, node3) &&
-                !tripleAVLFilePhases[TI_3012].existsTriples(objectPool, node3)
+                !tripleAVLFilePhases[TI_0123].existsTriples(node3) &&
+                !tripleAVLFilePhases[TI_1203].existsTriples(node3) &&
+                !tripleAVLFilePhases[TI_2013].existsTriples(node3) &&
+                !tripleAVLFilePhases[TI_3012].existsTriples(node3)
             ) {
               try {
                 notifyReleaseNodeListeners(node3);
@@ -1777,7 +1718,6 @@
     /**
      * Finds triples matching the given specification.
      *
-     * @param objectPool PARAMETER TO DO
      * @param variableMask the mask used to indicate the desired index.
      * @param node0 The 0 node of the triple to find.
      * @param node1 The 1 node of the triple to find.
@@ -1786,10 +1726,7 @@
      * @return A StoreTuples containing all the triples which match the search.
      * @throws StatementStoreException EXCEPTION TO DO
      */
-    StoreTuples findTuples(
-        ObjectPool objectPool, int variableMask,
-        long node0, long node1, long node2, long node3
-    ) throws StatementStoreException {
+    StoreTuples findTuples(int variableMask, long node0, long node1, long node2, long node3) throws StatementStoreException {
       if (
           node0 < NodePool.NONE ||
           node1 < NodePool.NONE ||
@@ -1804,21 +1741,21 @@
       try {
         switch (variableMask) {
           case MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3012].findTuples(node3);
           case MASK0 | MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3012].findTuples(node3);
           case MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3120].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3120].findTuples(node3);
           case MASK0 | MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3012].findTuples(node3);
           case MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3201].findTuples(node3);
           case MASK0 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3201].findTuples(node3);
           case MASK1 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3120].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3120].findTuples(node3);
           case MASK0 | MASK1 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3012].findTuples(node3);
           default:
             throw new AssertionError();
         }
@@ -1830,7 +1767,6 @@
     /**
      * Finds triples matching the given specification.
      *
-     * @param objectPool PARAMETER TO DO
      * @param node0 The 0 node of the triple to find.
      * @param node1 The 1 node of the triple to find.
      * @param node2 The 2 node of the triple to find.
@@ -1838,10 +1774,7 @@
      * @return A StoreTuples containing all the triples which match the search.
      * @throws StatementStoreException EXCEPTION TO DO
      */
-    StoreTuples findTuples(
-        ObjectPool objectPool,
-        long node0, long node1, long node2, long node3
-    ) throws StatementStoreException {
+    StoreTuples findTuples(long node0, long node1, long node2, long node3) throws StatementStoreException {
       if (
           node0 < NodePool.NONE ||
           node1 < NodePool.NONE ||
@@ -1861,67 +1794,37 @@
       try {
         switch (variableMask) {
           case 0:
-            return tripleAVLFilePhases[TI_0123].allTuples(objectPool);
+            return tripleAVLFilePhases[TI_0123].allTuples();
           case MASK0:
-            return tripleAVLFilePhases[TI_0123].findTuples(
-                objectPool, node0
-            );
+            return tripleAVLFilePhases[TI_0123].findTuples(node0);
           case MASK1:
-            return tripleAVLFilePhases[TI_1203].findTuples(
-                objectPool, node1
-            );
+            return tripleAVLFilePhases[TI_1203].findTuples(node1);
           case MASK0 | MASK1:
-            return tripleAVLFilePhases[TI_0123].findTuples(
-                objectPool, node0, node1
-            );
+            return tripleAVLFilePhases[TI_0123].findTuples(node0, node1);
           case MASK2:
-            return tripleAVLFilePhases[TI_2013].findTuples(
-                objectPool, node2
-            );
+            return tripleAVLFilePhases[TI_2013].findTuples(node2);
           case MASK0 | MASK2:
-            return tripleAVLFilePhases[TI_2013].findTuples(
-                objectPool, node2, node0
-            );
+            return tripleAVLFilePhases[TI_2013].findTuples(node2, node0);
           case MASK1 | MASK2:
-            return tripleAVLFilePhases[TI_1203].findTuples(
-                objectPool, node1, node2
-            );
+            return tripleAVLFilePhases[TI_1203].findTuples(node1, node2);
           case MASK0 | MASK1 | MASK2:
-            return tripleAVLFilePhases[TI_0123].findTuples(
-                objectPool, node0, node1, node2
-            );
+            return tripleAVLFilePhases[TI_0123].findTuples(node0, node1, node2);
           case MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(
-                objectPool, node3
-            );
+            return tripleAVLFilePhases[TI_3012].findTuples(node3);
           case MASK0 | MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(
-                objectPool, node3, node0
-            );
+            return tripleAVLFilePhases[TI_3012].findTuples(node3, node0);
           case MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3120].findTuples(
-                objectPool, node3, node1
-            );
+            return tripleAVLFilePhases[TI_3120].findTuples(node3, node1);
           case MASK0 | MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3012].findTuples(
-                objectPool, node3, node0, node1
-            );
+            return tripleAVLFilePhases[TI_3012].findTuples(node3, node0, node1);
           case MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].findTuples(
-                objectPool, node3, node2
-            );
+            return tripleAVLFilePhases[TI_3201].findTuples(node3, node2);
           case MASK0 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].findTuples(
-                objectPool, node3, node2, node0
-            );
+            return tripleAVLFilePhases[TI_3201].findTuples(node3, node2, node0);
           case MASK1 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3120].findTuples(
-                objectPool, node3, node1, node2
-            );
+            return tripleAVLFilePhases[TI_3120].findTuples(node3, node1, node2);
           case MASK0 | MASK1 | MASK2 | MASK3:
-            if (tripleAVLFilePhases[TI_0123].existsTriple(
-                objectPool, node0, node1, node2, node3
-            )) {
+            if (tripleAVLFilePhases[TI_0123].existsTriple(node0, node1, node2, node3)) {
               return TuplesOperations.unconstrained();
             }
             return TuplesOperations.empty();
@@ -1935,7 +1838,7 @@
 
 
     StoreTuples findTuples(
-        ObjectPool objectPool, boolean node0Bound, boolean node1Bound,
+        boolean node0Bound, boolean node1Bound,
         boolean node2Bound, boolean node3Bound
     ) throws StatementStoreException {
       int variableMask =
@@ -1944,15 +1847,11 @@
           (node2Bound ? MASK2 : 0) |
           (node3Bound ? MASK3 : 0);
 
-      return tripleAVLFilePhases[selectIndex[variableMask]].allTuples(
-          objectPool
-      );
+      return tripleAVLFilePhases[selectIndex[variableMask]].allTuples();
     }
 
 
-    boolean existsTriples(
-        ObjectPool objectPool, long node0, long node1, long node2, long node3
-    ) throws StatementStoreException {
+    boolean existsTriples(long node0, long node1, long node2, long node3) throws StatementStoreException {
       if (
           node0 < NodePool.NONE ||
           node1 < NodePool.NONE ||
@@ -1974,57 +1873,35 @@
           case 0:
             return !tripleAVLFilePhases[TI_0123].isEmpty();
           case MASK0:
-            return tripleAVLFilePhases[TI_0123].existsTriples(objectPool, node0);
+            return tripleAVLFilePhases[TI_0123].existsTriples(node0);
           case MASK1:
-            return tripleAVLFilePhases[TI_1203].existsTriples(objectPool, node1);
+            return tripleAVLFilePhases[TI_1203].existsTriples(node1);
           case MASK0 | MASK1:
-            return tripleAVLFilePhases[TI_0123].existsTriples(
-                objectPool, node0, node1
-            );
+            return tripleAVLFilePhases[TI_0123].existsTriples(node0, node1);
           case MASK2:
-            return tripleAVLFilePhases[TI_2013].existsTriples(objectPool, node2);
+            return tripleAVLFilePhases[TI_2013].existsTriples(node2);
           case MASK0 | MASK2:
-            return tripleAVLFilePhases[TI_2013].existsTriples(
-                objectPool, node2, node0
-            );
+            return tripleAVLFilePhases[TI_2013].existsTriples(node2, node0);
           case MASK1 | MASK2:
-            return tripleAVLFilePhases[TI_1203].existsTriples(
-                objectPool, node1, node2
-            );
+            return tripleAVLFilePhases[TI_1203].existsTriples(node1, node2);
           case MASK0 | MASK1 | MASK2:
-            return tripleAVLFilePhases[TI_0123].existsTriples(
-                objectPool, node0, node1, node2
-            );
+            return tripleAVLFilePhases[TI_0123].existsTriples(node0, node1, node2);
           case MASK3:
-            return tripleAVLFilePhases[TI_3012].existsTriples(objectPool, node3);
+            return tripleAVLFilePhases[TI_3012].existsTriples(node3);
           case MASK0 | MASK3:
-            return tripleAVLFilePhases[TI_3012].existsTriples(
-                objectPool, node3, node0
-            );
+            return tripleAVLFilePhases[TI_3012].existsTriples(node3, node0);
           case MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3120].existsTriples(
-                objectPool, node3, node1
-            );
+            return tripleAVLFilePhases[TI_3120].existsTriples(node3, node1);
           case MASK0 | MASK1 | MASK3:
-            return tripleAVLFilePhases[TI_3012].existsTriples(
-                objectPool, node3, node0, node1
-            );
+            return tripleAVLFilePhases[TI_3012].existsTriples(node3, node0, node1);
           case MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].existsTriples(
-                objectPool, node3, node2
-            );
+            return tripleAVLFilePhases[TI_3201].existsTriples(node3, node2);
           case MASK0 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3201].existsTriples(
-                objectPool, node3, node2, node0
-            );
+            return tripleAVLFilePhases[TI_3201].existsTriples(node3, node2, node0);
           case MASK1 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_3120].existsTriples(
-                objectPool, node3, node1, node2
-            );
+            return tripleAVLFilePhases[TI_3120].existsTriples(node3, node1, node2);
           case MASK0 | MASK1 | MASK2 | MASK3:
-            return tripleAVLFilePhases[TI_0123].existsTriple(
-                objectPool, node0, node1, node2, node3
-            );
+            return tripleAVLFilePhases[TI_0123].existsTriple(node0, node1, node2, node3);
           default:
             throw new AssertionError();
         }
@@ -2043,12 +1920,8 @@
 
       for (int i = 1; i < NR_INDEXES; ++i) {
         if (nrTriples[0] != nrTriples[i]) {
-          StringBuffer sb = new StringBuffer(
-              "tripleAVLFiles disagree on the number of triples:"
-          );
-          for (int j = 0; j < NR_INDEXES; ++j) {
-            sb.append(' ').append(nrTriples[j]);
-          }
+          StringBuffer sb = new StringBuffer("tripleAVLFiles disagree on the number of triples:");
+          for (int j = 0; j < NR_INDEXES; ++j) sb.append(' ').append(nrTriples[j]);
           throw new RuntimeException(sb.toString());
         }
       }
@@ -2064,8 +1937,7 @@
 
     final class Token {
 
-      private TripleAVLFile.Phase.Token[] tripleAVLFileTokens =
-          new TripleAVLFile.Phase.Token[NR_INDEXES];
+      private TripleAVLFile.Phase.Token[] tripleAVLFileTokens = new TripleAVLFile.Phase.Token[NR_INDEXES];
 
       private Phase phase = Phase.this;
 
@@ -2074,9 +1946,7 @@
        * CONSTRUCTOR Token TO DO
        */
       Token() {
-        for (int i = 0; i < NR_INDEXES; ++i) {
-          tripleAVLFileTokens[i] = tripleAVLFilePhases[i].use();
-        }
+        for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFileTokens[i] = tripleAVLFilePhases[i].use();
       }
 
 
@@ -2088,9 +1958,7 @@
 
       public void release() {
         assert tripleAVLFileTokens != null : "Invalid Token";
-        for (int i = 0; i < NR_INDEXES; ++i) {
-          tripleAVLFileTokens[i].release();
-        }
+        for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFileTokens[i].release();
         tripleAVLFileTokens = null;
         phase = null;
       }

Modified: trunk/src/jar/store-nodepool-xa/java/org/mulgara/store/nodepool/xa/XANodePoolImpl.java
===================================================================
--- trunk/src/jar/store-nodepool-xa/java/org/mulgara/store/nodepool/xa/XANodePoolImpl.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/store-nodepool-xa/java/org/mulgara/store/nodepool/xa/XANodePoolImpl.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -122,11 +122,6 @@
   private String fileName;
 
   /**
-   * Description of the Field
-   */
-  private ObjectPool objectPool;
-
-  /**
    * The LockFile that protects the node pool from being opened twice.
    */
   private LockFile lockFile;
@@ -189,7 +184,7 @@
   /**
    * Description of the Field
    */
-  private Set newNodeListeners = new HashSet();
+  private Set<NewNodeListener> newNodeListeners = new HashSet<NewNodeListener>();
 
 
   /**
@@ -206,8 +201,6 @@
 
     lockFile = LockFile.createLockFile(fileName + ".np.lock");
 
-    objectPool = ObjectPool.newInstance();
-
     try {
       // Open the metaroot file.
       RandomAccessFile metarootRAF = null;
@@ -233,7 +226,7 @@
         }
       }
 
-      freeList = FreeList.openFreeList(objectPool, fileName + ".np_fl");
+      freeList = FreeList.openFreeList(fileName + ".np_fl");
     } catch (IOException ex) {
       try {
         close();
@@ -306,10 +299,9 @@
 
       // Notify all the NewNodeListeners.
       try {
-        Iterator it = newNodeListeners.iterator();
+        Iterator<NewNodeListener> it = newNodeListeners.iterator();
         while (it.hasNext()) {
-          NewNodeListener l = (NewNodeListener) it.next();
-          l.newNode(node);
+          it.next().newNode(node);
         }
       } catch (Exception ex) {
         throw new NodePoolException("Call to NewNodeListener failed.", ex);
@@ -374,18 +366,9 @@
     } finally {
       try {
         try {
-          if (objectPool != null) {
-            objectPool.release();
-            objectPool = null;
-          }
-
-          if (metarootFile != null) {
-            metarootFile.close();
-          }
+          if (metarootFile != null) metarootFile.close();
         } finally {
-          if (freeList != null) {
-            freeList.close();
-          }
+          if (freeList != null) freeList.close();
         }
       } catch (IOException ex) {
         throw new NodePoolException("I/O error closing node pool.", ex);
@@ -411,18 +394,9 @@
     } finally {
       try {
         try {
-          if (objectPool != null) {
-            objectPool.release();
-            objectPool = null;
-          }
-
-          if (metarootFile != null) {
-            metarootFile.delete();
-          }
+          if (metarootFile != null) metarootFile.delete();
         } finally {
-          if (freeList != null) {
-            freeList.delete();
-          }
+          if (freeList != null) freeList.delete();
         }
       } catch (IOException ex) {
         throw new NodePoolException("I/O error deleting node pool.", ex);
@@ -516,7 +490,6 @@
    */
   public synchronized void prepare() throws SimpleXAResourceException {
     checkInitialized();
-    objectPool.flush();
 
     if (prepared) {
       // prepare already performed.
@@ -810,20 +783,12 @@
     }
 
     if (metarootFile != null) {
-      if (metarootBlocks[0] != null) {
-        metarootBlocks[0].release();
-        metarootBlocks[0] = null;
-      }
-      if (metarootBlocks[1] != null) {
-        metarootBlocks[1].release();
-        metarootBlocks[1] = null;
-      }
+      if (metarootBlocks[0] != null) metarootBlocks[0] = null;
+      if (metarootBlocks[1] != null) metarootBlocks[1] = null;
       metarootFile.unmap();
     }
 
-    if (freeList != null) {
-      freeList.unmap();
-    }
+    if (freeList != null) freeList.unmap();
   }
 
 
@@ -860,8 +825,8 @@
         metarootFile.setNrBlocks(NR_METAROOTS);
       }
 
-      metarootBlocks[0] = metarootFile.readBlock(objectPool, 0);
-      metarootBlocks[1] = metarootFile.readBlock(objectPool, 1);
+      metarootBlocks[0] = metarootFile.readBlock(0);
+      metarootBlocks[1] = metarootFile.readBlock(1);
     }
 
     if (clear) {

Modified: trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/store-stringpool-xa/java/org/mulgara/store/stringpool/xa/XAStringPoolImpl.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -40,7 +40,6 @@
 
 // Locally written packages
 import org.mulgara.query.*;
-import org.mulgara.store.*;
 import org.mulgara.store.nodepool.NodePool;
 import org.mulgara.store.nodepool.NodePoolException;
 import org.mulgara.store.statement.StatementStore;
@@ -165,9 +164,6 @@
    */
   private String fileName;
 
-  /** The object pool to use for all reusable objects. */
-  private ObjectPool writerObjectPool;
-
   /** The LockFile that protects the node pool from being opened twice. */
   private LockFile lockFile;
 
@@ -228,8 +224,6 @@
 
     lockFile = LockFile.createLockFile(fileName + ".sp.lock");
 
-    writerObjectPool = ObjectPool.newInstance();
-
     try {
       // Open the metaroot file.
       RandomAccessFile metarootRAF = null;
@@ -255,9 +249,7 @@
         }
       }
 
-      avlFile = new AVLFile(
-          writerObjectPool, fileName + ".sp_avl", PAYLOAD_SIZE
-      );
+      avlFile = new AVLFile(fileName + ".sp_avl", PAYLOAD_SIZE);
       gNodeToDataFile = IntFile.open(new File(fileName + ".sp_nd"));
 
       for (int i = 0; i < NR_BLOCK_FILES; ++i) {
@@ -266,8 +258,7 @@
           num = "0" + num;
         }
         int blockSize = MIN_BLOCK_SIZE << i;
-        blockFiles[i] = new ManagedBlockFile(
-            writerObjectPool, fileName + ".sp_" + num,
+        blockFiles[i] = new ManagedBlockFile(fileName + ".sp_" + num,
             blockSize, blockSize > MappedBlockFile.REGION_SIZE ?
             BlockFile.IOType.EXPLICIT : BlockFile.IOType.DEFAULT
         );
@@ -380,22 +371,16 @@
    * @return The graph node. <code>Graph.NONE</code> if not found.
    * @throws StringPoolException EXCEPTION TO DO
    */
-  public synchronized long findGNode(
-      SPObject spObject
-  ) throws StringPoolException {
+  public synchronized long findGNode(SPObject spObject) throws StringPoolException {
     checkInitialized();
-    return currentPhase.findGNode(writerObjectPool, spObject, null);
+    return currentPhase.findGNode(spObject, null);
   }
 
 
-  public synchronized long findGNode(
-      SPObject spObject, NodePool nodePool
-  ) throws StringPoolException {
+  public synchronized long findGNode(SPObject spObject, NodePool nodePool) throws StringPoolException {
     checkInitialized();
-    if (nodePool == null) {
-      throw new IllegalArgumentException("nodePool parameter is null");
-    }
-    return currentPhase.findGNode(writerObjectPool, spObject, nodePool);
+    if (nodePool == null) throw new IllegalArgumentException("nodePool parameter is null");
+    return currentPhase.findGNode(spObject, nodePool);
   }
 
 
@@ -408,11 +393,9 @@
    * <code>null</code> if no such graph node is in the pool.
    * @throws StringPoolException if an internal error occurs.
    */
-  public synchronized SPObject findSPObject(
-      long gNode
-  ) throws StringPoolException {
+  public synchronized SPObject findSPObject(long gNode) throws StringPoolException {
     checkInitialized();
-    return currentPhase.findSPObject(writerObjectPool, gNode);
+    return currentPhase.findSPObject(gNode);
   }
 
 
@@ -422,18 +405,14 @@
   ) throws StringPoolException {
     checkInitialized();
     dirty = false;
-    return currentPhase.findGNodes(
-        writerObjectPool, lowValue, inclLowValue, highValue, inclHighValue
-    );
+    return currentPhase.findGNodes(lowValue, inclLowValue, highValue, inclHighValue);
   }
 
 
-  public synchronized Tuples findGNodes(
-      SPObject.TypeCategory typeCategory, URI typeURI
-  ) throws StringPoolException {
+  public synchronized Tuples findGNodes(SPObject.TypeCategory typeCategory, URI typeURI) throws StringPoolException {
     checkInitialized();
     dirty = false;
-    return currentPhase.findGNodes(writerObjectPool, typeCategory, typeURI);
+    return currentPhase.findGNodes(typeCategory, typeURI);
   }
 
 
@@ -549,14 +528,8 @@
    * @throws IOException EXCEPTION TO DO
    * @throws SimpleXAResourceException EXCEPTION TO DO
    */
-  public synchronized void clear(
-      int phaseNumber
-  ) throws IOException, SimpleXAResourceException {
-    if (currentPhase != null) {
-      throw new IllegalStateException(
-          "StringPool already has a current phase."
-      );
-    }
+  public synchronized void clear(int phaseNumber) throws IOException, SimpleXAResourceException {
+    if (currentPhase != null) throw new IllegalStateException("StringPool already has a current phase.");
 
     openMetarootFile(true);
 
@@ -567,9 +540,7 @@
     phaseIndex = 1;
     avlFile.clear();
     gNodeToDataFile.clear();
-    for (int i = 0; i < NR_BLOCK_FILES; ++i) {
-      blockFiles[i].clear();
-    }
+    for (int i = 0; i < NR_BLOCK_FILES; ++i) blockFiles[i].clear();
 
     new Phase();
   }
@@ -581,11 +552,8 @@
    * @throws IOException EXCEPTION TO DO
    * @throws SimpleXAResourceException EXCEPTION TO DO
    */
-  public synchronized void clear(
-  ) throws IOException, SimpleXAResourceException {
-    if (currentPhase == null) {
-      clear(0);
-    }
+  public synchronized void clear() throws IOException, SimpleXAResourceException {
+    if (currentPhase == null) clear(0);
 
     // TODO - should throw an exception if clear() is called after any other
     // operations are performed.  Calling clear() multiple times should be
@@ -600,7 +568,6 @@
    */
   public synchronized void prepare() throws SimpleXAResourceException {
     checkInitialized();
-    writerObjectPool.flush();
 
     if (prepared) {
       // prepare already performed.
@@ -887,11 +854,9 @@
 
     if (metarootFile != null) {
       if (metarootBlocks[0] != null) {
-        metarootBlocks[0].release();
         metarootBlocks[0] = null;
       }
       if (metarootBlocks[1] != null) {
-        metarootBlocks[1].release();
         metarootBlocks[1] = null;
       }
       metarootFile.unmap();
@@ -953,11 +918,6 @@
             }
           } finally {
             try {
-              if (writerObjectPool != null) {
-                writerObjectPool.release();
-                writerObjectPool = null;
-              }
-
               if (metarootFile != null) {
                 if (deleteFiles) {
                   metarootFile.delete();
@@ -1011,8 +971,8 @@
         metarootFile.setNrBlocks(NR_METAROOTS);
       }
 
-      metarootBlocks[0] = metarootFile.readBlock(writerObjectPool, 0);
-      metarootBlocks[1] = metarootFile.readBlock(writerObjectPool, 1);
+      metarootBlocks[0] = metarootFile.readBlock(0);
+      metarootBlocks[1] = metarootFile.readBlock(1);
     }
 
     if (clear) {
@@ -1067,9 +1027,6 @@
 
     private Phase.Token token = null;
 
-    private ObjectPool readerObjectPool = null;
-
-
     /**
      * CONSTRUCTOR ReadOnlyStringPool TO DO
      */
@@ -1131,19 +1088,13 @@
      * @return The graph node. <code>Graph.NONE</code> if not found.
      * @throws StringPoolException EXCEPTION TO DO
      */
-    public synchronized long findGNode(
-        SPObject spObject
-    ) throws StringPoolException {
-      return phase.findGNode(readerObjectPool, spObject, null);
+    public synchronized long findGNode(SPObject spObject) throws StringPoolException {
+      return phase.findGNode(spObject, null);
     }
 
 
-    public synchronized long findGNode(
-        SPObject spObject, NodePool nodePool
-    ) throws StringPoolException {
-      throw new UnsupportedOperationException(
-          "Trying to modify a read-only string pool."
-      );
+    public synchronized long findGNode(SPObject spObject, NodePool nodePool) throws StringPoolException {
+      throw new UnsupportedOperationException("Trying to modify a read-only string pool.");
     }
 
 
@@ -1156,10 +1107,8 @@
      * <code>null</code> if no such graph node is in the pool.
      * @throws StringPoolException if an internal error occurs.
      */
-    public synchronized SPObject findSPObject(
-        long gNode
-    ) throws StringPoolException {
-      return phase.findSPObject(readerObjectPool, gNode);
+    public synchronized SPObject findSPObject(long gNode) throws StringPoolException {
+      return phase.findSPObject(gNode);
     }
 
 
@@ -1167,16 +1116,12 @@
         SPObject lowValue, boolean inclLowValue,
         SPObject highValue, boolean inclHighValue
     ) throws StringPoolException {
-      return phase.findGNodes(
-          readerObjectPool, lowValue, inclLowValue, highValue, inclHighValue
-      );
+      return phase.findGNodes(lowValue, inclLowValue, highValue, inclHighValue);
     }
 
 
-    public synchronized Tuples findGNodes(
-        SPObject.TypeCategory typeCategory, URI typeURI
-    ) throws StringPoolException {
-      return phase.findGNodes(readerObjectPool, typeCategory, typeURI);
+    public synchronized Tuples findGNodes(SPObject.TypeCategory typeCategory, URI typeURI) throws StringPoolException {
+      return phase.findGNodes(typeCategory, typeURI);
     }
 
 
@@ -1194,9 +1139,7 @@
      * Close all the files used in the string pool.
      */
     public void close() {
-      throw new UnsupportedOperationException(
-          "Trying to close a read-only string pool."
-      );
+      throw new UnsupportedOperationException("Trying to close a read-only string pool.");
     }
 
 
@@ -1205,40 +1148,25 @@
      * associated with it.
      */
     public void delete() {
-      throw new UnsupportedOperationException(
-          "Trying to delete a read-only string pool."
-      );
+      throw new UnsupportedOperationException("Trying to delete a read-only string pool.");
     }
 
 
     public synchronized void release() {
       try {
-        if (token != null) {
-          token.release();
-        }
-        if (readerObjectPool != null) {
-          readerObjectPool.flush();
-          readerObjectPool.release();
-        }
+        if (token != null) token.release();
       } finally {
         phase = null;
         token = null;
-        readerObjectPool = null;
       }
     }
 
 
     public synchronized void refresh() {
-      if (readerObjectPool == null) {
-        readerObjectPool = ObjectPool.newInstance();
-      }
-
       synchronized (committedPhaseLock) {
         Phase committedPhase = committedPhaseToken.getPhase();
         if (phase != committedPhase) {
-          if (token != null) {
-            token.release();
-          }
+          if (token != null) token.release();
           phase = committedPhase;
           token = phase.use();
         }
@@ -1373,12 +1301,8 @@
      * exists in the pool.
      */
     void put(long gNode, SPObject spObject) throws StringPoolException {
-      if (gNode < NodePool.MIN_NODE) {
-        throw new IllegalArgumentException("gNode < MIN_NODE");
-      }
+      if (gNode < NodePool.MIN_NODE) throw new IllegalArgumentException("gNode < MIN_NODE");
 
-      final ObjectPool objectPool = XAStringPoolImpl.this.writerObjectPool;
-
       AVLNode[] findResult = null;
       try {
         // Check that there is no SPObject corresponding to the graph node.
@@ -1388,9 +1312,7 @@
             gNodeToDataFile.getByte(bOffset + IDX_TYPE_CATEGORY_B) !=
             SPObject.TypeCategory.TCID_FREE
         ) {
-          throw new StringPoolException(
-              "Graph node already exists.  (Graph node: " + gNode + ")"
-          );
+          throw new StringPoolException("Graph node already exists.  (Graph node: " + gNode + ")");
         }
 
         SPObject.TypeCategory typeCategory = spObject.getTypeCategory();
@@ -1406,12 +1328,10 @@
         }
         ByteBuffer data = spObject.getData();
         SPComparator spComparator = spObject.getSPComparator();
-        AVLComparator avlComparator = new SPAVLComparator(
-            objectPool, spComparator, typeCategory, typeId, data
-        );
+        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
 
         // Find the adjacent nodes.
-        findResult = avlFilePhase.find(objectPool, avlComparator, null);
+        findResult = avlFilePhase.find(avlComparator, null);
         if (findResult != null && findResult.length == 1) {
           throw new StringPoolException(
               "SPObject already exists.  (existing graph node: " +
@@ -1419,17 +1339,10 @@
           );
         }
 
-        put(
-            objectPool, gNode, findResult,
-            typeCategory, typeId, subtypeId, data
-        );
+        put(gNode, findResult,typeCategory, typeId, subtypeId, data);
 
-        if (GN2SPO_CACHE_ENABLED) {
-          gn2spoCache.put(gNode, spObject);
-        }
-        if (SPO2GN_CACHE_ENABLED) {
-          spo2gnCache.put(spObject, gNode);
-        }
+        if (GN2SPO_CACHE_ENABLED) gn2spoCache.put(gNode, spObject);
+        if (SPO2GN_CACHE_ENABLED) spo2gnCache.put(spObject, gNode);
       } catch (IOException ex) {
         throw new StringPoolException("I/O Error", ex);
       } finally {
@@ -1441,9 +1354,8 @@
 
 
     private void put(
-        ObjectPool objectPool, long gNode, AVLNode[] findResult,
-        SPObject.TypeCategory typeCategory, int typeId, int subtypeId,
-        ByteBuffer data
+        long gNode, AVLNode[] findResult, SPObject.TypeCategory typeCategory,
+        int typeId, int subtypeId, ByteBuffer data
     ) throws StringPoolException, IOException {
       long offset = gNode * GN2SPO_BLOCKSIZE;
       long bOffset = offset * Constants.SIZEOF_LONG;
@@ -1452,14 +1364,14 @@
           SPObject.TypeCategory.TCID_FREE;
 
       // Create the new AVLNode.
-      AVLNode newNode = avlFilePhase.newAVLNodeInstance(objectPool);
+      AVLNode newNode = avlFilePhase.newAVLNodeInstance();
       newNode.putPayloadByte(IDX_TYPE_CATEGORY_B, (byte)typeCategory.ID);
       newNode.putPayloadByte(IDX_TYPE_ID_B, (byte)typeId);
       newNode.putPayloadByte(IDX_SUBTYPE_ID_B, (byte)subtypeId);
       int dataSize = data.limit();
       newNode.putPayloadInt(IDX_DATA_SIZE_I, dataSize);
 
-      long blockId = storeByteBuffer(objectPool, newNode, data);
+      long blockId = storeByteBuffer(newNode, data);
 
       newNode.putPayloadLong(IDX_GRAPH_NODE, gNode);
       newNode.write();
@@ -1516,9 +1428,7 @@
      * @return the block Id of the new block or Block.INVALID_BLOCK_ID if no
      * block was allocated.
      */
-    private long storeByteBuffer(
-        ObjectPool objectPool, AVLNode avlNode, ByteBuffer data
-    ) throws IOException, StringPoolException {
+    private long storeByteBuffer(AVLNode avlNode, ByteBuffer data) throws IOException, StringPoolException {
       // Get the number of bytes to be written.
       int dataSize = data.limit();
 
@@ -1561,19 +1471,15 @@
         }
 
         ManagedBlockFile.Phase blockFilePhase = blockFilePhases[fileIndex];
-        Block block = blockFilePhase.allocateBlock(objectPool);
-        try {
-          block.put(0, data);
-          block.write();
+        Block block = blockFilePhase.allocateBlock();
+        block.put(0, data);
+        block.write();
 
-          blockId = block.getBlockId();
+        blockId = block.getBlockId();
 
-          // Store the block ID in the AVLNode payload.
-          avlNode.putPayloadLong(IDX_BLOCK_ID, blockId);
-          return blockId;
-        } finally {
-          block.release();
-        }
+        // Store the block ID in the AVLNode payload.
+        avlNode.putPayloadLong(IDX_BLOCK_ID, blockId);
+        return blockId;
       } else {
         blockId = Block.INVALID_BLOCK_ID;
       }
@@ -1587,9 +1493,7 @@
      * current position.  The number of bytes read is the number of remaining
      * bytes in the ByteBuffer.
      */
-    private ByteBuffer retrieveRemainingBytes(
-        ObjectPool objectPool, ByteBuffer data, long blockId
-    ) throws IOException {
+    private ByteBuffer retrieveRemainingBytes(ByteBuffer data, long blockId) throws IOException {
       int dataSize = data.remaining();
 
       if (dataSize > 0) {
@@ -1598,12 +1502,8 @@
             (dataSize - 1) >> (LOG2_MIN_BLOCK_SIZE - 1)
         );
         ManagedBlockFile.Phase blockFilePhase = blockFilePhases[fileIndex];
-        Block block = blockFilePhase.readBlock(objectPool, blockId);
-        try {
-          block.get(0, data);
-        } finally {
-          block.release();
-        }
+        Block block = blockFilePhase.readBlock(blockId);
+        block.get(0, data);
       }
       return data;
     }
@@ -1639,19 +1539,13 @@
      * @throws StringPoolException if an internal error occurs.
      */
     boolean remove(long gNode) throws StringPoolException {
-      if (gNode < NodePool.MIN_NODE) {
-        throw new IllegalArgumentException("gNode < MIN_NODE");
-      }
+      if (gNode < NodePool.MIN_NODE) throw new IllegalArgumentException("gNode < MIN_NODE");
 
-      if (avlFilePhase.isEmpty()) {
-        return false;
-      }
+      if (avlFilePhase.isEmpty()) return false;
 
-      final ObjectPool objectPool = XAStringPoolImpl.this.writerObjectPool;
-
       try {
         // Load the SPObject from the G2N file.
-        SPObject spObject = findSPObject(objectPool, gNode);
+        SPObject spObject = findSPObject(gNode);
         if (spObject == null) {
           // Graph node represents a blank node.
           return false;
@@ -1666,14 +1560,10 @@
             SPObjectFactory.INVALID_TYPE_ID;
         ByteBuffer data = spObject.getData();
         SPComparator spComparator = spObject.getSPComparator();
-        AVLComparator avlComparator = new SPAVLComparator(
-          objectPool, spComparator, typeCategory, typeId, data
-        );
+        AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
 
         // Find the SPObject.
-        AVLNode[] findResult = avlFilePhase.find(
-            objectPool, avlComparator, null
-        );
+        AVLNode[] findResult = avlFilePhase.find(avlComparator, null);
         if (findResult == null) {
           // The AVL tree is empty.  This shouldn't happen since this was
           // checked for earlier.
@@ -1709,17 +1599,12 @@
     /**
      * Finds a graph node matching a given SPObject.
      *
-     * @param objectPool PARAMETER TO DO
      * @param spObject The SPObject to search on.
      * @return The graph node. <code>Graph.NONE</code> if not found.
      * @throws StringPoolException EXCEPTION TO DO
      */
-    long findGNode(
-        ObjectPool objectPool, SPObject spObject, NodePool nodePool
-    ) throws StringPoolException {
-      if (spObject == null) {
-        throw new StringPoolException("spObject parameter is null");
-      }
+    long findGNode(SPObject spObject, NodePool nodePool) throws StringPoolException {
+      if (spObject == null) throw new StringPoolException("spObject parameter is null");
 
       long gNode;
       Long gNodeL;
@@ -1745,12 +1630,10 @@
           }
           ByteBuffer data = spObject.getData();
           SPComparator spComparator = spObject.getSPComparator();
-          AVLComparator avlComparator = new SPAVLComparator(
-            objectPool, spComparator, typeCategory, typeId, data
-          );
+          AVLComparator avlComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
 
           // Find the SPObject.
-          findResult = avlFilePhase.find(objectPool, avlComparator, null);
+          findResult = avlFilePhase.find(avlComparator, null);
           if (findResult != null && findResult.length == 1) {
             gNode = findResult[0].getPayloadLong(IDX_GRAPH_NODE);
             if (GN2SPO_CACHE_ENABLED) {
@@ -1766,16 +1649,11 @@
               } catch (NodePoolException ex) {
                 throw new StringPoolException("Could not allocate new node", ex);
               }
-              put(
-                  objectPool, gNode, findResult,
-                  typeCategory, typeId, subtypeId, data
-              );
+              put(gNode, findResult,typeCategory, typeId, subtypeId, data);
               if (GN2SPO_CACHE_ENABLED) {
                 //gn2spoCache.put(gNode, spObject);
               }
-              if (SPO2GN_CACHE_ENABLED) {
-                spo2gnCache.put(spObject, gNode);
-              }
+              if (SPO2GN_CACHE_ENABLED) spo2gnCache.put(spObject, gNode);
             } else {
               // Not found.
               gNode = NodePool.NONE;
@@ -1800,9 +1678,7 @@
         }
       }
 
-      if (logger.isDebugEnabled()) {
-        logger.debug("findGNode(" + spObject + ") = " + gNode);
-      }
+      if (logger.isDebugEnabled()) logger.debug("findGNode(" + spObject + ") = " + gNode);
 
       return gNode;
     }
@@ -1817,23 +1693,15 @@
      * <code>null</code> if no such graph node is in the pool.
      * @throws StringPoolException if an internal error occurs.
      */
-    SPObject findSPObject(
-        ObjectPool objectPool, long gNode
-    ) throws StringPoolException {
-      if (gNode < NodePool.MIN_NODE) {
-        throw new IllegalArgumentException("gNode=" + gNode + " < MIN_NODE");
-      }
+    SPObject findSPObject(long gNode) throws StringPoolException {
+      if (gNode < NodePool.MIN_NODE) throw new IllegalArgumentException("gNode=" + gNode + " < MIN_NODE");
 
       Long gNodeL = new Long(gNode);
       SPObject spObject;
-      if (GN2SPO_CACHE_ENABLED) {
-        spObject = gn2spoCache.get(gNodeL);
-      }
+      if (GN2SPO_CACHE_ENABLED) spObject = gn2spoCache.get(gNodeL);
       if (!GN2SPO_CACHE_ENABLED || spObject == null) {
         if (gn2spoCache.isBlankNode(gNodeL)) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("findSPObject(" + gNode + ") = Blank node");
-          }
+          if (logger.isDebugEnabled()) logger.debug("findSPObject(" + gNode + ") = Blank node");
           return null;
         }
 
@@ -1842,24 +1710,16 @@
           // Get the type category ID.
           long offset = gNode * GN2SPO_BLOCKSIZE;
           long bOffset = offset * Constants.SIZEOF_LONG;
-          int typeCategoryId = gNodeToDataFile.getByte(
-              bOffset + IDX_TYPE_CATEGORY_B
-          );
+          int typeCategoryId = gNodeToDataFile.getByte(bOffset + IDX_TYPE_CATEGORY_B);
           if (typeCategoryId == SPObject.TypeCategory.TCID_FREE) {
             // A blank node.
-            if (logger.isDebugEnabled()) {
-              logger.debug("findSPObject(" + gNode + ") = Blank node");
-            }
-            if (GN2SPO_CACHE_ENABLED) {
-              gn2spoCache.putBlankNode(gNode);
-            }
+            if (logger.isDebugEnabled()) logger.debug("findSPObject(" + gNode + ") = Blank node");
+            if (GN2SPO_CACHE_ENABLED) gn2spoCache.putBlankNode(gNode);
             return null;
           }
 
           // Convert the ID to a TypeCategory object.
-          SPObject.TypeCategory typeCategory = SPObject.TypeCategory.forId(
-              typeCategoryId
-          );
+          SPObject.TypeCategory typeCategory = SPObject.TypeCategory.forId(typeCategoryId);
 
           // Get the type ID and subtype ID.
           int typeId = gNodeToDataFile.getByte(bOffset + IDX_TYPE_ID_B);
@@ -1884,56 +1744,41 @@
           // Retrieve bytes from the AVLNode.
           ByteBuffer data = ByteBuffer.allocate(dataSize);
           data.limit(directDataSize);
-          XAStringPoolImpl.get(
-              gNodeToDataFile, bOffset + IDX_DATA * Constants.SIZEOF_LONG, data
-          );
+          XAStringPoolImpl.get(gNodeToDataFile, bOffset + IDX_DATA * Constants.SIZEOF_LONG, data);
 
           // Retrieve the remaining bytes if any.
           if (dataSize > MAX_DIRECT_DATA_BYTES) {
             data.limit(dataSize);
-            retrieveRemainingBytes(objectPool, data, blockId);
+            retrieveRemainingBytes(data, blockId);
           }
           data.rewind();
 
           // Construct the SPObject and return it.
-          spObject = SPO_FACTORY.newSPObject(
-            typeCategory, typeId, subtypeId, data
-          );
+          spObject = SPO_FACTORY.newSPObject(typeCategory, typeId, subtypeId, data);
 
-          if (GN2SPO_CACHE_ENABLED) {
-            gn2spoCache.put(gNode, spObject);
-          }
+          if (GN2SPO_CACHE_ENABLED) gn2spoCache.put(gNode, spObject);
           if (SPO2GN_CACHE_ENABLED) {
             //spo2gnCache.put(spObject, gNode);
           }
         } catch (IOException ex) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("IOException in findSPObject(" + gNode + ")", ex);
-          }
+          if (logger.isDebugEnabled()) logger.debug("IOException in findSPObject(" + gNode + ")", ex);
           throw new StringPoolException("I/O Error", ex);
         } catch (RuntimeException ex) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("RuntimeException in findSPObject(" + gNode + ")", ex);
-          }
+          if (logger.isDebugEnabled()) logger.debug("RuntimeException in findSPObject(" + gNode + ")", ex);
           throw ex;
         } catch (Error e) {
-          if (logger.isDebugEnabled()) {
-            logger.debug("Error in findSPObject(" + gNode + ")", e);
-          }
+          if (logger.isDebugEnabled()) logger.debug("Error in findSPObject(" + gNode + ")", e);
           throw e;
         }
       }
 
-      if (logger.isDebugEnabled()) {
-        logger.debug("findSPObject(" + gNode + ") = " + spObject);
-      }
+      if (logger.isDebugEnabled()) logger.debug("findSPObject(" + gNode + ") = " + spObject);
 
       return spObject;
     }
 
 
     Tuples findGNodes(
-        ObjectPool objectPool,
         SPObject lowValue, boolean inclLowValue,
         SPObject highValue, boolean inclHighValue
     ) throws StringPoolException {
@@ -1946,18 +1791,15 @@
         // Return all nodes in the index.
         typeCategory = null;
         typeId = SPObjectFactory.INVALID_TYPE_ID;
-        lowAVLNode = avlFilePhase.getRootNode(objectPool);
-        if (lowAVLNode != null) {
-          lowAVLNode = lowAVLNode.getMinNode_R();
-        }
+        lowAVLNode = avlFilePhase.getRootNode();
+        if (lowAVLNode != null) lowAVLNode = lowAVLNode.getMinNode_R();
         highAVLNodeId = Block.INVALID_BLOCK_ID;
       } else {
         // Get the type category.
         SPObject typeValue = lowValue != null ? lowValue : highValue;
         typeCategory = typeValue.getTypeCategory();
-        typeId = typeCategory == SPObject.TypeCategory.TYPED_LITERAL ? (
-            ((SPTypedLiteral)typeValue).getTypeId()
-        ) : SPObjectFactory.INVALID_TYPE_ID;
+        typeId = typeCategory == SPObject.TypeCategory.TYPED_LITERAL ?
+                 ((SPTypedLiteral)typeValue).getTypeId() : SPObjectFactory.INVALID_TYPE_ID;
 
         // Check that the two SPObjects are of the same type.
         if (lowValue != null && highValue != null) {
@@ -1969,9 +1811,7 @@
             )
           ) {
             // Type mismatch.
-            throw new StringPoolException(
-                "lowValue and highValue are not of the same type"
-            );
+            throw new StringPoolException("lowValue and highValue are not of the same type");
           }
 
           if (lowValue != null && highValue != null) {
@@ -1981,7 +1821,7 @@
             int c = lowValue.compareTo(highValue);
             if (c > 0 || c == 0 && (!inclLowValue || !inclHighValue)) {
               return new GNodeTuplesImpl(
-                  objectPool, null, SPObjectFactory.INVALID_TYPE_ID,
+                  null, SPObjectFactory.INVALID_TYPE_ID,
                   null, null, null, Block.INVALID_BLOCK_ID
               );
             }
@@ -1993,15 +1833,11 @@
         if (lowValue != null) {
           ByteBuffer data = lowValue.getData();
           SPComparator spComparator = lowValue.getSPComparator();
-          lowComparator = new SPAVLComparator(
-              objectPool, spComparator, typeCategory, typeId, data
-          );
+          lowComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
         } else {
           // Select the first node with the current type.
           if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
-            lowComparator = new SPCategoryTypeAVLComparator(
-                typeCategory.ID, typeId
-            );
+            lowComparator = new SPCategoryTypeAVLComparator(typeCategory.ID, typeId);
           } else {
             lowComparator = new SPCategoryAVLComparator(typeCategory.ID);
           }
@@ -2012,23 +1848,17 @@
         if (highValue != null) {
           ByteBuffer data = highValue.getData();
           SPComparator spComparator = highValue.getSPComparator();
-          highComparator = new SPAVLComparator(
-              objectPool, spComparator, typeCategory, typeId, data
-          );
+          highComparator = new SPAVLComparator(spComparator, typeCategory, typeId, data);
         } else {
           // Select the first node past the last one that has the current type.
           if (typeCategory == SPObject.TypeCategory.TYPED_LITERAL) {
-            highComparator = new SPCategoryTypeAVLComparator(
-                typeCategory.ID, typeId + 1
-            );
+            highComparator = new SPCategoryTypeAVLComparator(typeCategory.ID, typeId + 1);
           } else {
             highComparator = new SPCategoryAVLComparator(typeCategory.ID + 1);
           }
         }
 
-        AVLNode[] findResult = avlFilePhase.find(
-            objectPool, lowComparator, null
-        );
+        AVLNode[] findResult = avlFilePhase.find(lowComparator, null);
         if (findResult == null) {
           // Empty store.
           lowAVLNode = null;
@@ -2044,25 +1874,19 @@
               // The lowValue passed to the GNodeTuplesImpl constructor
               // is always inclusive but inclLowValue is false.
               // Recalculate lowValue.
-              if (lowAVLNode != null) {
-                lowValue = loadSPObject(
-                    objectPool, typeCategory, typeId, lowAVLNode
-                );
-              }
+              if (lowAVLNode != null) lowValue = loadSPObject(typeCategory, typeId, lowAVLNode);
             }
           } else {
             // Did not find the node but found the location where the node
             // would be if it existed.
-            if (findResult[0] != null) {
-              findResult[0].release();
-            }
+            if (findResult[0] != null) findResult[0].release();
             lowAVLNode = findResult[1];
           }
 
           if (lowAVLNode != null) {
             // Find the high node.
 
-            findResult = avlFilePhase.find(objectPool, highComparator, null);
+            findResult = avlFilePhase.find(highComparator, null);
             if (findResult.length == 1) {
               // Found the node exactly.
               AVLNode highAVLNode = findResult[0];
@@ -2076,9 +1900,7 @@
                   // The highValue passed to the GNodeTuplesImpl constructor
                   // is always exclusive but inclHighValue is true.
                   // Recalculate highValue.
-                  highValue = loadSPObject(
-                      objectPool, typeCategory, typeId, highAVLNode
-                  );
+                  highValue = loadSPObject(typeCategory, typeId, highAVLNode);
 
                   highAVLNode.release();
                 } else {
@@ -2091,8 +1913,7 @@
             } else {
               // Did not find the node but found the location where the node
               // would be if it existed.
-              highAVLNodeId = findResult[1] != null ? findResult[1].getId() :
-                  Block.INVALID_BLOCK_ID;
+              highAVLNodeId = findResult[1] != null ? findResult[1].getId() : Block.INVALID_BLOCK_ID;
             }
 
             AVLFile.release(findResult);
@@ -2102,16 +1923,11 @@
         }
       }
 
-      return new GNodeTuplesImpl(
-          objectPool, typeCategory, typeId,
-          lowValue, highValue, lowAVLNode, highAVLNodeId
-      );
+      return new GNodeTuplesImpl(typeCategory, typeId,lowValue, highValue, lowAVLNode, highAVLNodeId);
     }
 
 
-    Tuples findGNodes(
-        ObjectPool objectPool, SPObject.TypeCategory typeCategory, URI typeURI
-    ) throws StringPoolException {
+    Tuples findGNodes(SPObject.TypeCategory typeCategory, URI typeURI) throws StringPoolException {
       int typeId;
       AVLNode lowAVLNode;
       long highAVLNodeId;
@@ -2122,9 +1938,7 @@
           try {
             typeId = SPO_FACTORY.getTypeId(typeURI);
           } catch (IllegalArgumentException ex) {
-            throw new StringPoolException(
-                "Unsupported XSD type: " + typeURI, ex
-            );
+            throw new StringPoolException("Unsupported XSD type: " + typeURI, ex);
           }
         } else {
           typeId = SPObjectFactory.INVALID_TYPE_ID;
@@ -2138,21 +1952,15 @@
             typeId != SPObjectFactory.INVALID_TYPE_ID
         ) {
           // Return nodes of the specified category and type node.
-          lowComparator = new SPCategoryTypeAVLComparator(
-              typeCategory.ID, typeId
-          );
-          highComparator = new SPCategoryTypeAVLComparator(
-              typeCategory.ID, typeId + 1
-          );
+          lowComparator = new SPCategoryTypeAVLComparator(typeCategory.ID, typeId);
+          highComparator = new SPCategoryTypeAVLComparator(typeCategory.ID, typeId + 1);
         } else {
           // Return nodes of the specified category.
           lowComparator = new SPCategoryAVLComparator(typeCategory.ID);
           highComparator = new SPCategoryAVLComparator(typeCategory.ID + 1);
         }
 
-        AVLNode[] findResult = avlFilePhase.find(
-            objectPool, lowComparator, null
-        );
+        AVLNode[] findResult = avlFilePhase.find(lowComparator, null);
         if (findResult == null) {
           // Empty store.
           lowAVLNode = null;
@@ -2166,10 +1974,9 @@
 
           if (lowAVLNode != null) {
             // Find the high node.
-            findResult = avlFilePhase.find(objectPool, highComparator, null);
+            findResult = avlFilePhase.find(highComparator, null);
             assert findResult.length == 2;
-            highAVLNodeId = findResult[1] != null ? findResult[1].getId() :
-                Block.INVALID_BLOCK_ID;
+            highAVLNodeId = findResult[1] != null ? findResult[1].getId() : Block.INVALID_BLOCK_ID;
             AVLFile.release(findResult);
           } else {
             highAVLNodeId = Block.INVALID_BLOCK_ID;
@@ -2177,31 +1984,23 @@
         }
       } else {
         if (typeURI != null) {
-          throw new StringPoolException(
-              "typeCategory is null and typeURI is not null"
-          );
+          throw new StringPoolException("typeCategory is null and typeURI is not null");
         }
         typeId = SPObjectFactory.INVALID_TYPE_ID;
 
         // Return all nodes in the index.
-        lowAVLNode = avlFilePhase.getRootNode(objectPool);
-        if (lowAVLNode != null) {
-          lowAVLNode = lowAVLNode.getMinNode_R();
-        }
+        lowAVLNode = avlFilePhase.getRootNode();
+        if (lowAVLNode != null) lowAVLNode = lowAVLNode.getMinNode_R();
         highAVLNodeId = Block.INVALID_BLOCK_ID;
       }
 
-      return new GNodeTuplesImpl(
-          objectPool, typeCategory, typeId, null, null,
-          lowAVLNode, highAVLNodeId
-      );
+      return new GNodeTuplesImpl(typeCategory, typeId, null, null, lowAVLNode, highAVLNodeId);
     }
 
 
     // Returns the SPObject referenced by the avlNode or null if the SPObject
     // is not of the specified type.
     private SPObject loadSPObject(
-        ObjectPool objectPool,
         SPObject.TypeCategory typeCategory, int typeId, AVLNode avlNode
     ) throws StringPoolException {
       try {
@@ -2245,34 +2044,24 @@
           ByteBuffer newData = ByteBuffer.allocate(dataSize);
           newData.put(data);
           data = newData;
-          retrieveRemainingBytes(objectPool, data, blockId);
+          retrieveRemainingBytes(data, blockId);
         }
         data.rewind();
 
         // Construct the SPObject and return it.
-        SPObject spObject = SPO_FACTORY.newSPObject(
-            typeCategory, typeId, subtypeId, data
-        );
+        SPObject spObject = SPO_FACTORY.newSPObject(typeCategory, typeId, subtypeId, data);
 
-        if (logger.isDebugEnabled()) {
-          logger.debug("loadSPObject() = " + spObject);
-        }
+        if (logger.isDebugEnabled()) logger.debug("loadSPObject() = " + spObject);
 
         return spObject;
       } catch (IOException ex) {
-        if (logger.isDebugEnabled()) {
-          logger.debug("IOException in loadSPObject()", ex);
-        }
+        if (logger.isDebugEnabled()) logger.debug("IOException in loadSPObject()", ex);
         throw new StringPoolException("I/O Error", ex);
       } catch (RuntimeException ex) {
-        if (logger.isDebugEnabled()) {
-          logger.debug("RuntimeException in loadSPObject()", ex);
-        }
+        if (logger.isDebugEnabled()) logger.debug("RuntimeException in loadSPObject()", ex);
         throw ex;
       } catch (Error e) {
-        if (logger.isDebugEnabled()) {
-          logger.debug("Error in loadSPObject()", e);
-        }
+        if (logger.isDebugEnabled()) logger.debug("Error in loadSPObject()", e);
         throw e;
       }
     }
@@ -2284,12 +2073,8 @@
      * nodes in the index.
      */
     long checkIntegrity() {
-      ObjectPool objectPool = ObjectPool.newInstance();
-      AVLNode node = avlFilePhase.getRootNode(objectPool);
-      if (node == null) {
-        objectPool.release();
-        return 0;
-      }
+      AVLNode node = avlFilePhase.getRootNode();
+      if (node == null) return 0;
 
       //logger.warn("StringPool tree: " + node);
       node = node.getMinNode_R();
@@ -2331,9 +2116,7 @@
         long iOffset = offset * (Constants.SIZEOF_LONG / Constants.SIZEOF_INT);
         long bOffset = offset * Constants.SIZEOF_LONG;
 
-        int gn2spoTypeCategoryId = gNodeToDataFile.getByte(
-            bOffset + IDX_TYPE_CATEGORY_B
-        );
+        int gn2spoTypeCategoryId = gNodeToDataFile.getByte(bOffset + IDX_TYPE_CATEGORY_B);
         if (gn2spoTypeCategoryId != typeCategoryId) {
           throw new AssertionError(
               "Type category mismatch.  gNode:" + graphNode +
@@ -2351,9 +2134,7 @@
           );
         }
 
-        int gn2spoSubtypeId = gNodeToDataFile.getByte(
-            bOffset + IDX_SUBTYPE_ID_B
-        );
+        int gn2spoSubtypeId = gNodeToDataFile.getByte(bOffset + IDX_SUBTYPE_ID_B);
         if (gn2spoSubtypeId != subtypeId) {
           throw new AssertionError(
               "Subtype ID mismatch.  gNode:" + graphNode +
@@ -2387,7 +2168,6 @@
 
         ++nodeIndex;
       } while ((node = node.getNextNode_R()) != null);
-      objectPool.release();
 
       return nodeIndex;
     }
@@ -2400,8 +2180,6 @@
 
     final class GNodeTuplesImpl implements Tuples {
 
-      private ObjectPool objectPool;
-
       // Defines the constraining type.
       private SPObject.TypeCategory typeCategory;
 
@@ -2450,22 +2228,16 @@
        * index that range from lowAVLNode up to but not including the node with
        * ID highAVLNodeId.
        *
-       * @param objectPool the object pool.
        * @param lowAVLNode the AVLNode that has the first graph node that is
        * included in the Tuples.
        * @param highAVLNodeId the ID of the AVLNode that has the first graph
        * node that is not included in the Tuples.
        */
       GNodeTuplesImpl(
-          ObjectPool objectPool,
           SPObject.TypeCategory typeCategory, int typeId,
           SPObject lowValue, SPObject highValue,
           AVLNode lowAVLNode, long highAVLNodeId
       ) {
-        if (objectPool == null) {
-          throw new IllegalArgumentException("objectPool is null");
-        }
-
         if (lowAVLNode != null && lowAVLNode.getId() == highAVLNodeId) {
           // Low and High are equal - Empty.
           lowAVLNode.release();
@@ -2475,23 +2247,18 @@
 
         if (lowAVLNode == null) {
           // Empty tuples.
-          objectPool = null;
           typeCategory = null;
           lowValue = null;
           highValue = null;
           if (highAVLNodeId != Block.INVALID_BLOCK_ID) {
             if (logger.isDebugEnabled()) {
-              logger.debug(
-                  "lowAVLNode is null but highAVLNodeId is not " +
-                  Block.INVALID_BLOCK_ID
-              );
+              logger.debug("lowAVLNode is null but highAVLNodeId is not " +Block.INVALID_BLOCK_ID);
             }
             highAVLNodeId = Block.INVALID_BLOCK_ID;
           }
           nrGNodes = 0;
           nrGNodesValid = true;
         } else {
-          objectPool.incRefCount();
           token = use();
         }
 
@@ -2499,7 +2266,6 @@
           typeId = SPObjectFactory.INVALID_TYPE_ID;
         }
 
-        this.objectPool = objectPool;
         this.typeCategory = typeCategory;
         this.typeId = typeId;
         this.lowValue = lowValue;
@@ -2509,18 +2275,12 @@
       }
 
       public long getColumnValue(int column) throws TuplesException {
-        if (column != 0) {
-          throw new TuplesException("Column index out of range: " + column);
-        }
+        if (column != 0) throw new TuplesException("Column index out of range: " + column);
 
-        if (onPrefixNode) {
-          // Handle the prefix.
-          return prefix[0];
-        }
+        // Handle the prefix.
+        if (onPrefixNode) return prefix[0];
 
-        if (avlNode == null) {
-          throw new TuplesException("No current row");
-        }
+        if (avlNode == null) throw new TuplesException("No current row");
         return avlNode.getPayloadLong(IDX_GRAPH_NODE);
       }
 
@@ -2544,19 +2304,12 @@
           AVLNode n = lowAVLNode;
           n.incRefCount();
           long count = 0;
-          while (
-              n != null && (
-                  highAVLNodeId == Block.INVALID_BLOCK_ID ||
-                  n.getId() != highAVLNodeId
-              )
-          ) {
+          while (n != null && (highAVLNodeId == Block.INVALID_BLOCK_ID || n.getId() != highAVLNodeId)) {
             ++count;
             n = n.getNextNode_R();
           }
 
-          if (n != null) {
-            n.release();
-          }
+          if (n != null) n.release();
 
           nrGNodes = count;
           nrGNodesValid = true;
@@ -2585,20 +2338,12 @@
           assert lowAVLNode != null;
           AVLNode n = lowAVLNode;
           n.incRefCount();
-          while (
-              count < 2 && n != null && (
-                  highAVLNodeId == Block.INVALID_BLOCK_ID ||
-                  n.getId() != highAVLNodeId
-              )
-          ) {
+          while (count < 2 && n != null && (highAVLNodeId == Block.INVALID_BLOCK_ID || n.getId() != highAVLNodeId)) {
             ++count;
             n = n.getNextNode_R();
           }
 
-          if (n != null) {
-            n.release();
-          }
-
+          if (n != null) n.release();
         }
         return count == 0 ? Cursor.ZERO :
                count == 1 ? Cursor.ONE :
@@ -2606,18 +2351,14 @@
       }
 
       public int getColumnIndex(Variable variable) throws TuplesException {
-        if (variable == null) {
-          throw new IllegalArgumentException("variable is null");
-        }
+        if (variable == null) throw new IllegalArgumentException("variable is null");
 
         if (variable.equals(variables[0])) {
           // The variable matches the one and only column.
           return 0;
         }
 
-        throw new TuplesException(
-            "variable doesn't match any column: " + variable
-        );
+        throw new TuplesException("variable doesn't match any column: " + variable);
       }
 
       public boolean isColumnEverUnbound(int column) {
@@ -2645,18 +2386,10 @@
         return java.util.Collections.EMPTY_LIST;
       }
 
-      public void beforeFirst(
-          long[] prefix, int suffixTruncation
-      ) throws TuplesException {
+      public void beforeFirst(long[] prefix, int suffixTruncation) throws TuplesException {
         assert prefix != null;
-        if (prefix.length > 1) {
-          throw new TuplesException(
-              "prefix.length (" + prefix.length + ") > nrColumns (1)"
-          );
-        }
-        if (suffixTruncation != 0) {
-          throw new TuplesException("suffixTruncation not supported");
-        }
+        if (prefix.length > 1) throw new TuplesException("prefix.length (" + prefix.length + ") > nrColumns (1)");
+        if (suffixTruncation != 0) throw new TuplesException("suffixTruncation not supported");
 
         beforeFirst = true;
         onPrefixNode = false;
@@ -2689,7 +2422,7 @@
             SPObject spObject;
             try {
               // FIXME check the type category and type node.
-              spObject = findSPObject(objectPool, prefix[0]);
+              spObject = findSPObject(prefix[0]);
             } catch (StringPoolException ex) {
               throw new TuplesException("Exception while loading SPObject", ex);
             }
@@ -2734,8 +2467,6 @@
           lowAVLNode = null;
           token.release();
           token = null;
-          objectPool.release();
-          objectPool = null;
         }
       }
 
@@ -2749,7 +2480,6 @@
           t.variables = (Variable[])variables.clone();
           if (t.lowAVLNode != null) {
             t.lowAVLNode.incRefCount();
-            t.objectPool.incRefCount();
             t.token = use(); // Allocate a new token.
             if (t.avlNode != null) {
               t.avlNode.incRefCount();
@@ -2757,9 +2487,7 @@
           }
           return t;
         } catch (CloneNotSupportedException e) {
-          throw new Error(
-              getClass() + " doesn't support clone, which it must", e
-          );
+          throw new Error(getClass() + " doesn't support clone, which it must", e);
         }
       }
 
@@ -2890,17 +2618,12 @@
 
     final class SPAVLComparator implements AVLComparator {
 
-      private final ObjectPool objectPool;
       private final SPComparator spComparator;
       private final SPObject.TypeCategory typeCategory;
       private final int typeId;
       private final ByteBuffer data;
 
-      SPAVLComparator(
-          ObjectPool objectPool, SPComparator spComparator,
-          SPObject.TypeCategory typeCategory, int typeId, ByteBuffer data
-      ) {
-        this.objectPool = objectPool;
+      SPAVLComparator(SPComparator spComparator, SPObject.TypeCategory typeCategory, int typeId, ByteBuffer data) {
         this.spComparator = spComparator;
         this.typeCategory = typeCategory;
         this.typeId = typeId;
@@ -2917,9 +2640,7 @@
 
         // Second, order by type node.
         int nodeTypeId = avlNode.getPayloadByte(IDX_TYPE_ID_B);
-        if (typeId != nodeTypeId) {
-          return typeId < nodeTypeId ? -1 : 1;
-        }
+        if (typeId != nodeTypeId) return typeId < nodeTypeId ? -1 : 1;
 
         // Finally, defer to the SPComparator.
         int dataSize = avlNode.getPayloadInt(IDX_DATA_SIZE_I);
@@ -2941,10 +2662,7 @@
 
         // Retrieve bytes from the AVLNode.
         nodeData.limit(directDataSize);
-        avlNode.getBlock().get(
-            (AVLNode.HEADER_SIZE + IDX_DATA) * Constants.SIZEOF_LONG,
-            nodeData
-        );
+        avlNode.getBlock().get((AVLNode.HEADER_SIZE + IDX_DATA) * Constants.SIZEOF_LONG, nodeData);
 
         if (dataSize > MAX_DIRECT_DATA_BYTES) {
           // Save the limit of data so it can be restored later in case it is
@@ -2964,7 +2682,7 @@
             // smaller by the comparePrefix method.
             nodeData.limit(dataSize);
             nodeData.position(directDataSize);
-            retrieveRemainingBytes(objectPool, nodeData, blockId);
+            retrieveRemainingBytes(nodeData, blockId);
           } catch (IOException ex) {
             throw new Error("I/O Error while retrieving SPObject data", ex);
           }
@@ -2982,8 +2700,7 @@
 
       private AVLFile.Phase.Token avlFileToken;
 
-      private ManagedBlockFile.Phase.Token[] blockFileTokens =
-          new ManagedBlockFile.Phase.Token[NR_BLOCK_FILES];
+      private ManagedBlockFile.Phase.Token[] blockFileTokens = new ManagedBlockFile.Phase.Token[NR_BLOCK_FILES];
 
 
       /**
@@ -2991,9 +2708,7 @@
        */
       Token() {
         avlFileToken = avlFilePhase.use();
-        for (int i = 0; i < NR_BLOCK_FILES; ++i) {
-          blockFileTokens[i] = blockFilePhases[i].use();
-        }
+        for (int i = 0; i < NR_BLOCK_FILES; ++i)  blockFileTokens[i] = blockFilePhases[i].use();
       }
 
 
@@ -3025,34 +2740,28 @@
   static final class SPO2GNCache {
     private static final int DEFAULT_MAX_SIZE = 1000;
     private static final int MAX_SIZE;
-    private Reference cacheRef;
+    private Reference<Cache<SPObject,Long>> cacheRef;
 
     static {
       String cacheSizeProp = System.getProperty("mulgara.sp.localizeCacheSize");
-      if (cacheSizeProp == null) {
-        cacheSizeProp = System.getProperty("mulgara.sp.cacheSize");
-      }
+      if (cacheSizeProp == null) cacheSizeProp = System.getProperty("mulgara.sp.cacheSize");
       if (cacheSizeProp != null) {
         MAX_SIZE = Integer.parseInt(cacheSizeProp);
-        if (MAX_SIZE < 1) {
-          throw new ExceptionInInitializerError(
-              "bad mulgara.sp.cacheSize property: " + cacheSizeProp
-          );
-        }
+        if (MAX_SIZE < 1) throw new ExceptionInInitializerError("bad mulgara.sp.cacheSize property: " + cacheSizeProp);
       } else {
         MAX_SIZE = DEFAULT_MAX_SIZE;
       }
     }
 
     public SPO2GNCache() {
-      cacheRef = new SoftReference(new Cache(MAX_SIZE));
+      cacheRef = new SoftReference<Cache<SPObject,Long>>(new Cache<SPObject,Long>(MAX_SIZE));
     }
 
-    private Cache getCache() {
-      Cache cache = (Cache)cacheRef.get();
+    private Cache<SPObject,Long> getCache() {
+      Cache<SPObject,Long> cache = cacheRef.get();
       if (cache == null) {
-        cache = new Cache(MAX_SIZE);
-        cacheRef = new SoftReference(cache);
+        cache = new Cache<SPObject,Long>(MAX_SIZE);
+        cacheRef = new SoftReference<Cache<SPObject,Long>>(cache);
       }
       return cache;
     }
@@ -3066,7 +2775,7 @@
       assert gNodeL != null;
       assert spObject != null;
 
-      Object old = getCache().put(spObject, gNodeL);
+      Long old = getCache().put(spObject, gNodeL);
       assert old == null || old.equals(gNodeL);
     }
 
@@ -3077,7 +2786,7 @@
 
     public synchronized Long get(SPObject spObject) {
       assert spObject != null;
-      return (Long)getCache().get(spObject);
+      return getCache().get(spObject);
     }
 
   }
@@ -3086,34 +2795,28 @@
   static final class GN2SPOCache {
     private static final int DEFAULT_MAX_SIZE = 1000;
     private static final int MAX_SIZE;
-    private Reference cacheRef;
+    private Reference<Cache<Long,SPObject>> cacheRef;
 
     static {
       String cacheSizeProp = System.getProperty("mulgara.sp.globalizeCacheSize");
-      if (cacheSizeProp == null) {
-        cacheSizeProp = System.getProperty("mulgara.sp.cacheSize");
-      }
+      if (cacheSizeProp == null) cacheSizeProp = System.getProperty("mulgara.sp.cacheSize");
       if (cacheSizeProp != null) {
         MAX_SIZE = Integer.parseInt(cacheSizeProp);
-        if (MAX_SIZE < 1) {
-          throw new ExceptionInInitializerError(
-              "bad mulgara.sp.cacheSize property: " + cacheSizeProp
-          );
-        }
+        if (MAX_SIZE < 1) throw new ExceptionInInitializerError("bad mulgara.sp.cacheSize property: " + cacheSizeProp);
       } else {
         MAX_SIZE = DEFAULT_MAX_SIZE;
       }
     }
 
     public GN2SPOCache() {
-      cacheRef = new SoftReference(new Cache(MAX_SIZE));
+      cacheRef = new SoftReference<Cache<Long,SPObject>>(new Cache<Long,SPObject>(MAX_SIZE));
     }
 
-    private Cache getCache() {
-      Cache cache = (Cache)cacheRef.get();
+    private Cache<Long,SPObject> getCache() {
+      Cache<Long,SPObject> cache = cacheRef.get();
       if (cache == null) {
-        cache = new Cache(MAX_SIZE);
-        cacheRef = new SoftReference(cache);
+        cache = new Cache<Long,SPObject>(MAX_SIZE);
+        cacheRef = new SoftReference<Cache<Long,SPObject>>(cache);
       }
       return cache;
     }
@@ -3127,7 +2830,7 @@
       assert gNodeL != null;
       assert spObject != null;
 
-      Object old = getCache().put(gNodeL, spObject);
+      SPObject old = getCache().put(gNodeL, spObject);
       assert old == null || old.equals(spObject);
     }
 
@@ -3148,7 +2851,7 @@
 
     public synchronized void putBlankNode(Long gNodeL) {
       assert gNodeL != null;
-      Object old = getCache().put(gNodeL, null);
+      SPObject old = getCache().put(gNodeL, null);
       assert old == null;
     }
 
@@ -3158,7 +2861,7 @@
 
     public synchronized SPObject get(Long gNodeL) {
       assert gNodeL != null;
-      return (SPObject)getCache().get(gNodeL);
+      return getCache().get(gNodeL);
     }
 
     public boolean isBlankNode(long gNode) {
@@ -3168,7 +2871,7 @@
     public synchronized boolean isBlankNode(Long gNodeL) {
       assert gNodeL != null;
       Cache cache = getCache();
-      return cache.get(gNodeL) == null && cache.containsKey(gNodeL);
+      return cache.containsKey(gNodeL) && cache.get(gNodeL) == null;
     }
 
   }
@@ -3177,7 +2880,8 @@
   /**
    * A LRU cache.
    */
-  static final class Cache extends LinkedHashMap {
+  @SuppressWarnings("serial")
+  static final class Cache<K,V> extends LinkedHashMap<K,V> {
 
     /** The load factor on the internal hash table. */
     public static final float LOAD_FACTOR = 0.75F;
@@ -3201,7 +2905,7 @@
      * @param eldest The eldest entry in the map.  Ignored.
      * @return <code>true</code> when the cache is overfull and data should be removed.
      */
-    protected boolean removeEldestEntry(Map.Entry eldest) {
+    protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
       return size() > MAX_SIZE;
     }
 

Modified: trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
===================================================================
--- trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -9,7 +9,6 @@
 import org.mulgara.store.tuples.DenseLongMatrix;
 import org.mulgara.store.xa.Block;
 import org.mulgara.store.xa.BlockFile;
-import org.mulgara.store.xa.ObjectPool;
 
 /**
  * Split memory backed from file backed cache lines.
@@ -37,7 +36,6 @@
   protected long[] prefix;
   protected BlockFile file;
   protected Block block;
-  protected ObjectPool objectPool;
   protected long initialBlockId;
   protected long nextBlockId;
   protected int nrBlocks;
@@ -51,7 +49,6 @@
 
 
   public BlockCacheLine(BlockFile file,
-                        ObjectPool objectPool,
                         int blockSize,
                         DenseLongMatrix buffer,
                         int size) throws TuplesException {
@@ -70,8 +67,6 @@
     if (this.initialBlockId < 0) {
       this.initialBlockId = 0;
     }
-    this.objectPool = objectPool;
-    this.objectPool.incRefCount();
     this.currentTuple = new long[width];
     this.previousTuple = new long[width];
     try {
@@ -83,7 +78,7 @@
 
     this.nextBlockId = this.initialBlockId;
     try {
-      this.block = file.readBlock(this.objectPool, this.nextBlockId++);
+      this.block = file.readBlock(this.nextBlockId++);
     } catch (IOException ie) {
       logger.warn("Failed to read Temporary File");
       throw new TuplesException("Failed to read Temporary File", ie);
@@ -106,7 +101,6 @@
     try {
       if (isEmpty()) {
         logger.debug("advancing empty tuples");
-        block.release();
         block = null;
         return;
       }
@@ -114,12 +108,11 @@
       // If just cloned, then read in previous block.
       if (block == null) {
         logger.debug("BlockCache " + this + " Refreshing from clone block " + (nextBlockId - 1));
-        block = file.readBlock(objectPool, nextBlockId - 1);
+        block = file.readBlock(nextBlockId - 1);
       }
 
       if (endOfBlock(offset)) {
-        block.release();
-        block = file.readBlock(objectPool, nextBlockId++);
+        block = file.readBlock(nextBlockId++);
         offset = 0;
       }
 
@@ -151,10 +144,7 @@
 
     try {
       if (this.prefix == null) {
-        if (block != null) {
-          block.release();
-        }
-        block = file.readBlock(objectPool, initialBlockId);
+        block = file.readBlock(initialBlockId);
         offset = 0;
         nextTuple = 0;
       } else {
@@ -185,20 +175,14 @@
   public void close(int closer) throws TuplesException {
     super.close(closer);
     if (block != null) {
-      block.release();
       block = null;
       file = null;
     }
-    if (objectPool != null) {
-      objectPool.release();
-      objectPool = null;
-    }
   }
 
 
   public Object clone() {
     BlockCacheLine b = (BlockCacheLine)super.clone();
-    b.objectPool.incRefCount();
     b.block = null;
     b.currentTuple =  (long[])currentTuple.clone();
     b.previousTuple = (long[])previousTuple.clone();
@@ -216,14 +200,13 @@
     file.setNrBlocks(this.initialBlockId + nrBlocks + 1);
 
     long blockId = this.initialBlockId;
-    Block block = file.allocateBlock(objectPool, blockId++);
+    Block block = file.allocateBlock(blockId++);
     int offset = 0;
 
     for (int i = 0; i < size; i++) {
       if (endOfBlock(offset)) {
         block.write();
-        block.release();
-        block = file.allocateBlock(this.objectPool, blockId++);
+        block = file.allocateBlock(blockId++);
         offset = 0;
       }
       for (int j = 0; j < this.width; j++) {
@@ -231,7 +214,6 @@
       }
     }
     block.write();
-    block.release();
 
     return offset;
   }
@@ -265,18 +247,16 @@
     try {
       assert prefix.length > 0 && prefix.length <= width;
 
-      Block first = file.readBlock(objectPool, initialBlockId);
+      Block first = file.readBlock(initialBlockId);
       long[] tmp = new long[width];
       loadTupleFromBlock(tmp, first, 0);
       if (logger.isDebugEnabled()) {
         logger.debug("Initial tuple for block " + first.getBlockId() + " : " + AbstractTuples.toString(tmp));
       }
-      if (compareBlockWithPrefix(first, prefix) >= 0) {
-          return first;
-      }
+      if (compareBlockWithPrefix(first, prefix) >= 0) return first;
 
       final long lastBlockId = initialBlockId + nrBlocks - 1;
-      Block last = file.readBlock(objectPool, lastBlockId);
+      Block last = file.readBlock(lastBlockId);
       boolean found;
       switch (compareBlockWithPrefix(last, prefix)) {
         case -1:
@@ -319,26 +299,20 @@
           " lowBound: " + lowBound + " highBound: " + highBound);
     }
     try {
-      if (highBound - lowBound <= 1) {
-        lowBlock.release();
-        return highBlock;
-      }
+      if (highBound - lowBound <= 1) return highBlock;
 
       long midBound = (int)((lowBound + highBound) / 2);
-      Block midBlock = file.readBlock(objectPool, midBound);
+      Block midBlock = file.readBlock(midBound);
 
       switch (compareBlockWithPrefix(midBlock, prefix)) {
         case -1:
-          lowBlock.release();
           return findBlock(prefix, found, midBound, midBlock, highBound, highBlock);
 
         case 0:
-          highBlock.release();
           return findBlock(prefix, true, lowBound, lowBlock, midBound, midBlock);
 
         case +1:
           assert !found;
-          highBlock.release();
           return findBlock(prefix, false, lowBound, lowBlock, midBound, midBlock);
 
         default:

Modified: trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java
===================================================================
--- trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -51,7 +51,6 @@
 import org.mulgara.store.tuples.TuplesOperations;
 import org.mulgara.store.xa.AbstractBlockFile;
 import org.mulgara.store.xa.BlockFile;
-import org.mulgara.store.xa.ObjectPool;
 import org.mulgara.util.TempDir;
 
 /**
@@ -92,7 +91,6 @@
 
   protected BlockFile blockFile;
   protected RefCount blockFileRefCount;
-  protected ObjectPool objectPool;
 
   // Would be final except for clone
   // can be final once clone semantics migrated into CacheLine.
@@ -277,9 +275,6 @@
         copy.heapCache[i] = (CacheLine)heapCache[i].clone();
       }
       copy.currTuple = copy.heapCache[0].getCurrentTuple(null);
-      if (objectPool != null) {
-        objectPool.incRefCount();
-      }
       if (blockFile != null) {
         blockFileRefCount.refCount++;
       }
@@ -324,10 +319,6 @@
     }
     heapCache = null;
     currTuple = null;
-    if (objectPool != null) {
-      objectPool.release();
-      objectPool = null;
-    }
 
     tuples.close();
     tuples = null;
@@ -572,11 +563,11 @@
 
       ArrayList tmpHeap = new ArrayList();
 
-      tmpHeap.add(new BlockCacheLine(blockFile, objectPool, BLOCK_SIZE, buffer, size));
+      tmpHeap.add(new BlockCacheLine(blockFile, BLOCK_SIZE, buffer, size));
       do {
         size = primeBuffer(buffer, tuples);
         if (size > 0) {
-          tmpHeap.add(new BlockCacheLine(blockFile, objectPool, BLOCK_SIZE, buffer, size));
+          tmpHeap.add(new BlockCacheLine(blockFile, BLOCK_SIZE, buffer, size));
         }
       } while (size == buffer.getLength());
 
@@ -829,7 +820,6 @@
       logger.warn("Failed to open temporary block file.", ie);
       throw new TuplesException("Failed to open temporary block file.", ie);
     }
-    this.objectPool = ObjectPool.newInstance();
   }
 
 

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
 
 // Third party packages
 import org.apache.log4j.Logger;
@@ -68,12 +66,14 @@
 public final class AVLFile {
 
   /** Logger.  */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(AVLFile.class);
 
   /** The underlying block file */
   private ManagedBlockFile avlBlockFile;
 
   /** The size of the user data stored in each node of the tree. */
+  @SuppressWarnings("unused")  // keep this member, since it isn't kept elsewhere
   private int payloadSize;
 
   /** The most recent phase for the file. */
@@ -83,38 +83,29 @@
   /**
    * Creates a new block file which contains an AVL tree.
    *
-   * @param objectPool An existing object pool to get blocks from.
    * @param file A {@link java.io.File} object giving the details of the file.
    * @param payloadSize Size of the payload in longs.  Must be at least 1.
    * @throws IOException If an i/o error occurs.
    */
-  public AVLFile(
-      ObjectPool objectPool, File file, int payloadSize
-  ) throws IOException {
+  public AVLFile(File file, int payloadSize) throws IOException {
     if (payloadSize < 1) {
       throw new IllegalArgumentException("payloadSize is less than 1");
     }
 
-    avlBlockFile = new ManagedBlockFile(
-        objectPool, file,
-        (AVLNode.HEADER_SIZE + payloadSize) * Constants.SIZEOF_LONG,
-        BlockFile.IOType.MAPPED
-    );
+    avlBlockFile = new ManagedBlockFile(file, (AVLNode.HEADER_SIZE + payloadSize) * Constants.SIZEOF_LONG,
+        BlockFile.IOType.MAPPED);
     this.payloadSize = payloadSize;
   }
 
   /**
    * Creates a new block file which contains an AVL tree.
    *
-   * @param objectPool An existing object pool to get blocks from.
    * @param fileName The name of the file to create.
    * @param payloadSize Size of the payload in longs.  Must be at least 1.
    * @throws IOException If an i/o error occurs.
    */
-  public AVLFile(
-      ObjectPool objectPool, String fileName, int payloadSize
-  ) throws IOException {
-    this(objectPool, new File(fileName), payloadSize);
+  public AVLFile(String fileName, int payloadSize) throws IOException {
+    this(new File(fileName), payloadSize);
   }
 
   /**
@@ -297,12 +288,10 @@
     /**
      * Get the AVLNode of the root of this phase tree.
      *
-     * @param objectPool The pool to get the block for the AVLNode from.
      * @return The AVL node at the root of this tree.
      */
-    public AVLNode getRootNode(ObjectPool objectPool) {
-      return rootId != AVLNode.NULL_NODE ?
-          AVLNode.newInstance(this, objectPool, null, 0, rootId) : null;
+    public AVLNode getRootNode() {
+      return rootId != AVLNode.NULL_NODE ? AVLNode.newInstance(this, null, 0, rootId) : null;
     }
 
     /**
@@ -357,17 +346,15 @@
     /**
      * Finds an AVLNode containing the requested data.
      *
-     * @param objectPool The pool to get the AVLNodes from.
      * @param comparator The means of comparing the key to the payload in the AVLNodes.
      * @param key The data to search for.
      * @return An array of nodes.  If the tree is empty, then <code>null</code>.
      *     If the data exists, then a single element array containing the required node.
      *     If the data does not exist then return the pair of nodes that the data exists between.
      */
-    public AVLNode[] find(
-        ObjectPool objectPool, AVLComparator comparator, long[] key
-    ) {
-      AVLNode rootNode = getRootNode(objectPool);
+    public AVLNode[] find(AVLComparator comparator, long[] key) {
+
+      AVLNode rootNode = getRootNode();
       if (rootNode == null) return null;
 
       try {
@@ -380,13 +367,11 @@
     /**
      * Get a new AVLNode, unattached to any data.
      *
-     * @param objectPool The pool to find the AVLNode in.
      * @return The new node.
      * @throws IOException If an I/O error occurred.
      */
-    public AVLNode newAVLNodeInstance(ObjectPool objectPool)
-        throws IOException {
-      return AVLNode.newInstance(this, objectPool);
+    public AVLNode newAVLNodeInstance() throws IOException {
+      return AVLNode.newInstance(this);
     }
 
     /**

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFileTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFileTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLFileTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.util.*;
 
 // Third party packages
 import junit.framework.*;
@@ -64,6 +62,7 @@
   /**
    * Logger.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(AVLFileTest.class);
 
   /**
@@ -76,9 +75,7 @@
    * Description of the Field
    *
    */
-  private static Block metaroot =
-      Block.newInstance(ObjectPool.newInstance(),
-      AVLFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
+  private static Block metaroot = Block.newInstance(AVLFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
 
   /**
    * Description of the Field
@@ -87,12 +84,6 @@
   private AVLFile avlFile;
 
   /**
-   * Description of the Field
-   *
-   */
-  private ObjectPool objectPool = null;
-
-  /**
    * Named constructor.
    *
    * @param name The name of the test.
@@ -152,8 +143,7 @@
     try {
 
       File dir = TempDir.getTempDir();
-      objectPool = ObjectPool.newInstance();
-      avlFile = new AVLFile(objectPool, new File(dir, "avlfiletest"), 1);
+      avlFile = new AVLFile(new File(dir, "avlfiletest"), 1);
       exceptionOccurred = false;
     }
     finally {
@@ -176,12 +166,6 @@
 
       try {
 
-        if (objectPool != null) {
-
-          objectPool.release();
-          objectPool = null;
-        }
-
         avlFile.unmap();
 
         if (System.getProperty("os.name").startsWith("Win")) {
@@ -210,32 +194,32 @@
     AVLFile.Phase phase0 = avlFile.new Phase();
     avlFile.clear();
 
-    //AVLNode node = phase0.newAVLNodeInstance(objectPool);
-    insert(objectPool, phase0, 60);
-    assertEquals(1, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 50);
-    assertEquals(2, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 70);
-    assertEquals(2, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 80);
-    assertEquals(3, getHeight(objectPool, phase0));
+    //AVLNode node = phase0.newAVLNodeInstance();
+    insert(phase0, 60);
+    assertEquals(1, getHeight(phase0));
+    insert(phase0, 50);
+    assertEquals(2, getHeight(phase0));
+    insert(phase0, 70);
+    assertEquals(2, getHeight(phase0));
+    insert(phase0, 80);
+    assertEquals(3, getHeight(phase0));
 
     // test RR rotation
-    insert(objectPool, phase0, 90);
-    assertEquals(3, getHeight(objectPool, phase0));
+    insert(phase0, 90);
+    assertEquals(3, getHeight(phase0));
 
     // test RL rotation
-    insert(objectPool, phase0, 65);
-    assertEquals(3, getHeight(objectPool, phase0));
+    insert(phase0, 65);
+    assertEquals(3, getHeight(phase0));
 
-    insert(objectPool, phase0, 75);
-    assertEquals(3, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 77);
-    assertEquals(4, getHeight(objectPool, phase0));
+    insert(phase0, 75);
+    assertEquals(3, getHeight(phase0));
+    insert(phase0, 77);
+    assertEquals(4, getHeight(phase0));
 
     try {
 
-      insert(objectPool, phase0, 50);
+      insert(phase0, 50);
       fail("Able to insert the same node values twice");
     }
     catch (IllegalArgumentException e) {
@@ -253,20 +237,20 @@
     AVLFile.Phase phase0 = avlFile.new Phase();
     avlFile.clear();
 
-    AVLNode[] nodes = find(objectPool, phase0, 5);
+    AVLNode[] nodes = find(phase0, 5);
 
     if (nodes != null) {
 
       fail("Found node in empty tree");
     }
 
-    insert(objectPool, phase0, 6);
-    insert(objectPool, phase0, 5);
-    insert(objectPool, phase0, 8);
+    insert(phase0, 6);
+    insert(phase0, 5);
+    insert(phase0, 8);
 
-    assertFound(find(objectPool, phase0, 5), 5);
+    assertFound(find(phase0, 5), 5);
 
-    assertNotFound(find(objectPool, phase0, 7), 6, 8);
+    assertNotFound(find(phase0, 7), 6, 8);
   }
 
   /**
@@ -279,82 +263,82 @@
     AVLFile.Phase phase0 = avlFile.new Phase();
     avlFile.clear();
 
-    insert(objectPool, phase0, 60);
-    assertEquals(1, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 50);
-    assertEquals(2, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 70);
-    assertEquals(2, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 80);
-    assertEquals(3, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 90);
-    assertEquals(3, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 65);
-    assertEquals(3, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 75);
-    assertEquals(3, getHeight(objectPool, phase0));
-    insert(objectPool, phase0, 77);
-    assertEquals(4, getHeight(objectPool, phase0));
+    insert(phase0, 60);
+    assertEquals(1, getHeight(phase0));
+    insert(phase0, 50);
+    assertEquals(2, getHeight(phase0));
+    insert(phase0, 70);
+    assertEquals(2, getHeight(phase0));
+    insert(phase0, 80);
+    assertEquals(3, getHeight(phase0));
+    insert(phase0, 90);
+    assertEquals(3, getHeight(phase0));
+    insert(phase0, 65);
+    assertEquals(3, getHeight(phase0));
+    insert(phase0, 75);
+    assertEquals(3, getHeight(phase0));
+    insert(phase0, 77);
+    assertEquals(4, getHeight(phase0));
 
-    find(objectPool, phase0, 60)[0].remove();
-    assertEquals(4, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 60), 50, 65);
-    assertFound(find(objectPool, phase0, 65), 65);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
-    assertFound(find(objectPool, phase0, 90), 90);
-    assertFound(find(objectPool, phase0, 65), 65);
-    assertFound(find(objectPool, phase0, 75), 75);
-    assertFound(find(objectPool, phase0, 77), 77);
+    find(phase0, 60)[0].remove();
+    assertEquals(4, getHeight(phase0));
+    assertNotFound(find(phase0, 60), 50, 65);
+    assertFound(find(phase0, 65), 65);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
+    assertFound(find(phase0, 90), 90);
+    assertFound(find(phase0, 65), 65);
+    assertFound(find(phase0, 75), 75);
+    assertFound(find(phase0, 77), 77);
 
-    find(objectPool, phase0, 50)[0].remove();
-    assertEquals(3, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 50), 0, 65);
-    assertFound(find(objectPool, phase0, 65), 65);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 75), 75);
-    assertFound(find(objectPool, phase0, 77), 77);
-    assertFound(find(objectPool, phase0, 80), 80);
-    assertFound(find(objectPool, phase0, 90), 90);
+    find(phase0, 50)[0].remove();
+    assertEquals(3, getHeight(phase0));
+    assertNotFound(find(phase0, 50), 0, 65);
+    assertFound(find(phase0, 65), 65);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 75), 75);
+    assertFound(find(phase0, 77), 77);
+    assertFound(find(phase0, 80), 80);
+    assertFound(find(phase0, 90), 90);
 
-    find(objectPool, phase0, 75)[0].remove();
-    assertEquals(3, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 75), 70, 77);
-    assertFound(find(objectPool, phase0, 65), 65);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 77), 77);
-    assertFound(find(objectPool, phase0, 80), 80);
-    assertFound(find(objectPool, phase0, 90), 90);
+    find(phase0, 75)[0].remove();
+    assertEquals(3, getHeight(phase0));
+    assertNotFound(find(phase0, 75), 70, 77);
+    assertFound(find(phase0, 65), 65);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 77), 77);
+    assertFound(find(phase0, 80), 80);
+    assertFound(find(phase0, 90), 90);
 
-    find(objectPool, phase0, 65)[0].remove();
-    assertEquals(3, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 65), 0, 70);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 77), 77);
-    assertFound(find(objectPool, phase0, 80), 80);
-    assertFound(find(objectPool, phase0, 90), 90);
+    find(phase0, 65)[0].remove();
+    assertEquals(3, getHeight(phase0));
+    assertNotFound(find(phase0, 65), 0, 70);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 77), 77);
+    assertFound(find(phase0, 80), 80);
+    assertFound(find(phase0, 90), 90);
 
-    find(objectPool, phase0, 90)[0].remove();
-    assertEquals(2, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 90), 80, 0);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 77), 77);
-    assertFound(find(objectPool, phase0, 80), 80);
+    find(phase0, 90)[0].remove();
+    assertEquals(2, getHeight(phase0));
+    assertNotFound(find(phase0, 90), 80, 0);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 77), 77);
+    assertFound(find(phase0, 80), 80);
 
-    find(objectPool, phase0, 80)[0].remove();
-    assertEquals(2, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 80), 77, 0);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 77), 77);
+    find(phase0, 80)[0].remove();
+    assertEquals(2, getHeight(phase0));
+    assertNotFound(find(phase0, 80), 77, 0);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 77), 77);
 
-    find(objectPool, phase0, 70)[0].remove();
-    assertEquals(1, getHeight(objectPool, phase0));
-    assertNotFound(find(objectPool, phase0, 70), 0, 77);
-    assertFound(find(objectPool, phase0, 77), 77);
+    find(phase0, 70)[0].remove();
+    assertEquals(1, getHeight(phase0));
+    assertNotFound(find(phase0, 70), 0, 77);
+    assertFound(find(phase0, 77), 77);
 
-    find(objectPool, phase0, 77)[0].remove();
-    assertNull(phase0.getRootNode(objectPool));
-    assertNull(find(objectPool, phase0, 77));
+    find(phase0, 77)[0].remove();
+    assertNull(phase0.getRootNode());
+    assertNull(find(phase0, 77));
   }
 
   /**
@@ -367,27 +351,27 @@
     AVLFile.Phase phase0 = avlFile.new Phase();
     avlFile.clear();
 
-    insert(objectPool, phase0, 60);
-    insert(objectPool, phase0, 50);
-    insert(objectPool, phase0, 70);
-    insert(objectPool, phase0, 80);
+    insert(phase0, 60);
+    insert(phase0, 50);
+    insert(phase0, 70);
+    insert(phase0, 80);
 
-    assertFound(find(objectPool, phase0, 60), 60);
-    assertFound(find(objectPool, phase0, 50), 50);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
+    assertFound(find(phase0, 60), 60);
+    assertFound(find(phase0, 50), 50);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
 
-    find(objectPool, phase0, 60)[0].remove();
-    assertNotFound(find(objectPool, phase0, 60), 50, 70);
-    assertFound(find(objectPool, phase0, 50), 50);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
+    find(phase0, 60)[0].remove();
+    assertNotFound(find(phase0, 60), 50, 70);
+    assertFound(find(phase0, 50), 50);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
 
-    insert(objectPool, phase0, 60);
-    assertFound(find(objectPool, phase0, 60), 60);
-    assertFound(find(objectPool, phase0, 50), 50);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
+    insert(phase0, 60);
+    assertFound(find(phase0, 60), 60);
+    assertFound(find(phase0, 50), 50);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
 
     // set up for testPersist()
     phase0.writeToBlock(metaroot, 0);
@@ -401,13 +385,14 @@
   public void testPersist() throws IOException {
 
     AVLFile.Phase phase0 = avlFile.new Phase(metaroot, 0);
+    @SuppressWarnings("unused")
     AVLFile.Phase.Token token0 = phase0.use();
     AVLFile.Phase phase1 = avlFile.new Phase();
 
-    assertFound(find(objectPool, phase1, 60), 60);
-    assertFound(find(objectPool, phase1, 50), 50);
-    assertFound(find(objectPool, phase1, 70), 70);
-    assertFound(find(objectPool, phase1, 80), 80);
+    assertFound(find(phase1, 60), 60);
+    assertFound(find(phase1, 50), 50);
+    assertFound(find(phase1, 70), 70);
+    assertFound(find(phase1, 80), 80);
   }
 
   /**
@@ -420,39 +405,40 @@
     AVLFile.Phase phase0 = avlFile.new Phase();
     avlFile.clear();
 
-    insert(objectPool, phase0, 60);
-    insert(objectPool, phase0, 50);
-    insert(objectPool, phase0, 70);
-    insert(objectPool, phase0, 80);
+    insert(phase0, 60);
+    insert(phase0, 50);
+    insert(phase0, 70);
+    insert(phase0, 80);
 
-    assertFound(find(objectPool, phase0, 60), 60);
-    assertFound(find(objectPool, phase0, 50), 50);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
+    assertFound(find(phase0, 60), 60);
+    assertFound(find(phase0, 50), 50);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
 
+    @SuppressWarnings("unused")
     AVLFile.Phase.Token token0 = phase0.use();
     AVLFile.Phase phase1 = avlFile.new Phase();
 
-    find(objectPool, phase1, 60)[0].remove();
-    assertNotFound(find(objectPool, phase1, 60), 50, 70);
-    assertFound(find(objectPool, phase1, 50), 50);
-    assertFound(find(objectPool, phase1, 70), 70);
-    assertFound(find(objectPool, phase1, 80), 80);
+    find(phase1, 60)[0].remove();
+    assertNotFound(find(phase1, 60), 50, 70);
+    assertFound(find(phase1, 50), 50);
+    assertFound(find(phase1, 70), 70);
+    assertFound(find(phase1, 80), 80);
 
-    assertFound(find(objectPool, phase0, 60), 60);
-    assertFound(find(objectPool, phase0, 50), 50);
-    assertFound(find(objectPool, phase0, 70), 70);
-    assertFound(find(objectPool, phase0, 80), 80);
+    assertFound(find(phase0, 60), 60);
+    assertFound(find(phase0, 50), 50);
+    assertFound(find(phase0, 70), 70);
+    assertFound(find(phase0, 80), 80);
 
-    insert(objectPool, phase1, 60);
-    assertFound(find(objectPool, phase1, 60), 60);
-    assertFound(find(objectPool, phase1, 50), 50);
-    assertFound(find(objectPool, phase1, 70), 70);
-    assertFound(find(objectPool, phase1, 80), 80);
+    insert(phase1, 60);
+    assertFound(find(phase1, 60), 60);
+    assertFound(find(phase1, 50), 50);
+    assertFound(find(phase1, 70), 70);
+    assertFound(find(phase1, 80), 80);
 
     try {
 
-      find(objectPool, phase0, 60)[0].remove();
+      find(phase0, 60)[0].remove();
       fail("Able to remove from a read-only phase");
     }
     catch (IllegalStateException ex) {
@@ -461,7 +447,7 @@
 
     try {
 
-      insert(objectPool, phase0, 75);
+      insert(phase0, 75);
       fail("Able to insert into a read-only phase");
     }
     catch (IllegalStateException ex) {
@@ -476,7 +462,7 @@
    */
   void dumpTree(AVLFile.Phase phase) {
 
-    AVLNode node = phase.getRootNode(objectPool);
+    AVLNode node = phase.getRootNode();
     System.out.println(toString(node));
 
     if (node != null) {
@@ -520,13 +506,12 @@
   /**
    * Gets the Height attribute of the AVLFileTest object
    *
-   * @param objectPool PARAMETER TO DO
    * @param phase PARAMETER TO DO
    * @return The Height value
    */
-  private int getHeight(ObjectPool objectPool, AVLFile.Phase phase) {
+  private int getHeight(AVLFile.Phase phase) {
 
-    AVLNode rootNode = phase.getRootNode(objectPool);
+    AVLNode rootNode = phase.getRootNode();
     int height = rootNode.getHeight();
     rootNode.release();
 
@@ -536,19 +521,17 @@
   /**
    * METHOD TO DO
    *
-   * @param objectPool PARAMETER TO DO
    * @param phase PARAMETER TO DO
    * @param value PARAMETER TO DO
    * @throws IOException EXCEPTION TO DO
    */
-  private void insert(ObjectPool objectPool, AVLFile.Phase phase,
-      int value) throws IOException {
+  private void insert(AVLFile.Phase phase, int value) throws IOException {
 
-    AVLNode[] findResult = find(objectPool, phase, value);
+    AVLNode[] findResult = find(phase, value);
 
     try {
 
-      AVLNode newNode = phase.newAVLNodeInstance(objectPool);
+      AVLNode newNode = phase.newAVLNodeInstance();
 
       try {
 
@@ -583,15 +566,13 @@
   /**
    * METHOD TO DO
    *
-   * @param objectPool PARAMETER TO DO
    * @param phase PARAMETER TO DO
    * @param value PARAMETER TO DO
    * @return RETURNED VALUE TO DO
    */
-  private AVLNode[] find(ObjectPool objectPool, AVLFile.Phase phase, int value) {
+  private AVLNode[] find(AVLFile.Phase phase, int value) {
 
-    return phase.find(objectPool, comparator, new long[] {
-        value});
+    return phase.find(comparator, new long[] {value});
   }
 
   /**
@@ -610,8 +591,7 @@
           ? ("(" + getKey(nodes[0]) + ", " + getKey(nodes[1]) + ")") : ""), 1,
           nodes.length);
       assertEquals("Incorrect node found", value, getKey(nodes[0]));
-    }
-    finally {
+    } finally {
 
       AVLFile.release(nodes);
     }

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLNode.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLNode.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/AVLNode.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -92,6 +92,7 @@
   final static long NULL_NODE = Block.INVALID_BLOCK_ID;
 
   /** The logger. */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(AVLNode.class);
 
   /** The most recent phase that this node belongs to. */
@@ -118,9 +119,6 @@
   /** Whether or not this node has been modified. */
   private boolean dirty;
 
-  /** The pool of objects this node came from. */
-  private ObjectPool objectPool;
-
   //  private Throwable trace;
 
   /** The number of references to this node. */
@@ -136,83 +134,50 @@
    * Creates a new AVLNode for a given AVLFile phase, and data in the file.
    *
    * @param phase The phase from the AVLFile.
-   * @param objectPool The object pool to return this node to when it's finished with.
    * @param parentNode The parent node to this node.
    * @param childIndex The index (left or right) of this node in relation to its parent.
    * @param nodeId The ID of this node, used for finding it in the file..
    */
-  private AVLNode(
-      AVLFile.Phase phase, ObjectPool objectPool,
-      AVLNode parentNode, int childIndex, long nodeId
-  ) {
-    init(phase, objectPool, parentNode, childIndex, nodeId);
+  private AVLNode(AVLFile.Phase phase, AVLNode parentNode, int childIndex, long nodeId) {
+    init(phase, parentNode, childIndex, nodeId);
   }
 
   /**
    * Constructs a new node for a given AVLFile phase.
    *
    * @param phase The phase form the AVLFile.
-   * @param objectPool The object pool to return this node to when it's finished with.
    * @throws IOException If there was an I/O exception.
    */
-  private AVLNode(
-      AVLFile.Phase phase, ObjectPool objectPool
-  ) throws IOException {
-    init(phase, objectPool);
+  private AVLNode(AVLFile.Phase phase) throws IOException {
+    init(phase);
   }
 
   /**
    * Factory method for an AVLNode.
    *
    * @param phase The phase form the AVLFile.
-   * @param objectPool The object pool to return this node to when it's finished with.
    * @return The new node, backed by a new block in the file.
    * @throws IOException If there was an I/O exception.
    */
-  public static AVLNode newInstance(
-      AVLFile.Phase phase, ObjectPool objectPool
-  ) throws IOException {
+  public static AVLNode newInstance(AVLFile.Phase phase) throws IOException {
     if (!phase.isCurrent()) {
-      throw new IllegalStateException(
-          "Attempt to allocate a new AVL node on a read-only phase."
-      );
+      throw new IllegalStateException("Attempt to allocate a new AVL node on a read-only phase.");
     }
-
-    AVLNode avlNode = (AVLNode) objectPool.get(ObjectPool.TYPE_AVLNODE);
-
-    if (avlNode != null) {
-      avlNode.init(phase, objectPool);
-    } else {
-      avlNode = new AVLNode(phase, objectPool);
-    }
-
-    return avlNode;
+    return new AVLNode(phase);
   }
 
   /**
    * Factory method for an AVLNode.
    *
    * @param phase The phase form the AVLFile.
-   * @param objectPool The object pool to return this node to when it's finished with.
    * @param parentNode The parent to this node.
    * @param childIndex The index of this node within its parent, either left or right.
    * @param nodeId The ID to find the data for this node in the file.
    * @return The new node, read from file, or with new file info in it.
    * @throws IOException If there was an I/O exception.
    */
-  static AVLNode newInstance(
-      AVLFile.Phase phase, ObjectPool objectPool,
-      AVLNode parentNode, int childIndex, long nodeId
-  ) {
-    AVLNode avlNode = (AVLNode) objectPool.get(ObjectPool.TYPE_AVLNODE);
-
-    if (avlNode != null) {
-      avlNode.init(phase, objectPool, parentNode, childIndex, nodeId);
-    } else {
-      avlNode = new AVLNode(phase, objectPool, parentNode, childIndex, nodeId);
-    }
-
-    return avlNode;
+  static AVLNode newInstance(AVLFile.Phase phase, AVLNode parentNode, int childIndex, long nodeId) {
+    return new AVLNode(phase, parentNode, childIndex, nodeId);
   }
 
   /**
@@ -1006,11 +971,8 @@
 
     do {
       assert avlNode.refCount > 0;
-      assert avlNode.objectPool != null;
 
-      if (--avlNode.refCount > 0) {
-        return;
-      }
+      if (--avlNode.refCount > 0) return;
 
       assert avlNode.leftChildNode == null;
       assert avlNode.rightChildNode == null;
@@ -1026,19 +988,11 @@
           }
         }
 
-        avlNode.block.release();
         avlNode.block = null;
       }
 
       avlNode.writable = false;
 
-      // NOTE: it is currently safe to modify objects after they have been put
-      // into a local pool since no other thread can get objects from the pool
-      // and the objects don't migrate to the global pool until the local pool
-      // has been released.
-      avlNode.objectPool.put(ObjectPool.TYPE_AVLNODE, avlNode);
-      avlNode.objectPool = null;
-
       //X     avlNode.trace = null;
       AVLNode prevNode = avlNode;
       avlNode = avlNode.parentNode;
@@ -1068,15 +1022,6 @@
   }
 
   /**
-   * Gets the ObjectPool for this AVLNode
-   *
-   * @return The ObjectPool value
-   */
-  ObjectPool getObjectPool() {
-    return objectPool;
-  }
-
-  /**
    * Gets the ID of the left child node to this node.
    *
    * @return The ID of the left child node.
@@ -1168,15 +1113,13 @@
 
     long nodeId = block.getLong(index);
 
-    return nodeId == NULL_NODE ? null :
-        newInstance(phase, objectPool, this, index, nodeId);
+    return nodeId == NULL_NODE ? null : newInstance(phase, this, index, nodeId);
   }
 
   /**
    * Initialises a node on the given information.
    *
    * @param phase The phase that the node exists in.
-   * @param objectPool The pool that the node will return to.
    * @param parentNode The parent node for this node.  Only
    *     <code>null</code> at the root of the tree.
    * @param childIndex Indicates if this is to the left or the
@@ -1184,18 +1127,13 @@
    *     {@link #IDX_RIGHT}.
    * @param nodeId This ID for this node.
    */
-  private void init(
-      AVLFile.Phase phase, ObjectPool objectPool,
-      AVLNode parentNode, int childIndex, long nodeId
-  ) {
-    assert this.objectPool == null;
+  private void init(AVLFile.Phase phase, AVLNode parentNode, int childIndex, long nodeId) {
 
     this.phase = phase;
     this.parentNode = parentNode;
     this.childIndex = childIndex;
     this.leftChildNode = null;
     this.rightChildNode = null;
-    this.objectPool = objectPool;
 
     //X    trace = new Throwable();
     refCount = 1;
@@ -1203,7 +1141,7 @@
     dirty = false;
 
     try {
-      block = phase.getAVLBlockFilePhase().readBlock(objectPool, nodeId);
+      block = phase.getAVLBlockFilePhase().readBlock(nodeId);
     } catch (IOException ex) {
       throw new Error("IOException", ex);
     }
@@ -1213,26 +1151,21 @@
    * Initialises a node on the given information.
    *
    * @param phase The phase that the node exists in.
-   * @param objectPool The pool that the node will return to.
    * @throws IOException If an I/O error occurs.
    */
-  private void init(
-      AVLFile.Phase phase, ObjectPool objectPool
-  ) throws IOException {
-    assert this.objectPool == null;
+  private void init(AVLFile.Phase phase) throws IOException {
 
     this.phase = phase;
     parentNode = null;
     childIndex = 0;
     this.leftChildNode = null;
     this.rightChildNode = null;
-    this.objectPool = objectPool;
 
     //X    trace = new Throwable();
     refCount = 1;
     writable = true;
     dirty = true;
-    block = phase.getAVLBlockFilePhase().allocateBlock(objectPool);
+    block = phase.getAVLBlockFilePhase().allocateBlock();
     block.putLong(IDX_LEFT, NULL_NODE);
     block.putLong(IDX_RIGHT, NULL_NODE);
     block.putByte(IDX_BALANCE_B, (byte) 0);

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/AbstractBlockFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/AbstractBlockFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/AbstractBlockFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -70,7 +70,7 @@
   private final static Logger logger = Logger.getLogger(AbstractBlockFile.class);
 
   /** All the open files accessed as block files. */
-  private static Set openFiles = new HashSet();
+  private static Set<File> openFiles = new HashSet<File>();
 
   /** Determine the byte order of this machine, and select an ordering to use. */
   static {

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/Block.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/Block.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/Block.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -65,12 +65,6 @@
   @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(Block.class);
 
-  /**
-   * The pool of currently unused blocks.  Blocks come from here where possible,
-   * and are returned here afterwards.
-   */
-  private ObjectPool objectPool;
-
   /** The file that this block is attached to. */
   private BlockFile blockFile;
 
@@ -80,6 +74,7 @@
   /** The ID of this block, unique within the file, and usually maps to a block position. */
   private long blockId;
 
+  // TODO: check if this is still needed
   /**
    * Indicates if this block owns the buffer inside it.  If the buffer
    * is owned then it must be freed (and written back to disk if it is
@@ -109,9 +104,8 @@
   private LongBuffer lb;
 
   /**
-   * Builds a block, providing the pool for the block to be returned to.
+   * Builds a block.
    *
-   * @param objectPool The pool that this block should be returned to.
    * @param blockFile The file that this data block is from.
    * @param blockSize The size of the data.
    * @param blockId The ID of the block in the file.
@@ -123,17 +117,16 @@
    * @param lb The 64 bit long offset of the data for this block, from the start of the buffer.
    */
   private Block(
-      ObjectPool objectPool, BlockFile blockFile, int blockSize,
+      BlockFile blockFile, int blockSize,
       long blockId, int byteOffset, ByteBuffer bb, ByteBuffer sbb,
       IntBuffer ib, LongBuffer lb
   ) {
-    init(objectPool, blockFile, blockSize, blockId, byteOffset, bb, sbb, ib, lb);
+    init(blockFile, blockSize, blockId, byteOffset, bb, sbb, ib, lb);
   }
 
   /**
-   * Factory method to produce a block, using an {@link ObjectPool} if possible.
+   * Factory method to produce a block.
    *
-   * @param objectPool The pool to get this block from, and to ultimately return the block to.
    * @param blockFile The file to get the data from.
    * @param blockSize The size of the data.
    * @param blockId The ID of the block in the file.
@@ -143,69 +136,40 @@
    *            which require a buffer of data.
    * @param ib The 32 bit integer offset of the data for this block, from the start of the buffer.
    * @param lb The 64 bit long offset of the data for this block, from the start of the buffer.
-   * @return A new block from the objectPool, or a new block which will be returned to the pool.
+   * @return A new block.
    */
   public static Block newInstance(
-      ObjectPool objectPool, BlockFile blockFile,
-      int blockSize, long blockId, int byteOffset, ByteBuffer bb,
+      BlockFile blockFile, int blockSize, long blockId, int byteOffset, ByteBuffer bb,
       ByteBuffer sbb, IntBuffer ib, LongBuffer lb
   ) {
-    Block block = (Block) objectPool.get(ObjectPool.TYPE_BLOCK);
-
-    if (block != null) {
-      block.init(
-          objectPool, blockFile, blockSize, blockId, byteOffset, bb,
-          sbb, ib, lb
-      );
-    } else {
-      block = new Block(
-          objectPool, blockFile, blockSize, blockId, byteOffset, bb,
-          sbb, ib, lb
-      );
-    }
-
-    return block;
+    return new Block(blockFile, blockSize, blockId, byteOffset, bb, sbb, ib, lb);
   }
 
   /**
    * Create a new block, not attached to any file.
    *
-   * @param objectPool The object pool to get the block from.
    * @param blockSize The size of the block to create.
    * @return A new block, with no file data.
    */
-  public static Block newInstance(ObjectPool objectPool, int blockSize) {
-    return newInstance(objectPool, null, blockSize, 0, ByteOrder.nativeOrder());
+  public static Block newInstance(int blockSize) {
+    return newInstance(null, blockSize, 0, ByteOrder.nativeOrder());
   }
 
   /**
-   * Factory method to create a new block, allocating a new data buffer.  Uses the objectPool
-   * if possible, or else creates a new block that will be returned to the object pool.
+   * Factory method to create a new block, allocating a new data buffer.
    *
-   * @param objectPool The pool of blocks to get the block from.
    * @param blockFile The file to get the block from.
    * @param blockSize The size of the data in the block.
    * @param blockId The ID of the block from the file.
    * @param byteOrder Represents little endian or big endian byte ordering.
-   * @return The block from the pool, or a new block which will be returned to the pool.
+   * @return A new block.
    */
-  public static Block newInstance(
-      ObjectPool objectPool, BlockFile blockFile,
-      int blockSize, long blockId, ByteOrder byteOrder
-  ) {
-    Block block = (Block) objectPool.get(ObjectPool.TYPE_S_BLOCK, blockSize);
-
-    if (block != null) {
-      block.init(objectPool, blockFile, blockId);
-    } else {
-      block = Block.newInstance(
-          objectPool, blockFile, blockSize, blockId, 0,
-          ByteBuffer.allocateDirect(blockSize).order(byteOrder), null, null,
-          null
-      );
-      block.ownsBuffer = true;
-    }
-
+  public static Block newInstance(BlockFile blockFile, int blockSize, long blockId, ByteOrder byteOrder) {
+    Block block = Block.newInstance(
+        blockFile, blockSize, blockId, 0,
+        ByteBuffer.allocateDirect(blockSize).order(byteOrder), null, null, null
+    );
+    block.ownsBuffer = true;
     return block;
   }
 
@@ -512,49 +476,9 @@
    */
   public void free() throws IOException {
     blockFile.freeBlock(blockId);
-    release();
   }
 
   /**
-   * Puts this buffer for this block back into the ObjectPool so it can be re-used in another Block.
-   */
-  public void release() {
-    if (blockFile != null) {
-      blockFile.releaseBlock(objectPool, this);
-      // blockFile should have been set to null in the call to releaseBlock()
-      // (which calls dispose()), but just to be sure we set it to null again.
-      blockFile = null;
-    } else {
-      dispose(objectPool);
-    }
-  }
-
-  /**
-   * Clears this Block, and puts the internal buffer back into the object pool for recycling.
-   * This block is invalid after calling this operation.
-   *
-   * @param objectPool The object pool to put the buffer back into.
-   */
-  public void dispose(ObjectPool objectPool) {
-    if (objectPool == null) {
-      throw new AssertionError();
-    }
-
-    this.objectPool = null;
-    blockFile = null;
-
-    if (ownsBuffer) {
-      objectPool.put(ObjectPool.TYPE_S_BLOCK, blockSize, this);
-    } else {
-      bb = null;
-      sbb = null;
-      ib = null;
-      lb = null;
-      objectPool.put(ObjectPool.TYPE_BLOCK, this);
-    }
-  }
-
-  /**
    * Determines if the contents of this block are equal to the specified block.
    *
    * @param o the block to compare to.
@@ -675,7 +599,6 @@
   /**
    * Initializes a block for use.
    *
-   * @param objectPool The pool that this block should be returned to.
    * @param blockFile The file that this data block is from.
    * @param blockSize The size of the data.
    * @param blockId The ID of the block in the file.
@@ -687,12 +610,10 @@
    * @param lb The 64 bit long offset of the data for this block, from the start of the buffer.
    */
   private void init(
-      ObjectPool objectPool, BlockFile blockFile, int blockSize,
+      BlockFile blockFile, int blockSize,
       long blockId, int byteOffset, ByteBuffer bb, ByteBuffer sbb,
       IntBuffer ib, LongBuffer lb
   ) {
-    assert this.objectPool == null;
-    this.objectPool = objectPool;
     this.blockFile = blockFile;
     this.blockSize = blockSize;
     init(blockId, byteOffset, bb, sbb, ib, lb);
@@ -702,20 +623,13 @@
    * Initializes a block for use, not setting up any of the data buffer, but still pointing to
    * the file for the block..
    *
-   * @param objectPool The pool that this block should be returned to.
    * @param blockFile The file that data block will come from.
    * @param blockId The ID of the block within the file.
    */
-  void init(ObjectPool objectPool, BlockFile blockFile, long blockId) {
-    assert this.objectPool == null;
+  void init(BlockFile blockFile, long blockId) {
     assert ownsBuffer;
-    this.objectPool = objectPool;
     this.blockFile = blockFile;
     this.blockId = blockId;
   }
 
-  //  protected void finalize() {
-  //    if (objectPool != null) logger.warn("Unpooled Block.");
-  //  }
-
 }

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
 
 // Third party packages
 import org.apache.log4j.Logger;
@@ -107,42 +105,24 @@
    * BlockFile implementation, changes to the ByteBuffer may take effect even if
    * {@link #writeBlock} is never called.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId The ID of the block that this buffer will be written to.
    * @return a ByteBuffer to be used for writing to the specified block.
    * @throws IOException if an I/O error occurs.
    */
-  public Block allocateBlock(ObjectPool objectPool,
-      long blockId) throws IOException;
+  public Block allocateBlock(long blockId) throws IOException;
 
   /**
-   * Frees a buffer that was allocated by calling either {@link #allocateBlock}
-   * or {@link #readBlock}. While calling this method is not strictly necessary,
-   * it may improve performance. The buffer should not be used after it has been
-   * freed.
-   *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
-   * @param block the buffer to be freed.
-   */
-  public void releaseBlock(ObjectPool objectPool, Block block);
-
-  /**
    * Allocates a ByteBuffer which is filled with the contents of the specified
    * block. If the buffer is modified then the method {@link #writeBlock} should
    * be called to write the buffer back to the file but, depending on the
    * BlockFile implementation, changes to the ByteBuffer may take effect even if
    * {@link #writeBlock} is never called.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId the block to read into the ByteBuffer.
    * @return The buffer that was read.
    * @throws IOException if an I/O error occurs.
    */
-  public Block readBlock(ObjectPool objectPool,
-      long blockId) throws IOException;
+  public Block readBlock(long blockId) throws IOException;
 
   /**
    * Writes a buffer that was allocated by calling either {@link #allocateBlock}

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFileTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFileTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/BlockFileTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -31,11 +31,7 @@
 import junit.framework.*;
 
 import java.io.*;
-import java.nio.*;
 
-// Java 2 standard packages
-import java.util.*;
-
 import org.apache.log4j.Logger;
 
 /**
@@ -88,6 +84,7 @@
   /**
    * Logger.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(BlockFileTest.class);
 
   /**
@@ -96,11 +93,6 @@
   protected BlockFile blockFile;
 
   /**
-   * Description of the Field
-   */
-  protected ObjectPool objectPool = null;
-
-  /**
    * Named constructor.
    *
    * @param name The name of the test.
@@ -131,12 +123,6 @@
 
       try {
 
-        if (objectPool != null) {
-
-          objectPool.release();
-          objectPool = null;
-        }
-
         blockFile.unmap();
 
         if (System.getProperty("os.name").startsWith("Win")) {
@@ -165,9 +151,8 @@
     blockFile.clear();
     blockFile.setNrBlocks(1);
 
-    Block blk = blockFile.allocateBlock(objectPool, 0);
+    Block blk = blockFile.allocateBlock(0);
     assertNotNull(blk);
-    blk.release();
   }
 
   /**
@@ -179,42 +164,34 @@
 
     blockFile.setNrBlocks(4);
 
-    Block blk = blockFile.allocateBlock(objectPool, 0);
+    Block blk = blockFile.allocateBlock(0);
     putString(blk, STR0);
     blk.write();
-    blk.release();
 
-    blk = blockFile.allocateBlock(objectPool, 3);
+    blk = blockFile.allocateBlock(3);
     putString(blk, STR3);
     blk.write();
-    blk.release();
 
-    blk = blockFile.allocateBlock(objectPool, 2);
+    blk = blockFile.allocateBlock(2);
     putString(blk, STR2);
     blk.write();
-    blk.release();
 
-    blk = blockFile.allocateBlock(objectPool, 1);
+    blk = blockFile.allocateBlock(1);
     putString(blk, STR1);
     blk.write();
-    blk.release();
 
     // Check what was written.
-    blk = blockFile.readBlock(objectPool, 2);
+    blk = blockFile.readBlock(2);
     assertEquals(STR2, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 0);
+    blk = blockFile.readBlock(0);
     assertEquals(STR0, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 1);
+    blk = blockFile.readBlock(1);
     assertEquals(STR1, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 3);
+    blk = blockFile.readBlock(3);
     assertEquals(STR3, getString(blk));
-    blk.release();
   }
 
   /**
@@ -226,21 +203,17 @@
 
     assertEquals(4, blockFile.getNrBlocks());
 
-    Block blk = blockFile.readBlock(objectPool, 2);
+    Block blk = blockFile.readBlock(2);
     assertEquals(STR2, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 0);
+    blk = blockFile.readBlock(0);
     assertEquals(STR0, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 1);
+    blk = blockFile.readBlock(1);
     assertEquals(STR1, getString(blk));
-    blk.release();
 
-    blk = blockFile.readBlock(objectPool, 3);
+    blk = blockFile.readBlock(3);
     assertEquals(STR3, getString(blk));
-    blk.release();
   }
 
   /**
@@ -255,30 +228,26 @@
     blockFile.setNrBlocks(nrBlocks);
 
     for (int i = 0; i < nrBlocks; ++i) {
-      Block blk = blockFile.allocateBlock(objectPool, i);
+      Block blk = blockFile.allocateBlock(i);
       blk.putInt(0, i + 5);
       blk.write();
-      blk.release();
     }
 
     for (int i = 0; i < nrBlocks; ++i) {
-      Block blk = blockFile.readBlock(objectPool, i);
+      Block blk = blockFile.readBlock(i);
       assertEquals(i + 5, blk.getInt(0));
-      blk.release();
     }
 
     for (int pass = 0; pass < 10; ++pass) {
       for (int i = 0; i < nrBlocks; ++i) {
-        Block blk = blockFile.readBlock(objectPool, i);
+        Block blk = blockFile.readBlock(i);
         blk.putInt(0, i ^ pass);
         blk.write();
-        blk.release();
       }
 
       for (int i = 0; i < nrBlocks; ++i) {
-        Block blk = blockFile.readBlock(objectPool, i);
+        Block blk = blockFile.readBlock(i);
         assertEquals(i ^ pass, blk.getInt(0));
-        blk.release();
       }
     }
 

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -31,8 +31,6 @@
 
 // Java 2 standard packages
 import java.lang.ref.*;
-import java.nio.*;
-import java.nio.channels.*;
 import java.util.*;
 
 // Third party packages
@@ -113,9 +111,6 @@
   /** A persistent map of items to their corresponding phases. */
   private IntFile itemToPhaseSeqMap;
 
-  /** The object pool to use when allocating blocks. */
-  private ObjectPool objectPool;
-
   /**
    * This is used to prevent items that are still in use from being returned by
    * {@link #allocate}. Items between firstHead and {@link Phase#head} are
@@ -170,7 +165,7 @@
   private Block tailBlock = null;
 
   /** The list of Phases from oldest to newest. */
-  private LinkedList phases = new LinkedList();
+  private LinkedList<Phase> phases = new LinkedList<Phase>();
 
   /** The newest (writing) phase. */
   private Phase currentPhase = null;
@@ -186,17 +181,11 @@
    * Constructs a FreeList which uses the specified file (if it exists) or
    * creates a new file (if it doesn't already exist).
    *
-   * @param objectPool the ObjectPool to use when allocating Blocks.
    * @param file the file.
    * @param ioType the IOType to use for the BlockFile.
    * @throws IOException if an I/O error occurs.
    */
-  private FreeList(
-      ObjectPool objectPool, File file, BlockFile.IOType ioType
-  ) throws IOException {
-    this.objectPool = objectPool;
-    objectPool.incRefCount();
-
+  private FreeList(File file, BlockFile.IOType ioType) throws IOException {
     this.file = file;
     blockFile = AbstractBlockFile.openBlockFile(file, BLOCK_SIZE_B, ioType);
     itemToPhaseSeqMap = IntFile.open(file + INTFILE_EXT);
@@ -207,31 +196,25 @@
    * Factory method for a FreeList instance which uses the specified file
    * (if it exists) or creates a new file (if it doesn't already exist).
    *
-   * @param objectPool the ObjectPool to use when allocating Blocks.
    * @param file the file.
    * @param ioType the IOType to use for the BlockFile.
    * @return The new FreeList instance.
    * @throws IOException if an I/O error occurs.
    */
-  public static FreeList openFreeList(
-      ObjectPool objectPool, File file, BlockFile.IOType ioType
-  ) throws IOException {
-    return new FreeList(objectPool, file, ioType);
+  public static FreeList openFreeList(File file, BlockFile.IOType ioType) throws IOException {
+    return new FreeList(file, ioType);
   }
 
   /**
    * Creates a FreeList instance which uses the specified file (if it exists) or
    * creates a new file (if it doesn't already exist).  Uses the default IO file type.
    *
-   * @param objectPool the ObjectPool to use when allocating Blocks.
    * @param file the file.
    * @return The new FreeList instance.
    * @throws IOException if an I/O error occurs.
    */
-  public static FreeList openFreeList(
-      ObjectPool objectPool, File file
-  ) throws IOException {
-    return openFreeList(objectPool, file, DEF_IO_TYPE);
+  public static FreeList openFreeList(File file) throws IOException {
+    return openFreeList(file, DEF_IO_TYPE);
   }
 
   /**
@@ -239,15 +222,12 @@
    * name (if the file exists) or creates a new file (if it doesn't already
    * exist).
    *
-   * @param objectPool the ObjectPool to use when allocating Blocks.
    * @param fileName the file name of the file.
    * @return The new FreeList instance.
    * @throws IOException if an I/O error occurs.
    */
-  public static FreeList openFreeList(
-      ObjectPool objectPool, String fileName
-  ) throws IOException {
-    return openFreeList(objectPool, new File(fileName));
+  public static FreeList openFreeList(String fileName) throws IOException {
+    return openFreeList(new File(fileName));
   }
 
   /**
@@ -362,16 +342,9 @@
   public synchronized void close() throws IOException {
     try {
       unmap();
-
-      if (objectPool != null) {
-        objectPool.release();
-        objectPool = null;
-      }
     } finally {
       try {
-        if (itemToPhaseSeqMap != null) {
-          itemToPhaseSeqMap.delete();
-        }
+        if (itemToPhaseSeqMap != null) itemToPhaseSeqMap.delete();
       } finally {
         itemToPhaseSeqMap = null;
         blockFile.close();
@@ -387,16 +360,9 @@
   public synchronized void delete() throws IOException {
     try {
       unmap();
-
-      if (objectPool != null) {
-        objectPool.release();
-        objectPool = null;
-      }
     } finally {
       try {
-        if (itemToPhaseSeqMap != null) {
-          itemToPhaseSeqMap.delete();
-        }
+        if (itemToPhaseSeqMap != null) itemToPhaseSeqMap.delete();
       } finally {
         itemToPhaseSeqMap = null;
         blockFile.delete();
@@ -427,19 +393,13 @@
   public synchronized void free(long item) throws IOException {
     removeClosedPhases();
 
-    if (currentPhase == null) {
-      throw new IllegalStateException("FreeList has no phases.");
-    }
+    if (currentPhase == null) throw new IllegalStateException("FreeList has no phases.");
 
     if ( (item < 0) || (item >= currentPhase.getNextItem())) {
-      throw new IllegalArgumentException(
-          "Trying to free item that was never allocated: " + item
-      );
+      throw new IllegalArgumentException("Trying to free item that was never allocated: " + item);
     }
 
-    if (DEBUG && !isValid(item)) {
-      throw new AssertionError("Attempt to free an invalid item: " + item);
-    }
+    if (DEBUG && !isValid(item)) throw new AssertionError("Attempt to free an invalid item: " + item);
 
     long head = currentPhase.getHead();
     readHeadBlock(getBlockId(head));
@@ -448,9 +408,7 @@
     headBlock.putLong(offset, item);
     headBlockDirty = true;
 
-    if (!isSharedItem(item)) {
-      reallocate = head;
-    }
+    if (!isSharedItem(item)) reallocate = head;
 
     if (getBlockOffset(head) == 0) {
       // Go to the next block.
@@ -477,29 +435,25 @@
         // to the new block.
         prevHeadBlock.putInt(IDX_NEXT, newHeadBlockId);
         prevHeadBlock.write();
-        prevHeadBlock.release();
 
         // Update the prev pointer of the next block to point back to the new
         // block.
         Block nextHeadBlock = findBlock(nextHeadBlockId);
 
         if (nextHeadBlock == null) {
-          nextHeadBlock = blockFile.readBlock(objectPool, nextHeadBlockId);
+          nextHeadBlock = blockFile.readBlock(nextHeadBlockId);
         }
 
         nextHeadBlock.putInt(IDX_PREV, newHeadBlockId);
         nextHeadBlock.write();
-        nextHeadBlock.release();
 
         nextHeadBlockId = newHeadBlockId;
       }
 
-      head = ( (long) nextHeadBlockId * BLOCK_SIZE) + HEADER_SIZE;
+      head = ((long)nextHeadBlockId * BLOCK_SIZE) + HEADER_SIZE;
     }
 
-    if (phases.size() == 1) {
-      firstHead = head;
-    }
+    if (phases.size() == 1) firstHead = head;
 
     currentPhase.setHead(head);
     currentPhase.decNrValidItems();
@@ -516,9 +470,7 @@
   public synchronized long allocate() throws IOException {
     removeClosedPhases();
 
-    if (currentPhase == null) {
-      throw new IllegalStateException("FreeList has no phases.");
-    }
+    if (currentPhase == null) throw new IllegalStateException("FreeList has no phases.");
 
     long item;
 
@@ -534,7 +486,7 @@
           readReallocateBlock(getBlockId(reallocate));
 
           int blockId = reallocateBlock.getInt(IDX_PREV);
-          reallocate = ( (blockId * BLOCK_SIZE) + BLOCK_SIZE) - 1;
+          reallocate = ((blockId * BLOCK_SIZE) + BLOCK_SIZE) - 1;
         } else {
           --reallocate;
         }
@@ -600,9 +552,7 @@
         tail = ( (long) blockId * BLOCK_SIZE) + HEADER_SIZE;
       }
 
-      if (phases.size() == 1) {
-        firstTail = tail;
-      }
+      if (phases.size() == 1) firstTail = tail;
 
       currentPhase.setTail(tail);
     }
@@ -626,13 +576,9 @@
   public synchronized boolean isValid(long item) {
     removeClosedPhases();
 
-    if (currentPhase == null) {
-      throw new IllegalStateException("FreeList has no phases.");
-    }
+    if (currentPhase == null) throw new IllegalStateException("FreeList has no phases.");
 
-    if ( (item < 0) || (item >= currentPhase.getNextItem())) {
-      return false;
-    }
+    if ( (item < 0) || (item >= currentPhase.getNextItem())) return false;
 
     long index = currentPhase.getTail();
     long head = currentPhase.getHead();
@@ -645,9 +591,7 @@
         long blockItem;
         blockItem = tailBlock.getLong(offset);
 
-        if (item == blockItem) {
-          return false;
-        }
+        if (item == blockItem) return false;
 
         if (getBlockOffset(index) == 0) {
           // Go to the next block.
@@ -670,7 +614,7 @@
    * @return the block ID.
    */
   private int getBlockId(long index) {
-    return (int) (index / BLOCK_SIZE);
+    return (int)(index / BLOCK_SIZE);
   }
 
   /**
@@ -681,7 +625,7 @@
    * @return the offset (in ints).
    */
   private int getBlockOffset(long index) {
-    return (int) (index % BLOCK_SIZE);
+    return (int)(index % BLOCK_SIZE);
   }
 
   /**
@@ -697,14 +641,11 @@
     int prevBlockId = -1;
 
     do {
-      Block block = blockFile.readBlock(objectPool, nextBlockId);
+      Block block = blockFile.readBlock(nextBlockId);
 
       if ( (prevBlockId >= 0) && (block.getInt(IDX_PREV) != prevBlockId)) {
         // Bad previous block pointer.  Fix it.
-        logger.warn(
-            "Free list back pointer does not agree with forward pointer." +
-            "  Fixed."
-        );
+        logger.warn("Free list back pointer does not agree with forward pointer.  Fixed.");
         block.putInt(IDX_PREV, prevBlockId);
         block.write();
       }
@@ -712,31 +653,22 @@
       prevBlockId = nextBlockId;
       nextBlockId = block.getInt(IDX_NEXT);
 
-      if (nextBlockId > maxBlockId) {
-        maxBlockId = nextBlockId;
-      }
+      if (nextBlockId > maxBlockId) maxBlockId = nextBlockId;
 
-      block.release();
     } while (nextBlockId != 0);
 
-    if (prevBlockId < 0) {
-      throw new AssertionError("prevBlockId is negative.");
-    }
+    if (prevBlockId < 0) throw new AssertionError("prevBlockId is negative.");
 
     // Check the previous block pointer in block 0.
-    Block block = blockFile.readBlock(objectPool, 0);
+    Block block = blockFile.readBlock(0);
 
     if (block.getInt(IDX_PREV) != prevBlockId) {
       // Bad previous block pointer.  Fix it.
-      logger.warn(
-          "Free list back pointer does not agree with forward pointer.  Fixed."
-      );
+      logger.warn("Free list back pointer does not agree with forward pointer.  Fixed.");
       block.putInt(IDX_PREV, prevBlockId);
       block.write();
     }
 
-    block.release();
-
     return maxBlockId;
   }
 
@@ -750,11 +682,11 @@
     // Caller must be synchronized.
     assert Thread.holdsLock(this);
 
-    Phase phase = (Phase) phases.getFirst();
+    Phase phase = phases.getFirst();
 
     while (!phase.isInUse() && (phases.size() > 1)) {
       phases.removeFirst();
-      phase = (Phase) phases.getFirst();
+      phase = phases.getFirst();
 
       firstHead = phase.getHead();
       firstTail = phase.getTail();
@@ -779,19 +711,13 @@
     if (headBlock != null) {
       if (blockId == (int) headBlock.getBlockId()) {
         headBlockDirty = false;
-
         return;
       }
-
       releaseHeadBlock();
     }
 
     headBlock = findBlock(blockId);
-
-    if (headBlock == null) {
-      headBlock = blockFile.allocateBlock(objectPool, blockId);
-    }
-
+    if (headBlock == null) headBlock = blockFile.allocateBlock(blockId);
     headBlockDirty = false;
   }
 
@@ -808,19 +734,12 @@
    */
   private void readHeadBlock(int blockId) throws IOException {
     if (headBlock != null) {
-      if (blockId == (int) headBlock.getBlockId()) {
-        return;
-      }
-
+      if (blockId == (int) headBlock.getBlockId()) return;
       releaseHeadBlock();
     }
 
     headBlock = findBlock(blockId);
-
-    if (headBlock == null) {
-      headBlock = blockFile.readBlock(objectPool, blockId);
-    }
-
+    if (headBlock == null) headBlock = blockFile.readBlock(blockId);
     headBlockDirty = false;
   }
 
@@ -847,11 +766,7 @@
    */
   private void releaseHeadBlock() throws IOException {
     if (headBlock != null) {
-      if (headBlockDirty) {
-        writeHeadBlock();
-      }
-
-      headBlock.release();
+      if (headBlockDirty) writeHeadBlock();
       headBlock = null;
     }
   }
@@ -866,19 +781,12 @@
    */
   private void readReallocateBlock(int blockId) throws IOException {
     if (reallocateBlock != null) {
-      if (blockId == (int) reallocateBlock.getBlockId()) {
-        return;
-      }
-
+      if (blockId == (int) reallocateBlock.getBlockId()) return;
       releaseReallocateBlock();
     }
 
     reallocateBlock = findBlock(blockId);
-
-    if (reallocateBlock == null) {
-      reallocateBlock = blockFile.readBlock(objectPool, blockId);
-    }
-
+    if (reallocateBlock == null) reallocateBlock = blockFile.readBlock(blockId);
     reallocateBlockDirty = false;
   }
 
@@ -890,7 +798,7 @@
    * @throws IOException if an I/O error occurs.
    */
   private void writeReallocateBlock() throws IOException {
-    if ( (reallocateBlock != null) && reallocateBlockDirty) {
+    if ((reallocateBlock != null) && reallocateBlockDirty) {
       reallocateBlock.write();
       reallocateBlockDirty = false;
     }
@@ -905,11 +813,7 @@
    */
   private void releaseReallocateBlock() throws IOException {
     if (reallocateBlock != null) {
-      if (reallocateBlockDirty) {
-        writeReallocateBlock();
-      }
-
-      reallocateBlock.release();
+      if (reallocateBlockDirty) writeReallocateBlock();
       reallocateBlock = null;
     }
   }
@@ -924,30 +828,19 @@
    */
   private void readTailBlock(int blockId) throws IOException {
     if (tailBlock != null) {
-      if (blockId == (int) tailBlock.getBlockId()) {
-        return;
-      }
-
+      if (blockId == (int) tailBlock.getBlockId()) return;
       releaseTailBlock();
     }
 
     tailBlock = findBlock(blockId);
-
-    if (tailBlock == null) {
-      tailBlock = blockFile.readBlock(objectPool, blockId);
-    }
+    if (tailBlock == null) tailBlock = blockFile.readBlock(blockId);
   }
 
   /**
-   * Releases the current tail buffer. After releasing, the tail buffer is made
-   * invalid.
-   *
+   * Releases the current tail buffer. After releasing, the tail buffer is made invalid.
    */
   private void releaseTailBlock() {
-    if (tailBlock != null) {
-      tailBlock.release();
-      tailBlock = null;
-    }
+    if (tailBlock != null) tailBlock = null;
   }
 
   /**
@@ -972,8 +865,7 @@
       return block;
     }
 
-    if ( (reallocateBlock != null) &&
-        ( (int) reallocateBlock.getBlockId() == blockId)) {
+    if ((reallocateBlock != null) && ((int)reallocateBlock.getBlockId() == blockId)) {
       writeReallocateBlock();
 
       Block block = reallocateBlock;
@@ -986,7 +878,6 @@
     if ( (tailBlock != null) && ( (int) tailBlock.getBlockId() == blockId)) {
       Block block = tailBlock;
       tailBlock = null;
-
       return block;
     }
 
@@ -1051,7 +942,7 @@
      * current token.  This is collectable by the GC and can be used to indicate
      * that the phase is no longer in use.
      */
-    private Reference tokenRef = null;
+    private Reference<Token> tokenRef = null;
 
 
     /** Holds a stack trace of construction so we can tell where problems occurred. */
@@ -1112,11 +1003,7 @@
         removeClosedPhases();
 
         int index = phases.indexOf(p);
-        if (index == -1) {
-          throw new IllegalStateException(
-              "Attempt to rollback to closed phase."
-          );
-        }
+        if (index == -1) throw new IllegalStateException("Attempt to rollback to closed phase.");
 
         while (phases.size() > (index + 1)) {
           Phase removedPhase = (Phase)phases.removeLast();
@@ -1241,7 +1128,7 @@
 
       if (token == null) {
         token = new Token();
-        tokenRef = new WeakReference(token);
+        tokenRef = new WeakReference<Token>(token);
       }
 
       ++refCount;
@@ -1334,7 +1221,7 @@
      * A new token is created if no token is available and the phase is in use.
      */
     private Token getToken() {
-      Token token = (tokenRef != null) ? (Token) tokenRef.get() : null;
+      Token token = (tokenRef != null) ? tokenRef.get() : null;
 
       if ( (token == null) && (refCount > 0)) {
         if (logger.isInfoEnabled()) {
@@ -1405,13 +1292,10 @@
     private synchronized boolean release() {
       assert getToken() != null:"released() when there is no valid token";
 
-      if (refCount == 0) {
-        throw new AssertionError("Attempt to release Phase with refCount == 0.");
-      }
+      if (refCount == 0) throw new AssertionError("Attempt to release Phase with refCount == 0.");
 
       if (--refCount == 0) {
         tokenRef = null;
-
         return true;
       }
 

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeListTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeListTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeListTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -28,9 +28,7 @@
 package org.mulgara.store.xa;
 
 // Java 2 standard packages
-import java.util.*;
 import java.io.*;
-import java.nio.*;
 
 // Third party packages
 import junit.framework.*;
@@ -66,13 +64,12 @@
   /**
    * Description of the Field
    */
-  static Block metaroot =
-      Block.newInstance(ObjectPool.newInstance(),
-      FreeList.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
+  static Block metaroot = Block.newInstance(FreeList.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
 
   /**
    * Logger.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(FreeListTest.class);
 
   /**
@@ -125,12 +122,9 @@
     try {
 
       File dir = TempDir.getTempDir();
-      freeList =
-          FreeList.openFreeList(ObjectPool.newInstance(),
-          new File(dir, "freelisttest"));
+      freeList = FreeList.openFreeList(new File(dir, "freelisttest"));
       exceptionOccurred = false;
-    }
-    finally {
+    } finally {
 
       if (exceptionOccurred) {
 
@@ -192,6 +186,7 @@
     assertEquals(3, freeList.allocate());
     assertEquals(5, freeList.getNextItem());
 
+    @SuppressWarnings("unused")
     FreeList.Phase.Token token0 = phase0.use();
     FreeList.Phase phase1 = freeList.new Phase();
 
@@ -208,7 +203,9 @@
     freeList.free(4);
 
     // free: | 2 4
+    @SuppressWarnings("unused")
     FreeList.Phase.Token token1 = phase1.use();
+    @SuppressWarnings("unused")
     FreeList.Phase phase2 = freeList.new Phase();
 
     phase1.writeToBlock(metaroot, 0);
@@ -250,6 +247,7 @@
     assertEquals(9, freeList.allocate());
     assertEquals(10, freeList.allocate());
 
+    @SuppressWarnings("unused")
     FreeList.Phase.Token token3 = phase3.use();
     FreeList.Phase phase4 = freeList.new Phase();
     assertEquals(11, freeList.allocate());
@@ -257,7 +255,9 @@
     token2.release();
     assertEquals(8, freeList.allocate());
 
+    @SuppressWarnings("unused")
     FreeList.Phase.Token token4 = phase4.use();
+    @SuppressWarnings("unused")
     FreeList.Phase phase5 = freeList.new Phase();
   }
 }

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -31,9 +31,6 @@
 import java.nio.*;
 import java.nio.channels.*;
 
-// Java 2 standard packages
-import java.util.*;
-
 // Third party packages
 import org.apache.log4j.Logger;
 
@@ -61,6 +58,7 @@
 public final class IOBlockFile extends AbstractBlockFile {
 
   /** Logger. */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(IOBlockFile.class);
 
   private static final int NOMINAL_ALLOCATION_SIZE = 1048576; // in bytes
@@ -131,46 +129,27 @@
    * contents of the ByteBuffer are undefined. The method {@link #writeBlock}
    * is called to write the buffer to the block.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId The ID of the block that this buffer will be written to.
    * @return a ByteBuffer to be used for writing to the specified block.
    */
-  public Block allocateBlock(ObjectPool objectPool, long blockId) {
+  public Block allocateBlock(long blockId) {
     assert(blockId >= 0) && (blockId < nrBlocks);
 
-    return Block.newInstance(objectPool, this, blockSize, blockId, byteOrder);
+    return Block.newInstance(this, blockSize, blockId, byteOrder);
   }
 
   /**
-   * Frees a buffer that was allocated by calling either {@link #allocateBlock}
-   * or {@link #readBlock}. While calling this method is not strictly
-   * necessary, it may improve performance. The buffer should not be used after
-   * it has been freed.
-   *
-   * @param objectPool The object pool to return the data buffer to.
-   * @param block the buffer to be freed.
-   */
-  public void releaseBlock(ObjectPool objectPool, Block block) {
-    block.dispose(objectPool);
-  }
-
-  /**
    * Allocates a ByteBuffer which is filled with the contents of the specified
    * block. If the buffer is modified then the method {@link #writeBlock}
    * should be called to write the buffer back to the file.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId the block to read into the ByteBuffer.
    * @return The allocated block, containing valid data from the file.
    * @throws IOException if an I/O error occurs.
    */
-  public Block readBlock(
-      ObjectPool objectPool, long blockId
-  ) throws IOException {
+  public Block readBlock(long blockId) throws IOException {
     // Create the buffer to read into.
-    Block block = allocateBlock(objectPool, blockId);
+    Block block = allocateBlock(blockId);
 
     ByteBuffer byteBuffer = block.getByteBuffer();
 

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFileTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFileTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/IOBlockFileTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.util.*;
 
 // Third party packages
 import junit.framework.*;
@@ -64,6 +62,7 @@
   /**
    * Logger.
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(IOBlockFileTest.class);
 
   private File file;
@@ -117,7 +116,6 @@
       File dir = TempDir.getTempDir();
       file = new File(dir, "iobftest");
       blockFile = new IOBlockFile(file, BLOCK_SIZE);
-      objectPool = ObjectPool.newInstance();
       exceptionOccurred = false;
     }
      finally {
@@ -140,11 +138,6 @@
 
     // Close the file.
     try {
-      if (objectPool != null) {
-        objectPool.release();
-        objectPool = null;
-      }
-
       blockFile.close();
     } finally {
       blockFile = null;

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
 
 // Third party packages
 import org.apache.log4j.Logger;
@@ -87,44 +85,34 @@
   /**
    * Constructs a ManagedBlockFile with the specified file.
    *
-   * @param objectPool an objectPool for this thread.
    * @param file the name of the BlockFile.
    * @param blockSize the block size in bytes.
    * @param ioType the type of I/O mechanism to use.
    * @throws IOException if an I/O error occurs.
    */
-  public ManagedBlockFile(
-      ObjectPool objectPool, File file, int blockSize,
-      BlockFile.IOType ioType
-  ) throws IOException {
+  public ManagedBlockFile(File file, int blockSize,BlockFile.IOType ioType) throws IOException {
     this.file = file;
     File freeListFile = new File(file + FREELIST_EXT);
 
     if (file.exists() != freeListFile.exists()) {
-      logger.error(
-          "ERROR: inconsistency between Block file and Free List file"
-      );
+      logger.error("ERROR: inconsistency between Block file and Free List file");
     }
 
     blockFile = AbstractBlockFile.openBlockFile(file, blockSize, ioType);
-    freeList = FreeList.openFreeList(objectPool, freeListFile);
+    freeList = FreeList.openFreeList(freeListFile);
     isOpen = true;
   }
 
   /**
    * Constructs a ManagedBlockFile with the specified file name.
    *
-   * @param objectPool an objectPool for this thread.
    * @param fileName the name of the BlockFile.
    * @param blockSize the block size in bytes.
    * @param ioType the type of I/O mechanism to use.
    * @throws IOException if an I/O error occurs.
    */
-  public ManagedBlockFile(
-      ObjectPool objectPool, String fileName,
-      int blockSize, BlockFile.IOType ioType
-  ) throws IOException {
-    this(objectPool, new File(fileName), blockSize, ioType);
+  public ManagedBlockFile(String fileName, int blockSize, BlockFile.IOType ioType) throws IOException {
+    this(new File(fileName), blockSize, ioType);
   }
 
   /**
@@ -371,46 +359,26 @@
      * depending on the BlockFile implementation, changes to the ByteBuffer may
      * take effect even if {@link #writeBlock} is never called.
      *
-     * @param objectPool the object pool to attempt to get objects from and
-     *      release objects to.
      * @param blockId The ID of the block that this buffer will be written to.
      * @return a ByteBuffer to be used for writing to the specified block.
      */
-    public Block allocateBlock(ObjectPool objectPool, long blockId) {
-      throw new UnsupportedOperationException(
-          "Cannot allocate a specific block of a ManagedBlockFile.");
+    public Block allocateBlock(long blockId) {
+      throw new UnsupportedOperationException("Cannot allocate a specific block of a ManagedBlockFile.");
     }
 
     /**
-     * Frees a buffer that was allocated by calling either {@link
-     * #allocateBlock} or {@link #readBlock}. While calling this method is not
-     * strictly necessary, it may improve performance. The buffer should not be
-     * used after it has been freed.
-     *
-     * @param objectPool the object pool to attempt to get objects from and
-     *      release objects to.
-     * @param block the buffer to be freed.
-     */
-    public void releaseBlock(ObjectPool objectPool, Block block) {
-      blockFile.releaseBlock(objectPool, block);
-    }
-
-    /**
      * Allocates a ByteBuffer which is filled with the contents of the
      * specified block. If the buffer is modified then the method {@link
      * #writeBlock} should be called to write the buffer back to the file but,
      * depending on the BlockFile implementation, changes to the ByteBuffer may
      * take effect even if {@link #writeBlock} is never called.
      *
-     * @param objectPool the object pool to attempt to get objects from and
-     *      release objects to.
      * @param blockId the block to read into the ByteBuffer.
      * @return The read block.
      * @throws IOException if an I/O error occurs.
      */
-    public Block readBlock(ObjectPool objectPool, long blockId)
-        throws IOException {
-      Block block = blockFile.readBlock(objectPool, blockId);
+    public Block readBlock(long blockId) throws IOException {
+      Block block = blockFile.readBlock(blockId);
       block.setBlockFile(this);
       return block;
     }
@@ -489,18 +457,16 @@
      * BlockFile implementation, changes to the ByteBuffer may take effect even if
      * {@link #writeBlock} is never called.
      *
-     * @param objectPool the object pool to attempt to get objects from and
-     *      release objects to.
      * @return a ByteBuffer to be used for writing to the specified block.
      * @throws IOException if an I/O error occurs.
      */
-    public Block allocateBlock(ObjectPool objectPool) throws IOException {
+    public Block allocateBlock() throws IOException {
       assert this == currentPhase;
 
       long blockId = freeList.allocate();
 
       blockFile.setNrBlocks(freeList.getNextItem());
-      Block block = blockFile.allocateBlock(objectPool, blockId);
+      Block block = blockFile.allocateBlock(blockId);
       block.setBlockFile(this);
       return block;
     }

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFileTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFileTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/ManagedBlockFileTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.nio.*;
-import java.util.*;
 
 // Third party packages
 import junit.framework.*;
@@ -107,14 +105,13 @@
    * Description of the Field
    *
    */
-  protected static Block metaroot =
-      Block.newInstance(ObjectPool.newInstance(),
-      ManagedBlockFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
+  protected static Block metaroot = Block.newInstance(ManagedBlockFile.Phase.RECORD_SIZE * Constants.SIZEOF_LONG);
 
   /**
    * Logger.
    *
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(ManagedBlockFileTest.class);
 
   /**
@@ -124,12 +121,6 @@
   protected ManagedBlockFile blockFile;
 
   /**
-   * Description of the Field
-   *
-   */
-  protected ObjectPool objectPool = null;
-
-  /**
    * Named constructor.
    *
    * @param name The name of the test.
@@ -156,11 +147,6 @@
   public void tearDown() throws IOException {
     if (blockFile != null) {
       try {
-        if (objectPool != null) {
-          objectPool.release();
-          objectPool = null;
-        }
-
         blockFile.close();
       } finally {
         blockFile = null;
@@ -177,9 +163,8 @@
     ManagedBlockFile.Phase phase0 = blockFile.new Phase();
     blockFile.clear();
 
-    Block blk = phase0.allocateBlock(objectPool);
+    Block blk = phase0.allocateBlock();
     assertNotNull(blk);
-    blk.release();
   }
 
   /**
@@ -191,49 +176,42 @@
     ManagedBlockFile.Phase phase0 = blockFile.new Phase();
     blockFile.clear();
 
+    @SuppressWarnings("unused")
     ManagedBlockFile.Phase.Token token0 = phase0.use();
     ManagedBlockFile.Phase phase1 = blockFile.new Phase();
 
-    Block blk = phase1.allocateBlock(objectPool);
+    Block blk = phase1.allocateBlock();
     assertEquals(0, blk.getBlockId());
     putString(blk, STR0);
     blk.write();
-    blk.release();
 
-    blk = phase1.allocateBlock(objectPool);
+    blk = phase1.allocateBlock();
     assertEquals(1, blk.getBlockId());
     putString(blk, STR1);
     blk.write();
-    blk.release();
 
-    blk = phase1.allocateBlock(objectPool);
+    blk = phase1.allocateBlock();
     assertEquals(2, blk.getBlockId());
     putString(blk, STR2);
     blk.write();
-    blk.release();
 
-    blk = phase1.allocateBlock(objectPool);
+    blk = phase1.allocateBlock();
     assertEquals(3, blk.getBlockId());
     putString(blk, STR3);
     blk.write();
-    blk.release();
 
     // Check what was written.
-    blk = phase1.readBlock(objectPool, 2);
+    blk = phase1.readBlock(2);
     assertEquals(STR2, getString(blk));
-    blk.release();
 
-    blk = phase1.readBlock(objectPool, 0);
+    blk = phase1.readBlock(0);
     assertEquals(STR0, getString(blk));
-    blk.release();
 
-    blk = phase1.readBlock(objectPool, 1);
+    blk = phase1.readBlock(1);
     assertEquals(STR1, getString(blk));
-    blk.release();
 
-    blk = phase1.readBlock(objectPool, 3);
+    blk = phase1.readBlock(3);
     assertEquals(STR3, getString(blk));
-    blk.release();
 
     phase1.writeToBlock(metaroot, 0);
   }
@@ -245,26 +223,23 @@
    */
   public void testPersist() throws IOException {
     ManagedBlockFile.Phase phase1 = blockFile.new Phase(metaroot, 0);
+    @SuppressWarnings("unused")
     ManagedBlockFile.Phase.Token token1 = phase1.use();
     ManagedBlockFile.Phase phase2 = blockFile.new Phase();
 
     assertEquals(4, phase2.getNrBlocks());
 
-    Block blk = phase2.readBlock(objectPool, 2);
+    Block blk = phase2.readBlock(2);
     assertEquals(STR2, getString(blk));
-    blk.release();
 
-    blk = phase2.readBlock(objectPool, 0);
+    blk = phase2.readBlock(0);
     assertEquals(STR0, getString(blk));
-    blk.release();
 
-    blk = phase2.readBlock(objectPool, 1);
+    blk = phase2.readBlock(1);
     assertEquals(STR1, getString(blk));
-    blk.release();
 
-    blk = phase2.readBlock(objectPool, 3);
+    blk = phase2.readBlock(3);
     assertEquals(STR3, getString(blk));
-    blk.release();
 
     phase2.writeToBlock(metaroot, 0);
   }
@@ -276,50 +251,46 @@
    */
   public void testDuplicate() throws IOException {
     ManagedBlockFile.Phase phase2 = blockFile.new Phase(metaroot, 0);
+    @SuppressWarnings("unused")
     ManagedBlockFile.Phase.Token token2 = phase2.use();
     ManagedBlockFile.Phase phase3 = blockFile.new Phase();
+    @SuppressWarnings("unused")
     ManagedBlockFile.Phase.Token token3 = phase3.use();
 
-    Block blk = phase3.readBlock(objectPool, 3);
+    Block blk = phase3.readBlock(3);
     assertEquals(STR3, getString(blk));
     blk.modify();
 
     long dup3Id = blk.getBlockId();
     assertEquals(4, dup3Id);
     blk.write();
-    blk.release();
 
-    blk = phase3.allocateBlock(objectPool);
+    blk = phase3.allocateBlock();
     assertEquals(5, blk.getBlockId());
     putString(blk, STR5);
     blk.write();
-    blk.release();
 
-    blk = phase3.readBlock(objectPool, 5);
+    blk = phase3.readBlock(5);
     assertEquals(STR5, getString(blk));
     blk.modify();
     assertEquals(5, blk.getBlockId());
     blk.write();
-    blk.release();
 
     // Check that the duplicate of block 3 has the same contents as block 3.
-    blk = phase3.readBlock(objectPool, dup3Id);
+    blk = phase3.readBlock(dup3Id);
     assertEquals(STR3, getString(blk));
-    blk.release();
 
     ManagedBlockFile.Phase phase4 = blockFile.new Phase();
 
-    blk = phase4.readBlock(objectPool, 5);
+    blk = phase4.readBlock(5);
     blk.modify();
     assertEquals(6, blk.getBlockId());
 
-    Block blk5 = phase4.readBlock(objectPool, 5);
+    Block blk5 = phase4.readBlock(5);
     assertEquals(
         blk5.getByteBuffer().position(0), blk.getByteBuffer().position(0)
     );
     blk.write();
-    blk.release();
-    blk5.release();
 
     phase4.writeToBlock(metaroot, 0);
   }

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFile.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFile.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFile.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -232,13 +232,11 @@
    * Allocates a ByteBuffer to be used for writing to the specified block. The
    * contents of the ByteBuffer are undefined.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId The ID of the block that this buffer will be written to.
    * @return a ByteBuffer to be used for writing to the specified block.
    */
-  public Block allocateBlock(ObjectPool objectPool, long blockId) {
-    return readBlock(objectPool, blockId);
+  public Block allocateBlock(long blockId) {
+    return readBlock(blockId);
   }
 
   /**
@@ -246,29 +244,21 @@
    * or {@link #readBlock}. The buffer should not be used after it has been
    * freed.
    *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param block the buffer to be freed.
    */
-  public void releaseBlock(ObjectPool objectPool, Block block) {
-    block.dispose(objectPool);
+  public void releaseBlock(Block block) {
   }
 
   /**
    * Allocates a ByteBuffer which is filled with the contents of the specified
    * block. If the buffer is modified then the method {@link #writeBlock}
    * should be called to write the buffer back to the file.
-   *
-   * @param objectPool the object pool to attempt to get objects from and
-   *      release objects to.
    * @param blockId the block to read into the ByteBuffer.
    * @return The block that was read.
    */
-  public Block readBlock(ObjectPool objectPool, long blockId) {
+  public Block readBlock(long blockId) {
     if ((blockId < 0) || (blockId >= nrBlocks)) {
-      throw new IllegalArgumentException(
-          "blockId: " + blockId + " of " + nrBlocks
-      );
+      throw new IllegalArgumentException("blockId: " + blockId + " of " + nrBlocks);
     }
 
     long fileOffset = blockId * blockSize;
@@ -280,7 +270,7 @@
     assert longBuffers != null;
 
     return Block.newInstance(
-        objectPool, this, blockSize, blockId, offset,
+        this, blockSize, blockId, offset,
         mappedByteBuffers[regionNr], srcByteBuffers[regionNr],
         intBuffers[regionNr], longBuffers[regionNr]
     );

Modified: trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFileTest.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFileTest.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/MappedBlockFileTest.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -28,9 +28,7 @@
 package org.mulgara.store.xa;
 
 // Java 2 standard packages
-import java.util.*;
 import java.io.*;
-import java.nio.*;
 
 // Third party packages
 import junit.framework.*;
@@ -65,6 +63,7 @@
    * Logger.
    *
    */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(MappedBlockFileTest.class);
 
   /**
@@ -114,7 +113,6 @@
 
       File dir = TempDir.getTempDir();
       blockFile = new MappedBlockFile(new File(dir, "mbftest"), BLOCK_SIZE);
-      objectPool = ObjectPool.newInstance();
       exceptionOccurred = false;
     }
     finally {

Deleted: trunk/src/jar/util-xa/java/org/mulgara/store/xa/ObjectPool.java
===================================================================
--- trunk/src/jar/util-xa/java/org/mulgara/store/xa/ObjectPool.java	2008-07-08 15:33:34 UTC (rev 1070)
+++ trunk/src/jar/util-xa/java/org/mulgara/store/xa/ObjectPool.java	2008-07-08 16:15:40 UTC (rev 1071)
@@ -1,641 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.store.xa;
-
-// Java 2 standard packages
-import java.util.*; // Third party packages
-
-// Third party packages
-import org.apache.log4j.Logger;
-
-/**
- * A pool of objects to avoid calling constructors unnecessarily.
- * Pools are linked to a root pool, which handles overflows for
- * local pools.
- *
- * @created 2002-09-09
- *
- * @author David Makepeace
- *
- * @version $Revision: 1.10 $
- *
- * @modified $Date: 2005/07/05 04:23:54 $
- *
- * @maintenanceAuthor $Author: pgearon $
- *
- * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
- *
- * @copyright &copy;2002 <a href="http://www.pisoftware.com/">Plugged In
- *      Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public final class ObjectPool {
-
-  /** A globally shared pool.  This is an instance of the current class. */
-  public final static ObjectPool SHARED_POOL = new ObjectPool(null);
-
-  /** Size of the object stack */
-  public final static int OBJECT_STACK_SIZE_LIMIT = 512;
-
-  /** Description of the Field */
-  public final static int TYPE_OBJECTPOOL = 0;
-
-  /** ID for keys in the pool */
-  public final static int TYPE_KEY = 1;
-
-  /** ID for object stack in the pool */
-  public final static int TYPE_OBJECTSTACK = 2;
-
-  /** ID of AVL Nodes in the pool */
-  public final static int TYPE_AVLNODE = 3;
-
-  /** ID of Array of AVLNode of length 1.  */
-  public final static int TYPE_AVLNODE_1 = 4;
-
-  /** ID of Array of AVLNode of length 2.  */
-  public final static int TYPE_AVLNODE_2 = 5;
-
-  /** ID of Block */
-  public final static int TYPE_BLOCK = 6;
-
-  /** ID of 8KB object */
-  public final static int TYPE_BLOCK_8192 = 7;
-
-  /** The number of different object types (all the TYPE_ fields) */
-  public final static int NR_OBJECT_TYPES = 8;
-
-  /** ID of a sized block */
-  public final static int TYPE_S_BLOCK = 0;
-
-  /** Logger */
-  private final static Logger logger = Logger.getLogger(ObjectPool.class);
-
-  /** The next cascaded object pool (the root pool) */
-  private ObjectPool nextPool;
-
-  /** An array of object arrays.  One array per type.  */
-  private Object[][] objectStacks =
-      new Object[NR_OBJECT_TYPES][OBJECT_STACK_SIZE_LIMIT];
-
-  /** The sizes of each object stack.  */
-  private int[] objectStackCounts = new int[NR_OBJECT_TYPES];
-
-  /** Mapping of sizes to object stacks containing that size */
-  private Map sizedObjectStacks = new HashMap();
-
-  /** Number of references to this pool by other pools (applies to the root pool). */
-  private int refCount;
-
-  /**
-   * Constructs an object pool.
-   *
-   * @param nextPool The next pool in the chain.  Normally the shared pool.
-   */
-  private ObjectPool(ObjectPool nextPool) {
-
-    init(nextPool);
-  }
-
-  /**
-   * Factory method to build a new root object pool.
-   *
-   * @return The new object pool.
-   */
-  public static ObjectPool newInstance() {
-
-    return newInstance(SHARED_POOL);
-  }
-
-  /**
-   * Factory method to build a new local object pool.
-   *
-   * @param nextPool The next pool in the chain.  Normally the shared pool
-   * @return The new object pool.
-   */
-  public static ObjectPool newInstance(ObjectPool nextPool) {
-
-    ObjectPool op;
-
-    if (nextPool != null) {
-
-      synchronized (nextPool) {
-
-        op = (ObjectPool) nextPool.get(TYPE_OBJECTPOOL);
-      }
-    }
-    else {
-
-      op = null;
-    }
-
-    if (op != null) {
-
-      op.init(nextPool);
-    }
-    else {
-
-      op = new ObjectPool(nextPool);
-    }
-
-    return op;
-  }
-
-  /**
-   * Gets a pooled object of a given type from this pool.
-   *
-   * @param type The ID of the type of object to find.
-   * @return A pooled object, or <code>null</code> if no objects are available.
-   */
-  public Object get(int type) {
-
-    assert refCount > 0;
-
-    int count = objectStackCounts[type];
-
-    if (count > 0) {
-
-      Object[] os = objectStacks[type];
-      Object o = os[--count];
-      os[count] = null;
-      objectStackCounts[type] = count;
-
-      return o;
-    }
-
-    if (nextPool != null) {
-
-      synchronized (nextPool) {
-
-        return nextPool.get(type);
-      }
-    }
-
-    return null;
-  }
-
-  /**
-   * Gets a pooled object of a given type and size from this pool.
-   *
-   * @param type The ID of the type of object to find.
-   * @param key The size of the object to find.
-   * @return A pooled object, or <code>null</code> if no objects are available.
-   */
-  public Object get(int type, int key) {
-
-    assert refCount > 0;
-
-    if ( (type == TYPE_S_BLOCK) && (key == 8192)) {
-
-      return get(TYPE_BLOCK_8192);
-    }
-
-    Key k = newKeyInstance(type, key);
-    ObjectStack os = (ObjectStack) sizedObjectStacks.get(k);
-    put(TYPE_KEY, k);
-
-    if ( (os != null) && !os.isEmpty()) {
-
-      return os.pop();
-    }
-
-    if (nextPool != null) {
-
-      synchronized (nextPool) {
-
-        return nextPool.get(type, key);
-      }
-    }
-
-    return null;
-  }
-
-  /**
-   * Increments the number of times this pool is referred to.
-   */
-  public void incRefCount() {
-
-    assert refCount > 0;
-
-    ++refCount;
-  }
-
-  /**
-   * Adds an object into the pool.
-   *
-   * @param type The type of object being added.
-   * @param o The object to add.
-   */
-  public void put(int type, Object o) {
-
-    assert refCount > 0;
-
-    int count = objectStackCounts[type];
-
-    if (count < OBJECT_STACK_SIZE_LIMIT) {
-
-      objectStacks[type][count++] = o;
-      objectStackCounts[type] = count;
-    }
-  }
-
-  /**
-   * METHOD TO DO
-   *
-   * @param type PARAMETER TO DO
-   * @param key PARAMETER TO DO
-   * @param o PARAMETER TO DO
-   */
-  public void put(int type, int key, Object o) {
-
-    assert refCount > 0;
-
-    if ( (type == TYPE_S_BLOCK) && (key == 8192)) {
-
-      put(TYPE_BLOCK_8192, o);
-
-      return;
-    }
-
-    Key k = newKeyInstance(type, key);
-    ObjectStack os = (ObjectStack) sizedObjectStacks.get(k);
-
-    if (os == null) {
-
-      os = newObjectStackInstance();
-      sizedObjectStacks.put(k, os);
-    }
-    else {
-
-      put(TYPE_KEY, k);
-    }
-
-    os.push(o);
-  }
-
-  /**
-   * Removes a reference to this object pool.
-   * Clears the pool if it is no longer in use.
-   */
-  public void release() {
-
-    assert refCount > 0;
-
-    if (--refCount == 0) {
-
-      flush(true);
-    }
-  }
-
-  /**
-   * Push all objects out of this pool and into the next (root) pool.
-   */
-  public void flush() {
-
-    flush(false);
-  }
-
-  /**
-   * Initialize the references for this pool.
-   *
-   * @param nextPool The next pool in the chain (either the root, or null).
-   */
-  private void init(ObjectPool nextPool) {
-
-    this.nextPool = nextPool;
-    refCount = 1;
-  }
-
-  /**
-   * Push all objects into the next pool, clearing this pool.
-   *
-   * @param dispose Get rid of this pool once it is flushed.
-   */
-  private void flush(boolean dispose) {
-
-    if (nextPool != null) {
-
-      synchronized (nextPool) {
-
-        if (!sizedObjectStacks.isEmpty()) {
-
-          if (nextPool.sizedObjectStacks.isEmpty()) {
-
-            // Swap the HashMaps.
-            Map tMap = nextPool.sizedObjectStacks;
-            nextPool.sizedObjectStacks = sizedObjectStacks;
-            sizedObjectStacks = tMap;
-          }
-          else {
-
-            for (Iterator it = sizedObjectStacks.entrySet().iterator();
-                it.hasNext(); ) {
-
-              Map.Entry entry = (Map.Entry) it.next();
-              Key k = (Key) entry.getKey();
-              ObjectStack os = (ObjectStack) entry.getValue();
-              ObjectStack npOS =
-                  (ObjectStack) nextPool.sizedObjectStacks.get(k);
-
-              if (npOS == null) {
-
-                nextPool.sizedObjectStacks.put(k, os);
-              }
-              else {
-
-                nextPool.put(TYPE_KEY, k);
-                npOS.copy(os);
-                nextPool.put(TYPE_OBJECTSTACK, os);
-              }
-            }
-
-            sizedObjectStacks.clear();
-          }
-        }
-
-        for (int i = 0; i < NR_OBJECT_TYPES; ++i) {
-
-          int count = objectStackCounts[i];
-
-          if (count > 0) {
-
-            Object[] os = objectStacks[i];
-            int npCount = nextPool.objectStackCounts[i];
-            Object[] npOS = nextPool.objectStacks[i];
-
-            if (npCount == 0) {
-
-              nextPool.objectStacks[i] = os;
-              nextPool.objectStackCounts[i] = count;
-              objectStacks[i] = npOS;
-              objectStackCounts[i] = 0;
-            }
-            else {
-
-              int len = OBJECT_STACK_SIZE_LIMIT - npCount;
-
-              if (len > count) {
-
-                len = count;
-              }
-
-              if (len > 0) {
-
-                System.arraycopy(os, count - len, npOS, npCount, len);
-                npCount += len;
-              }
-
-              while (count > 0) {
-
-                os[--count] = null;
-              }
-
-              nextPool.objectStackCounts[i] = npCount;
-              objectStackCounts[i] = 0;
-            }
-          }
-        }
-
-        if (dispose) {
-
-          nextPool.put(TYPE_OBJECTPOOL, this);
-          nextPool = null;
-        }
-      }
-    }
-    else if (dispose) {
-
-      sizedObjectStacks = null;
-      objectStacks = null;
-      objectStackCounts = null;
-    }
-  }
-
-  /**
-   * Create a new key, based on a given type and size.
-   *
-   * @param type The ID of the type of object to store.
-   * @param key The key for this object type.  This is the size of the data it holds.
-   * @return A new {@link Key} instance.
-   */
-  private Key newKeyInstance(int type, int key) {
-
-    Key k = (Key) get(TYPE_KEY);
-
-    if (k != null) {
-
-      k.init(type, key);
-    }
-    else {
-
-      k = new Key(type, key);
-    }
-
-    return k;
-  }
-
-  /**
-   * Creates a new ObjectStack.
-   *
-   * @return A fresh {@link ObjectStack}.
-   */
-  private ObjectStack newObjectStackInstance() {
-
-    ObjectStack os = (ObjectStack) get(TYPE_OBJECTSTACK);
-
-    if (os == null) {
-
-      os = new ObjectStack(OBJECT_STACK_SIZE_LIMIT);
-    }
-
-    return os;
-  }
-
-  //  protected void finalize() {
-  //    if (refCount > 0) logger.warn("Unpooled ObjectPool.");
-  //  }
-
-  /**
-   * This class is used as a key for object types, so that all objects
-   * of the same type can be found using the same key.
-   */
-  private final static class Key {
-
-    /** The ID of the object type */
-    int type;
-
-    /** The size of the data in the object */
-    int key;
-
-    /**
-     * Constructs a new object type Key.
-     *
-     * @param type The ID of the object type.
-     * @param key The key for the object type, from the size.
-     */
-    Key(int type, int key) {
-
-      init(type, key);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(Object o) {
-
-      Key k = (Key) o;
-
-      return (k.type == type) && (k.key == key);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int hashCode() {
-
-      return type + (key * 17);
-    }
-
-    /**
-     * Stores the parameters for this Key.
-     *
-     * @param type The ID of the object type.
-     * @param key The key for the object type, from the size.
-     */
-    void init(int type, int key) {
-
-      this.type = type;
-      this.key = key;
-    }
-  }
-
-  /**
-   * A stack of objects, all of the same type.
-   */
-  private final static class ObjectStack {
-
-    /** The stack containing the objects. */
-    private Object[] stack;
-
-    /** The number of objects in the stack. */
-    private int count = 0;
-
-    /**
-     * Constructor for the stack.
-     *
-     * @param maxSize The maximum number of objects in the stack.
-     */
-    ObjectStack(int maxSize) {
-
-      stack = new Object[maxSize];
-    }
-
-    /**
-     * Checks if the stack contains any objects.
-     *
-     * @return <code>true</code> when the stack is empty.
-     */
-    boolean isEmpty() {
-
-      return count == 0;
-    }
-
-    /**
-     * Removes every object from the stack.
-     */
-    void clear() {
-
-      while (count > 0) {
-
-        stack[--count] = null;
-      }
-    }
-
-    /**
-     * Moves the contents of another stack into this one,
-     * but only up to the limit of this stack.  If the source stack
-     * contains more objects than free positions in this stack, then objects
-     * will be lost.
-     *
-     * @param os The object stack to copy from.  This stack will be cleared.
-     */
-    void copy(ObjectStack os) {
-
-      int len = stack.length - count;
-
-      if (len > os.count) {
-
-        len = os.count;
-      }
-
-      if (len > 0) {
-
-        System.arraycopy(os.stack, os.count - len, stack, count, len);
-        count += len;
-      }
-
-      os.clear();
-    }
-
-    /**
-     * Adds a new object to the stack.
-     * Currently drops the object if the stack is full.
-     *
-     * @param o The object to add.
-     */
-    void push(Object o) {
-
-      if (count < stack.length) {
-
-        stack[count++] = o;
-      }
-
-      // TODO discard oldest entries when stack is full.
-    }
-
-    /**
-     * Removes the last object from the top of the stack and returns it.
-     *
-     * @return The top object from the stack, or <code>null</code> if the stack is empty.
-     */
-    Object pop() {
-
-      if (count > 0) {
-
-        Object o = stack[--count];
-        stack[count] = null;
-
-        return o;
-      }
-      else {
-
-        return null;
-      }
-    }
-  }
-}




More information about the Mulgara-svn mailing list