View Javadoc

1   package com.atlassian.sal.api.lifecycle;
2   
3   /**
4    * Marker interface that indicates a component wishes to execute some code after application startup. {@link #onStart()}
5    * will be invoked:
6    * <ol>
7    *     <li>immediately after the host application has started up; and</li>
8    *     <li>immediately after the host application has been restored from backup (if the host supports backup and
9    *     restore); and</li>
10   *     <li>immediately after a plugin module is enabled, if the plugin is installed or enabled manually after the host
11   *     application has already started.</li>
12   * </ol>
13   * <p>
14   * <strong>Note:</strong> for this to work a component must be exposed as an OSGi service with {@code LifecycleAware} as
15   * a declared interface. The plugin system will do this for you automatically if you add a {@code public="true"}
16   * attribute and &lt;interface&gt;com.atlassian.sal.api.lifecycle.LifecycleAware&lt/interface&gt child element to your
17   * &lt;component&gt; definition. For example:
18   * <pre>
19   *      &lt;component key="my-cool-component" class="com.atlassian.stash.MyCoolComponent" public="true"&gt;
20   *          &lt;interface&gt;com.atlassian.sal.api.lifecycle.LifecycleAware&lt;/interface&gt;
21   *      &lt;/component&gt;
22   * </pre>
23   * <p>
24   *
25   * @since 2.0
26   */
27  public interface LifecycleAware
28  {
29      /**
30       * Called when the application has started or has been restored from backup
31       */
32      void onStart();
33  }