T
- The SPI typepublic class SPInterface<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?>[] |
paramClasses |
private java.lang.Object[] |
params |
private java.lang.String |
propertyName
The property name to be used for finding the name of
the SPI implementation class.
|
private java.lang.Class<T> |
spi
The service programming interface: intended to be
an interface or abstract class, but not limited
to those two.
|
Constructor and Description |
---|
SPInterface(java.lang.Class<T> provider)
Construct object representing Class
provider . |
SPInterface(java.lang.Class<T> provider,
java.lang.Class<?>[] constructorParamClasses,
java.lang.Object[] constructorParams)
Construct object representing Class
provider . |
SPInterface(java.lang.Class<T> spi,
java.lang.String propertyName)
Construct object representing Class
provider . |
SPInterface(java.lang.Class<T> spi,
java.lang.String propertyName,
java.lang.Class<?>[] constructorParamClasses,
java.lang.Object[] constructorParams)
Construct object representing Class
provider . |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getPropertyName()
Returns the property name to be used for finding
the name of the SPI implementation class.
|
java.lang.Class<T> |
getSPClass()
Returns the SPI class.
|
java.lang.String |
getSPName()
Returns the SPI class name.
|
<S extends T> |
newInstance(java.lang.Class<S> impl)
Creates a new instance of the given SPI class.
|
static <T> SPInterface<T> |
newSPInterface(java.lang.Class<T> provider)
Construct object representing Class
provider . |
static <T> SPInterface<T> |
newSPInterface(java.lang.Class<T> provider,
java.lang.Class<?>[] constructorParamClasses,
java.lang.Object[] constructorParams)
Construct object representing Class
provider . |
static <T> SPInterface<T> |
newSPInterface(java.lang.Class<T> provider,
java.lang.String propertyName)
Construct object representing Class
provider . |
static <T> SPInterface<T> |
newSPInterface(java.lang.Class<T> provider,
java.lang.String propertyName,
java.lang.Class<?>[] constructorParamClasses,
java.lang.Object[] constructorParams)
Construct object representing Class
provider . |
<S extends T> |
verifyAncestory(java.lang.Class<S> impl)
Verifies the given SPI implementation is a SPI specialization.
|
private final java.lang.Class<T> spi
private final java.lang.String propertyName
private final java.lang.Class<?>[] paramClasses
private final java.lang.Object[] params
public SPInterface(java.lang.Class<T> provider)
provider
.provider
- The SPI classpublic SPInterface(java.lang.Class<T> spi, java.lang.String propertyName)
provider
.spi
- The SPI classpropertyName
- when looking for the name of a class implementing
the provider class, a discovery strategy may involve looking for
(system or other) properties having either the name of the class
(provider) or the propertyName
.public SPInterface(java.lang.Class<T> provider, java.lang.Class<?>[] constructorParamClasses, java.lang.Object[] constructorParams)
provider
.provider
- The SPI classconstructorParamClasses
- classes representing the
constructor argument types.constructorParams
- objects representing the
constructor arguments.public SPInterface(java.lang.Class<T> spi, java.lang.String propertyName, java.lang.Class<?>[] constructorParamClasses, java.lang.Object[] constructorParams)
provider
.spi
- The SPI classpropertyName
- when looking for the name of a class implementing
the provider class, a discovery strategy may involve looking for
(system or other) properties having either the name of the class
(provider) or the propertyName
.constructorParamClasses
- classes representing the
constructor argument types.constructorParams
- objects representing the
constructor arguments.public static <T> SPInterface<T> newSPInterface(java.lang.Class<T> provider)
provider
.T
- The SPI typeprovider
- The SPI classprovider
public static <T> SPInterface<T> newSPInterface(java.lang.Class<T> provider, java.lang.String propertyName)
provider
.T
- The SPI typeprovider
- The SPI classpropertyName
- when looking for the name of a class implementing
the provider class, a discovery strategy may involve looking for
(system or other) properties having either the name of the class
(provider) or the propertyName
.provider
public static <T> SPInterface<T> newSPInterface(java.lang.Class<T> provider, java.lang.Class<?>[] constructorParamClasses, java.lang.Object[] constructorParams)
provider
.T
- The SPI typeprovider
- The SPI classconstructorParamClasses
- classes representing the
constructor argument typesconstructorParams
- objects representing the
constructor argumentsprovider
public static <T> SPInterface<T> newSPInterface(java.lang.Class<T> provider, java.lang.String propertyName, java.lang.Class<?>[] constructorParamClasses, java.lang.Object[] constructorParams)
provider
.T
- The SPI typeprovider
- The SPI classpropertyName
- when looking for the name of a class implementing
the provider class, a discovery strategy may involve looking for
(system or other) properties having either the name of the class
(provider) or the propertyName
.constructorParamClasses
- classes representing the
constructor argument typesconstructorParams
- objects representing the
constructor argumentsprovider
public java.lang.String getSPName()
public java.lang.Class<T> getSPClass()
public java.lang.String getPropertyName()
public <S extends T> S newInstance(java.lang.Class<S> impl) throws DiscoveryException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
S
- Any type extends Timpl
- The SPI class has to be instantiatedDiscoveryException
- if the class implementing
the SPI cannot be found, cannot be loaded and
instantiated, or if the resulting class does not implement
(or extend) the SPIjava.lang.InstantiationException
- see Class.newInstance()
java.lang.IllegalAccessException
- see Class.newInstance()
java.lang.NoSuchMethodException
- see Class.newInstance()
java.lang.reflect.InvocationTargetException
- see Class.newInstance()
public <S extends T> void verifyAncestory(java.lang.Class<S> impl)
S
- Any type extends Timpl
- The SPI instantance