33 |
|
|
34 |
protected Set indexTypes; |
protected Set indexTypes; |
35 |
|
|
|
/** |
|
|
* <code>null</code> until initializeIndices() has been called |
|
|
* for the first time. |
|
|
*/ |
|
36 |
protected Map indices = null; |
protected Map indices = null; |
37 |
|
|
38 |
/** Get a DB implementation associated with |
/** Get a DB implementation associated with |
46 |
|
|
47 |
public AbstractPool(Set indexTypes) throws IOException { |
public AbstractPool(Set indexTypes) throws IOException { |
48 |
this.indexTypes = indexTypes; |
this.indexTypes = indexTypes; |
49 |
|
initializeIndices(); |
50 |
} |
} |
51 |
|
|
52 |
protected final void initializeIndices() throws IOException { |
/** Initialize the <code>indices</code> map. |
53 |
|
* Conceptually, this is part of the constructor, |
54 |
|
* but it calls <code>getDB()</code>, which |
55 |
|
* may require subclasses to be fully initialized |
56 |
|
* before it is called. This <em>is</em> called in |
57 |
|
* this class's constructor, but a subclass may |
58 |
|
* provide an empty implementation and call |
59 |
|
* <code>super.initializeIndices()</code> |
60 |
|
* in its own constructor after it is fully initialized. |
61 |
|
* Rather roundabout, but more elegant than |
62 |
|
* hacking our way around the problem. |
63 |
|
*/ |
64 |
|
protected void initializeIndices() throws IOException { |
65 |
if(this.indices != null) return; |
if(this.indices != null) return; |
66 |
|
|
67 |
Map indices = new HashMap(); |
Map indices = new HashMap(); |
76 |
this.indices = Collections.unmodifiableMap(indices); |
this.indices = Collections.unmodifiableMap(indices); |
77 |
} |
} |
78 |
|
|
79 |
public Map getIndices() throws IOException { |
public Map getIndices() { return indices; } |
|
initializeIndices(); |
|
|
return indices; |
|
|
} |
|
80 |
|
|
81 |
public Object getIndex(String indexTypeURI) throws IOException { |
public Object getIndex(String indexTypeURI) { |
82 |
return getIndices().get(indexTypeURI); |
return getIndices().get(indexTypeURI); |
83 |
} |
} |
84 |
|
|