Class OperatorSpi
- java.lang.Object
-
- org.esa.snap.core.gpf.OperatorSpi
-
- Direct Known Subclasses:
BandMathsOp.Spi
,GraphOp.Spi
,ImportVectorOp.Spi
,MergeOp.Spi
,MosaicOp.Spi
,PassThroughOp.Spi
,ProductSetReaderOp.Spi
,ReadOp.Spi
,ReprojectionOp.Spi
,ResamplingOp.Spi
,SubsetOp.Spi
,ToolAdapterOpSpi
,WriteOp.Spi
,WriteRGBOp.Spi
public abstract class OperatorSpi extends Object
The
OperatorSpi
class is the service provider interface (SPI) forOperator
s. Therefore this abstract class is intended to be derived by clients.The SPI is both a descriptor for the operator type and a factory for new
Operator
instances.An SPI is required for your operator if you want to make it accessible via an alias name in the various
GPF
.create
methods or within GPF Graph XML code.SPI are registered either pragmatically using the
OperatorSpiRegistry
or automatically via standard Java services lookup mechanism. For the services approach, place a fileMETA-INF/services/org.esa.snap.core.gpf.OperatorSpi
in the JAR file containing your operators and associated SPIs. For each SPI to be automatically registered, place a text line in the file containing the SPI's fully qualified class name.- Since:
- 4.1
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OperatorSpi(Class<? extends Operator> operatorClass)
Constructs an operator SPI for the given operator class.protected
OperatorSpi(Class<? extends Operator> operatorClass, String operatorAlias)
Deprecated.since BEAM 5, no replacement.protected
OperatorSpi(URL operatorDescriptorUrl)
Constructs an operator SPI for the given URL pointing to a valid operator descriptor XML document.protected
OperatorSpi(OperatorDescriptor operatorDescriptor)
Constructs an operator SPI for the given operator descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Operator
createOperator()
Creates an operator instance with no arguments.Operator
createOperator(Map<String,Object> parameters, Map<String,Product> sourceProducts)
Creates an operator instance for the given source products and processing parameters.Operator
createOperator(Map<String,Object> parameters, Map<String,Product> sourceProducts, RenderingHints renderingHints)
Creates an operator instance for the given source products and processing parameters.ModuleMetadata
getModuleMetadata()
The metadata information of the module which holds the operator provided by this SPI.String
getOperatorAlias()
The alias name under which the operator can be accessed.static String
getOperatorAlias(Class<? extends Operator> operatorClass)
Gets the alias name of the operator given by it's class.Class<? extends Operator>
getOperatorClass()
Gets the operator implementation class.OperatorDescriptor
getOperatorDescriptor()
-
-
-
Constructor Detail
-
OperatorSpi
protected OperatorSpi(OperatorDescriptor operatorDescriptor)
Constructs an operator SPI for the given operator descriptor.- Parameters:
operatorDescriptor
- The operator descriptor.- Since:
- BEAM 5
-
OperatorSpi
protected OperatorSpi(URL operatorDescriptorUrl)
Constructs an operator SPI for the given URL pointing to a valid operator descriptor XML document.- Parameters:
operatorDescriptorUrl
- The operator descriptor URL.- Since:
- BEAM 5
-
OperatorSpi
protected OperatorSpi(Class<? extends Operator> operatorClass)
Constructs an operator SPI for the given operator class. The alias name and other metadata will be taken from the operator annotationOperatorMetadata
. If no such exists, the alias name will be the operator's class name without the package path. All other metadata will be set to the empty string.- Parameters:
operatorClass
- The operator class.
-
OperatorSpi
@Deprecated protected OperatorSpi(Class<? extends Operator> operatorClass, String operatorAlias)
Deprecated.since BEAM 5, no replacement.Constructs an operator SPI for the given class name and alias name.- Parameters:
operatorClass
- The operator class.operatorAlias
- The alias name for the operator.
-
-
Method Detail
-
createOperator
public Operator createOperator() throws OperatorException
Creates an operator instance with no arguments. The default implementation calls the default constructor. If no such is defined in the operator, an exception is thrown.
This method may be overridden by clients in order to provide a no-argument instance of their operator. Implementors should call
operator.setSpi(this)
in order to set the operator's SPI.- Returns:
- the operator instance
- Throws:
OperatorException
- if the instance could not be created
-
createOperator
public Operator createOperator(Map<String,Object> parameters, Map<String,Product> sourceProducts) throws OperatorException
Creates an operator instance for the given source products and processing parameters.
This method may be overridden by clients in order to process the passed parameters and source products and optionally construct the operator in a specific way. Implementors should call
operator.setSpi(this)
in order to set the operator's SPI.- Parameters:
parameters
- the processing parameters.sourceProducts
- the source products.- Returns:
- the operator instance.
- Throws:
OperatorException
- if the operator could not be created.
-
createOperator
public Operator createOperator(Map<String,Object> parameters, Map<String,Product> sourceProducts, RenderingHints renderingHints) throws OperatorException
Creates an operator instance for the given source products and processing parameters.
This method may be overridden by clients in order to process the passed parameters and source products and optionally construct the operator in a specific way. Implementors should call
operator.setSpi(this)
in order to set the operator's SPI.- Parameters:
parameters
- the processing parameters.sourceProducts
- the source products.renderingHints
- the rendering hints, may benull
.- Returns:
- the operator instance.
- Throws:
OperatorException
- if the operator could not be created.
-
getOperatorClass
public final Class<? extends Operator> getOperatorClass()
Gets the operator implementation class. The operator class must be public and provide a public zero-argument constructor.Shorthand for
getOperatorDescriptor().getOperatorClass()
.- Returns:
- The operator implementation class.
-
getOperatorAlias
public final String getOperatorAlias()
The alias name under which the operator can be accessed.Shorthand for
getOperatorDescriptor().getAlias()
.- Returns:
- The alias name of the (@link Operator), or
null
if not declared.
-
getModuleMetadata
public ModuleMetadata getModuleMetadata()
The metadata information of the module which holds the operator provided by this SPI.- Returns:
- the module metadata
-
getOperatorDescriptor
public OperatorDescriptor getOperatorDescriptor()
- Returns:
- The operator descriptor.
- Since:
- BEAM 5
-
getOperatorAlias
public static String getOperatorAlias(Class<? extends Operator> operatorClass)
Gets the alias name of the operator given by it's class. The method returns the 'alias' element of the operator'sOperatorMetadata
, if any. Otherwise it returns the class' simple name (without package path).- Parameters:
operatorClass
- The operator class.- Returns:
- An operator alias name.
-
-