Package org.forgerock.openig.heap
Interface Heap
-
- All Known Implementing Classes:
EnvironmentHeap
,HeapImpl
public interface Heap
Manages a collection of associated objects created and initialized byHeaplet
objects. A heap object may be lazily initialized, meaning that it or its dependencies may not be created until first requested from the heap.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description <T> T
get(String name, Class<T> type)
Returns an object from the heap with a specified name, ornull
if no such object exists.<T> List<T>
getAll(Class<T> type)
Deprecated.marked in 6.5 with no functional equivalentName
getName()
Returns the name of this heap.Bindings
getProperties()
Returns the properties from this heap and its parents if any.<T> T
resolve(JsonValue reference, Class<T> type)
Resolves a mandatory object with the specified reference.<T> T
resolve(JsonValue reference, Class<T> type, boolean optional)
Resolves an object with the specified reference, optionally or not.
-
-
-
Method Detail
-
getName
Name getName()
Returns the name of this heap.- Returns:
- the name of this heap.
-
get
<T> T get(String name, Class<T> type) throws HeapException
Returns an object from the heap with a specified name, ornull
if no such object exists.- Type Parameters:
T
- expected type of the heap object- Parameters:
name
- the name of the object in the heap to be retrieved.type
- expected type of the heap object- Returns:
- the requested object from the heap, or
null
if no such object exists. - Throws:
HeapException
- if an exception occurred during creation of the heap object or any of its dependencies.JsonValueException
- if a heaplet (or one of its dependencies) has a malformed configuration object.
-
getAll
@Deprecated <T> List<T> getAll(Class<T> type) throws HeapException
Deprecated.marked in 6.5 with no functional equivalentReturns all objects from the heap or its parent (if any), with the specified type or an empty list if no such object exists. Existing objects in the heap are not overridden by its parents if such exist.- Type Parameters:
T
- expected type of the heap object- Parameters:
type
- expected type to search for in the heap or its parent (if any).- Returns:
- the requested object from the heap, or from its parent (if any), or an empty list if no such object exists.
- Throws:
HeapException
- if an exception occurred during the creation of a heap object or any of its dependencies.JsonValueException
- if a heaplet (or one of its dependencies) has a malformed configuration object.
-
resolve
<T> T resolve(JsonValue reference, Class<T> type) throws HeapException
Resolves a mandatory object with the specified reference. If the object does not exist or the inline declaration cannot be build, aJsonValueException
is thrown. If the reference is an inline object declaration, an anonymous object is added to the heap and returned.Equivalent to:
heap.resolve(reference, type, false);
- Type Parameters:
T
- expected instance type- Parameters:
reference
- a JSON value containing the name of the heap object to retrieve.type
- the expected type of the heap object.- Returns:
- the specified heap object.
- Throws:
HeapException
- if there was an exception creating the heap object or any of its dependencies.JsonValueException
- if the name containsnull
, is not a string, or the specified heap object could not be retrieved or has the wrong type or the reference is not a valid inline declaration.
-
resolve
<T> T resolve(JsonValue reference, Class<T> type, boolean optional) throws HeapException
Resolves an object with the specified reference, optionally or not. If the reference is an inline object declaration, an anonymous object is added to the heap and returned. If the inline declaration cannot be build, aJsonValueException
is thrown.- Type Parameters:
T
- expected instance type- Parameters:
reference
- a JSON value containing either the name of the heap object to retrieve or an inline declaration.type
- the expected type of the heap object.optional
- Accept or not a JsonValue that contains null.- Returns:
- the referenced heap object or
null
if name containsnull
. - Throws:
HeapException
- if there was an exception creating the heap object or any of its dependencies.JsonValueException
- if the reference is not a string, or the specified heap object has the wrong type or the reference is not a valid inline declaration.
-
getProperties
Bindings getProperties()
Returns the properties from this heap and its parents if any.- Returns:
- the properties from this heap and its parents if any.
-
-