Package org.wildfly.security
Class OneTimeSecurityFactory<T>
- java.lang.Object
-
- org.wildfly.security.OneTimeSecurityFactory<T>
-
- All Implemented Interfaces:
SecurityFactory<T>
public final class OneTimeSecurityFactory<T> extends Object implements SecurityFactory<T>
ASecurityFactory
implementation which calls delegated factory at first and returns created object for any other create call. Thread safe.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description private SecurityFactory<T>
factory
private T
obj
-
Constructor Summary
Constructors Constructor Description OneTimeSecurityFactory(SecurityFactory<T> factory)
Creates a new factory instance.
-
-
-
Field Detail
-
factory
private volatile SecurityFactory<T> factory
-
obj
private volatile T obj
-
-
Constructor Detail
-
OneTimeSecurityFactory
public OneTimeSecurityFactory(SecurityFactory<T> factory)
Creates a new factory instance.- Parameters:
factory
- a security factory to use to obtain object which should be returned by this factory every time
-
-
Method Detail
-
create
public T create() throws GeneralSecurityException
Description copied from interface:SecurityFactory
Create an instance.- Specified by:
create
in interfaceSecurityFactory<T>
- Returns:
- the new instance
- Throws:
GeneralSecurityException
- if instantiation fails for some reason
-
-