Class Engine
java.lang.Object
org.apache.harmony.security.fortress.Engine
public class Engine extends Object
This class implements common functionality for Provider supplied
classes. The usage pattern is to allocate static Engine instance
per service type and synchronize on that instance during calls to
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:
{@code
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);
}
...
}-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEngine.SpiAndProvider -
Field Summary
Fields Modifier and Type Field Description static SecurityAccessdoorAccess to package visible api in java.security -
Constructor Summary
-
Method Summary
Modifier and Type Method Description Engine.SpiAndProvidergetInstance(String algorithm, Object param)Finds the appropriate service implementation and returns anSpiAndProviderinstance containing a reference to SPI and itsProviderObjectgetInstance(String algorithm, Provider provider, Object param)Finds the appropriate service implementation and returns and instance of the class that implements corresponding Service Provider Interface.
-
Field Details
-
door
Access to package visible api in java.security
-
-
Constructor Details
-
Engine
Creates a Engine object- Parameters:
service-
-
-
Method Details
-
getInstance
public Engine.SpiAndProvider getInstance(String algorithm, Object param) throws NoSuchAlgorithmExceptionFinds the appropriate service implementation and returns anSpiAndProviderinstance containing a reference to SPI and itsProvider- Throws:
NoSuchAlgorithmException
-
getInstance
public Object getInstance(String algorithm, Provider provider, Object param) throws NoSuchAlgorithmExceptionFinds the appropriate service implementation and returns and instance of the class that implements corresponding Service Provider Interface.- Throws:
NoSuchAlgorithmException
-