org.geotoolkit.coverage.processing
Class CachingCoverageProcessor

Object
  extended by Factory
      extended by AbstractCoverageProcessor
          extended by CachingCoverageProcessor
All Implemented Interfaces:
Localized, GridCoverageProcessor

@Buffered
@ThreadSafe
@Decorator(value=AbstractCoverageProcessor.class)
public class CachingCoverageProcessor
extends AbstractCoverageProcessor

A coverage processor that cache the result of operations. Given that grid coverages may be expensive to compute and consume a lot of memory, we can save a lot of resources by returning cached instances every time the same operation with the same parameters is applied on the same coverage. Coverages are cached using weak references.

Since:
2.2
Version:
3.00
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
coverage/geotk-coverage (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class Factory
Factory.Availability, Factory.Organizer
 
Field Summary
protected  AbstractCoverageProcessor processor
          The underlying processor.
 
Fields inherited from class AbstractCoverageProcessor
LOGGER, OPERATION
 
Fields inherited from class Factory
EMPTY_HINTS, hints
 
Constructor Summary
CachingCoverageProcessor()
          Creates a default caching processor.
CachingCoverageProcessor(AbstractCoverageProcessor processor)
          Creates a new buffered processor backed by the specified processor.
CachingCoverageProcessor(Hints userHints)
          Creates a caching processor using the specified hints.
 
Method Summary
 Coverage doOperation(ParameterValueGroup parameters)
          Applies an operation.
 Operation getOperation(String name)
          Returns the operation for the specified name.
 Collection<Operation> getOperations()
          Retrieves grid processing operations information.
 
Methods inherited from class AbstractCoverageProcessor
getInstance, getLocale, listOperations, printOperations
 
Methods inherited from class Factory
availability, dispose, equals, getImplementationHints, hasCompatibleHints, hashCode, setOrdering, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

processor

protected final AbstractCoverageProcessor processor
The underlying processor.

Constructor Detail

CachingCoverageProcessor

public CachingCoverageProcessor()
Creates a default caching processor.

This constructor should not be invoked directly - consider using CoverageFactoryFinder.getCoverageProcessor(Hints) instead.


CachingCoverageProcessor

public CachingCoverageProcessor(Hints userHints)
Creates a caching processor using the specified hints.

This constructor should not be invoked directly - consider using CoverageFactoryFinder.getCoverageProcessor(Hints) instead.

Parameters:
userHints - An optional set of hints, or null if none.

CachingCoverageProcessor

public CachingCoverageProcessor(AbstractCoverageProcessor processor)
Creates a new buffered processor backed by the specified processor.

Parameters:
processor - The coverage processor for which to cache the results.
Method Detail

getOperations

public Collection<Operation> getOperations()
Retrieves grid processing operations information. The default implementation forward the call directly to the underlying processor.

Specified by:
getOperations in interface GridCoverageProcessor
Specified by:
getOperations in class AbstractCoverageProcessor
Returns:
The available processing operations

getOperation

public Operation getOperation(String name)
                       throws OperationNotFoundException
Returns the operation for the specified name. The default implementation forward the call directly to the underlying processor.

Specified by:
getOperation in class AbstractCoverageProcessor
Parameters:
name - Name of the operation.
Returns:
The operation for the given name.
Throws:
OperationNotFoundException - if there is no operation for the specified name.

doOperation

public Coverage doOperation(ParameterValueGroup parameters)
                     throws OperationNotFoundException,
                            CoverageProcessingException
Applies an operation. The default implementation first checks if a coverage has already been created from the same parameters. If such a coverage is found, it is returned. Otherwise, this method forward the call to the underlying processor and caches the result.

Specified by:
doOperation in class AbstractCoverageProcessor
Parameters:
parameters - Parameters required for the operation.
Returns:
The result as a coverage.
Throws:
OperationNotFoundException - if there is no operation for the parameter group name.
CoverageProcessingException - if the operation can not be executed.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.