gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/lava/gzz/storm IndexedPool.java impl/Abstra...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava/gzz/storm IndexedPool.java impl/Abstra...
Date: Mon, 13 Jan 2003 19:14:52 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/13 19:14:51

Modified files:
        lava/gzz/storm : IndexedPool.java 
        lava/gzz/storm/impl: AbstractPool.java DirPool.java 

Log message:
        Refactor more

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/IndexedPool.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/AbstractPool.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/storm/IndexedPool.java
diff -u gzz/lava/gzz/storm/IndexedPool.java:1.12 
gzz/lava/gzz/storm/IndexedPool.java:1.13
--- gzz/lava/gzz/storm/IndexedPool.java:1.12    Mon Jan 13 18:47:16 2003
+++ gzz/lava/gzz/storm/IndexedPool.java Mon Jan 13 19:14:51 2003
@@ -137,13 +137,13 @@
     /** Get the Index object for a given IndexType.
      *  Equivalent to <code>getIndices().get(type)</code>.
      */
-    Object getIndex(String typeURI) throws IOException;
+    Object getIndex(String typeURI);
 
     /** Return a mapping from index type URIs
      *  to <code>Index</code> objects. This map
      *  cannot be modified.
      */
-    Map getIndices() throws IOException;
+    Map getIndices();
 
     /** A convenience method to get a <code>Pointer</code> instance
      *  for this pool. This is defined always to return this:
Index: gzz/lava/gzz/storm/impl/AbstractPool.java
diff -u gzz/lava/gzz/storm/impl/AbstractPool.java:1.11 
gzz/lava/gzz/storm/impl/AbstractPool.java:1.12
--- gzz/lava/gzz/storm/impl/AbstractPool.java:1.11      Mon Jan 13 18:47:17 2003
+++ gzz/lava/gzz/storm/impl/AbstractPool.java   Mon Jan 13 19:14:51 2003
@@ -33,10 +33,6 @@
 
     protected Set indexTypes;
 
-    /**
-     *  <code>null</code> until initializeIndices() has been called
-     *  for the first time.
-     */
     protected Map indices = null;
 
     /** Get a DB implementation associated with
@@ -50,9 +46,22 @@
 
     public AbstractPool(Set indexTypes) throws IOException {
        this.indexTypes = indexTypes;
+       initializeIndices();
     }
 
-    protected final void initializeIndices() throws IOException {
+    /** Initialize the <code>indices</code> map.
+     *  Conceptually, this is part of the constructor,
+     *  but it calls <code>getDB()</code>, which
+     *  may require subclasses to be fully initialized
+     *  before it is called. This <em>is</em> called in
+     *  this class's constructor, but a subclass may
+     *  provide an empty implementation and call
+     *  <code>super.initializeIndices()</code>
+     *  in its own constructor after it is fully initialized.
+     *  Rather roundabout, but more elegant than
+     *  hacking our way around the problem.
+     */
+    protected void initializeIndices() throws IOException {
        if(this.indices != null) return;
 
        Map indices = new HashMap();
@@ -67,12 +76,9 @@
        this.indices = Collections.unmodifiableMap(indices);
     }
 
-    public Map getIndices() throws IOException {
-       initializeIndices(); 
-       return indices; 
-    }
+    public Map getIndices() { return indices; }
 
-    public Object getIndex(String indexTypeURI) throws IOException {
+    public Object getIndex(String indexTypeURI) {
        return getIndices().get(indexTypeURI);
     }
 
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.19 
gzz/lava/gzz/storm/impl/DirPool.java:1.20
--- gzz/lava/gzz/storm/impl/DirPool.java:1.19   Mon Jan 13 19:02:26 2003
+++ gzz/lava/gzz/storm/impl/DirPool.java        Mon Jan 13 19:14:51 2003
@@ -37,7 +37,7 @@
 
     /** The DB objects by index type URI.
      */
-    protected Map dbs;
+    protected Map dbs = new HashMap();
 
     /** Get the File object for the block
      *  corresponding to a given id.
@@ -112,6 +112,10 @@
     public DirPool(File dir, Set indexTypes) throws IOException {
        super(indexTypes);
        this.dir = dir;
+       super.initializeIndices();
+    }
+
+    protected void initializeIndices() throws IOException {
     }
 
     public Block get(BlockId id) throws IOException { 
@@ -159,7 +163,9 @@
     }
 
     protected DB getDB(String typeURI) throws IOException {
-       if(dbs == null) dbs = new HashMap();
+       if(dir == null || dbs == null)
+           throw new IllegalStateException("Not initialized yet");
+
        DB db = (DB)dbs.get(typeURI);
        if(db == null) {
            db = new DirDB(dir, typeURI);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]