org.qi4j.bootstrap.builder

## Class ApplicationBuilder

- java.lang.Object
- - org.qi4j.bootstrap.builder.ApplicationBuilder

- All Implemented Interfaces:
    ActivationEventListenerRegistration

      public class ApplicationBuilder
      extends Object
      implements ActivationEventListenerRegistration

  Application Builder.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApplicationBuilder(String applicationName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `afterActivation()` Called after application activation.
    `protected void` | `beforeActivation()` Called before application activation.
    `protected void` | `configureWithJson(JSONObject root)` Configures the application struucture from a JSON document.
    `void` | `deregisterActivationEventListener(ActivationEventListener listener)`
    `static ApplicationBuilder` | `fromJson(InputStream json)` Load an ApplicationBuilder from a JSON InputStream.
    `static ApplicationBuilder` | `fromJson(JSONObject root)` Load an ApplicationBuilder from a JSONObject.
    `static ApplicationBuilder` | `fromJson(String json)` Load an ApplicationBuilder from a JSON String.
    `static void` | `main(String[] args)` main method that read JSON from STDIN.
    `Application` | `newApplication()` Create and activate a new Application.
    `void` | `registerActivationEventListener(ActivationEventListener listener)`
    `LayerDeclaration` | `withLayer(String layerName)` Declare Layer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ApplicationBuilder

          public ApplicationBuilder(String applicationName)

  - ### Method Detail

    - #### newApplication

          public Application newApplication()
                                     throws AssemblyException,
                                            ActivationException

      Create and activate a new Application.
      Returns:
        Activated Application
      Throws:
        `AssemblyException` - if the assembly failed
        `ActivationException` - if the activation failed

    - #### beforeActivation

          protected void beforeActivation()

      Called before application activation.

    - #### afterActivation

          protected void afterActivation()

      Called after application activation.

    - #### registerActivationEventListener

          public void registerActivationEventListener(ActivationEventListener listener)

      Specified by:
        `registerActivationEventListener` in interface `ActivationEventListenerRegistration`
      Parameters:
        `listener` - will be notified when Activation events occur

    - #### deregisterActivationEventListener

          public void deregisterActivationEventListener(ActivationEventListener listener)

      Specified by:
        `deregisterActivationEventListener` in interface `ActivationEventListenerRegistration`
      Parameters:
        `listener` - will not be notified when Activation events occur anymore

    - #### withLayer

          public LayerDeclaration withLayer(String layerName)

      Declare Layer.
      Parameters:
        `layerName` - Name of the Layer
      Returns:
        Layer declaration for the given name, new if did not already exists

    - #### fromJson

          public static ApplicationBuilder fromJson(String json)
                                             throws JSONException,
                                                    AssemblyException

      Load an ApplicationBuilder from a JSON String.
      Parameters:
        `json` - JSON String
      Returns:
        Application Builder loaded from JSON
      Throws:
        `JSONException` - if unable to read JSON
        `AssemblyException` - if unable to declare the assembly

    - #### fromJson

          public static ApplicationBuilder fromJson(InputStream json)
                                             throws JSONException,
                                                    AssemblyException

      Load an ApplicationBuilder from a JSON InputStream.
      Parameters:
        `json` - JSON input
      Returns:
        Application Builder loaded from JSON
      Throws:
        `JSONException` - if unable to read JSON
        `AssemblyException` - if unable to declare the assembly

    - #### fromJson

          public static ApplicationBuilder fromJson(JSONObject root)
                                             throws JSONException,
                                                    AssemblyException

      Load an ApplicationBuilder from a JSONObject.
      Parameters:
        `root` - JSON object
      Returns:
        Application Builder loaded from JSON
      Throws:
        `JSONException` - if unable to read JSON
        `AssemblyException` - if unable to declare the assembly

    - #### configureWithJson

          protected void configureWithJson(JSONObject root)
                                    throws JSONException,
                                           AssemblyException

      Configures the application struucture from a JSON document.
      Parameters:
        `root` - The JSON document root.
      Throws:
        `JSONException` - if the JSON document isn't valid.
        `AssemblyException` - if probelms in the Assemblers provided in the JSON document.

    - #### main

          public static void main(String[] args)
                           throws JSONException,
                                  ActivationException,
                                  AssemblyException

      main method that read JSON from STDIN.

      Passivation exceptions are written to STDERR if any.

      Parameters:
        `args` - Unused
      Throws:
        `JSONException` - if unable to read JSON
        `AssemblyException` - if the assembly failed
        `ActivationException` - if the activation failed