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.
5    * <p/>
6    * {@link #onStart()} will be invoked:
7    * <ol>
8    *     <li>immediately after the host application has started up; and</li>
9    *     <li>immediately after the host application has been restored from backup (if the host supports backup and restore); and</li>
10   *     <li>immediately after a plugin module is enabled, if the plugin is installed or enabled manually after the host application
11   *     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 a declared
15   * interface. For transformerless plugins using the atlassian spring scanner, this can be done using the {@code ExportAsService}
16   * annotation. For transformed plugins, use a {@code <component>} with a {@code public="true"} attribute and an
17   * {@code <interface>com.atlassian.sal.api.lifecycle.LifecycleAware</interface>} child element. 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       * Notification that the plugin is enabled and the application is started, including  after being restored from backup.
31       */
32      void onStart();
33  }