public final class Engine extends Object
getInstance and retrieval of the selected Provider
and Service Provider Interface (SPI) results. Retrieving the
results with getProvider and getSpi sets the
internal Engine values to null to prevent memory leaks.
For example:
public class Foo {
private static final Engine ENGINE = new Engine("Foo");
private final FooSpi spi;
private final Provider provider;
private final String algorithm;
protected Foo(FooSpi spi,
Provider provider,
String algorithm) {
this.spi = spi;
this.provider = provider;
this.algorithm = algorithm;
}
public static Foo getInstance(String algorithm) {
Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null);
return new Foo((FooSpi) sap.spi, sap.provider, algorithm);
}
public static Foo getInstance(String algorithm, Provider provider) {
Object spi = ENGINE.getInstance(algorithm, provider, null);
return new Foo((FooSpi) spi, provider, algorithm);
}
...
}| Modifier and Type | Class and Description |
|---|---|
static class |
Engine.SpiAndProvider |
| Modifier and Type | Field and Description |
|---|---|
static SecurityAccess |
door
Access to package visible api in java.security
|
| Constructor and Description |
|---|
Engine(String serviceName)
Creates a Engine object
|
| Modifier and Type | Method and Description |
|---|---|
Engine.SpiAndProvider |
getInstance(Provider.Service service,
String param)
Finds the appropriate service implementation and returns an
SpiAndProvider instance containing a reference to SPI
and its Provider |
Engine.SpiAndProvider |
getInstance(String algorithm,
Object param)
Finds the appropriate service implementation and returns an
SpiAndProvider instance containing a reference to the first
matching SPI and its Provider |
Object |
getInstance(String algorithm,
Provider provider,
Object param)
Finds the appropriate service implementation and returns and instance of
the class that implements corresponding Service Provider Interface.
|
ArrayList<Provider.Service> |
getServices()
Returns a list of all providers for this type of service or
null
if no matches were found. |
ArrayList<Provider.Service> |
getServices(String algorithm)
Returns a list of all possible matches for a given algorithm.
|
public static SecurityAccess door
public Engine(String serviceName)
serviceName - public Engine.SpiAndProvider getInstance(String algorithm, Object param) throws NoSuchAlgorithmException
SpiAndProvider instance containing a reference to the first
matching SPI and its ProviderNoSuchAlgorithmExceptionpublic Engine.SpiAndProvider getInstance(Provider.Service service, String param) throws NoSuchAlgorithmException
SpiAndProvider instance containing a reference to SPI
and its ProviderNoSuchAlgorithmExceptionpublic ArrayList<Provider.Service> getServices()
null
if no matches were found.public ArrayList<Provider.Service> getServices(String algorithm)
null if no matches were found.public Object getInstance(String algorithm, Provider provider, Object param) throws NoSuchAlgorithmException
NoSuchAlgorithmException