public class HeapImpl extends Object implements Heap
Constructor and Description |
---|
HeapImpl(HeapImpl parent,
Name name)
Builds a new heap that is a child of the given heap.
|
HeapImpl(Name name)
Builds a root heap (will be referenced by children but has no parent itself).
|
Modifier and Type | Method and Description |
---|---|
void |
addDefaultDeclaration(org.forgerock.json.JsonValue object)
Add a default JsonValue object declaration in this heap.
|
void |
destroy()
Destroys the objects on the heap and dereferences all associated objects.
|
<T> T |
get(String name,
Class<T> type)
Returns an object from the heap with a specified name, or
null if no such object exists. |
<T> List<T> |
getAll(Class<T> type)
Returns all objects from the heap or its parent (if any), with the
specified type or an empty list if no such object exists.
|
org.forgerock.http.Handler |
getHandler()
Returns the
Handler object referenced by the handler top-level attribute. |
Bindings |
getProperties()
Returns the properties from this heap and its parents if any.
|
void |
init(org.forgerock.json.JsonValue config,
String... reservedFieldNames)
Initializes the heap using the given configuration.
|
void |
put(String name,
Object object)
Puts an object into the heap.
|
<T> T |
resolve(org.forgerock.json.JsonValue reference,
Class<T> type)
Resolves a mandatory object with the specified reference.
|
<T> T |
resolve(org.forgerock.json.JsonValue reference,
Class<T> type,
boolean optional)
Resolves an object with the specified reference, optionally or not.
|
public HeapImpl(Name name)
name
- local name of this heappublic void init(org.forgerock.json.JsonValue config, String... reservedFieldNames) throws HeapException
config
- the configuration root.reservedFieldNames
- the names of reserved top level fields in the config which
should not be parsed as global decorators.HeapException
- if an exception occurs allocating heaplets.org.forgerock.json.JsonValueException
- if the configuration object is malformed.public void addDefaultDeclaration(org.forgerock.json.JsonValue object)
init(JsonValue, String...)
: values provided after init() has
been called will be ignored.
Notice that if the caller add 2 declarations with the same name, that will ends up with an exception thrown
when heap will be initialized.object
- Object declaration (has to contains a name attribute)public <T> List<T> getAll(Class<T> type) throws HeapException
Heap
getAll
in interface Heap
T
- expected type of the heap objecttype
- expected type to search for in the heap or its parent (if
any).HeapException
- if an exception occurred during the creation of a heap object
or any of its dependencies.public <T> T get(String name, Class<T> type) throws HeapException
Heap
null
if no such object exists.get
in interface Heap
T
- expected type of the heap objectname
- the name of the object in the heap to be retrieved.type
- expected type of the heap objectnull
if no such object exists.HeapException
- if an exception occurred during creation of the heap object or any of its dependencies.public <T> T resolve(org.forgerock.json.JsonValue reference, Class<T> type) throws HeapException
Heap
JsonValueException
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);
resolve
in interface Heap
T
- expected instance typereference
- a JSON value containing the name of the heap object to retrieve.type
- the expected type of the heap object.HeapException
- if there was an exception creating the heap object or any of its dependencies.public <T> T resolve(org.forgerock.json.JsonValue reference, Class<T> type, boolean optional) throws HeapException
Heap
JsonValueException
is thrown.resolve
in interface Heap
T
- expected instance typereference
- 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.null
if name contains null
.HeapException
- if there was an exception creating the heap object or any of its dependencies.public void put(String name, Object object)
name
- name of the object to be put into the heap.object
- the object to be put into the heap.public void destroy()
destroy
method for each object in the heap to provide a
chance for system resources to be freed.public org.forgerock.http.Handler getHandler() throws HeapException
Handler
object referenced by the handler top-level attribute.
The returned object is fully decorated (including top-level reference decorations).Handler
object referenced by the handler top-level attributeHeapException
- if object resolution failedpublic Bindings getProperties()
Heap
getProperties
in interface Heap
Copyright © 2025 Open Identity Platform Community. All rights reserved.