Interface Heap

All Known Implementing Classes:
EnvironmentHeap, HeapImpl

public interface Heap
Manages a collection of associated objects created and initialized by Heaplet 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

    Modifier and Type
    Method
    Description
    <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.
    Returns the name of this heap.
    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.
    The StartupMetrics associated with this heap.
  • Method Details

    • 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, or null 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.
    • 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, a 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);
           
       
      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 contains null, 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, a JsonValueException 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 contains null.
      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.
    • startupMetrics

      StartupMetrics startupMetrics()
      The StartupMetrics associated with this heap.
      Returns:
      the StartupMetrics associated with this heap.