public class Engine extends Object
getInstance
and retreival of the selected Provider
and Service Provider Interface (SPI) results. Retreiving 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 service)
Creates a Engine object
|
Modifier and Type | Method and Description |
---|---|
Engine.SpiAndProvider |
getInstance(String algorithm,
Object param)
Finds the appropriate service implementation and returns an
SpiAndProvider instance containing a reference to 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.
|
public static SecurityAccess door
public Engine(String service)
service
- public Engine.SpiAndProvider getInstance(String algorithm, Object param) throws NoSuchAlgorithmException
SpiAndProvider
instance containing a reference to SPI
and its Provider
NoSuchAlgorithmException
public Object getInstance(String algorithm, Provider provider, Object param) throws NoSuchAlgorithmException
NoSuchAlgorithmException