|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectGridCoverageStorePool
@ThreadSafe public class GridCoverageStorePool
A pool of GridCoverageReader and GridCoverageWriter instances.
This pool can be useful if many grid coverages are likely to be read or written,
and the readers or writers are costly to create.
Note: In Geotk implementation,This class is typically used as below. Note that it is not strictly necessary to invoke theGridCoverageReaderandGridCoverageWriterare not directly costly to create. However they may hold references toImageReaderorImageWriterinstances, and some kind of those Java I/O objects are costly to create.
release(GridCoverageReader) method in a finally block.
class MyClass {
private final GridCoverageStorePool pool = new GridCoverageStorePool(4);
GridCoverage2D getCoverage() throws CoverageStoreException {
GridCoverageReader reader = pool.acquireReader();
GridCoverage2D coverage = reader.read(...);
pool.release(reader);
return coverage;
}
}
The default pool implementation creates instances of ImageCoverageReader. Subclasses
can create other kind of implementations by overriding the createReader() method.
| coverage/geotk-coverageio (download) | View source code for this class |
| Constructor Summary | |
|---|---|
GridCoverageStorePool(int max)
Creates a new pool which will accept the given maximal amount of readers and writers. |
|
| Method Summary | |
|---|---|
GridCoverageReader |
acquireReader()
Returns a reader from the pool, or creates a new one if the pool is empty. |
protected GridCoverageReader |
createReader()
Invoked when a new image reader needs to be created. |
void |
release(GridCoverageReader reader)
Returns the given reader to the pool. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GridCoverageStorePool(int max)
max - The maximal amount of readers and writers to keep in the pool.| Method Detail |
|---|
protected GridCoverageReader createReader()
throws CoverageStoreException
ImageCoverageReader. Subclasses can override
this method if they want to supply an other kind of reader.
acquireReader().
CoverageStoreException - If the reader can not be created.
public GridCoverageReader acquireReader()
throws CoverageStoreException
release(GridCoverageReader) when they finished
using the reader, in order to return it to the pool. However it is not necessary to perform
the release in a finally block: if the reader is never returned to the pool, it will
be garbage-collected.
CoverageStoreException - If the reader can not be created.
public void release(GridCoverageReader reader)
throws CoverageStoreException
reader - The reader to return to the pool.
CoverageStoreException - If an error occurred while reseting or disposing the reader.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||