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 * {@link #onStop()} will be invoked only if {@link #onStart()} was invoked, when dependencies are still available:
15 * <ol>
16 * <li>on plugin framework shut down</li>
17 * <li>on plugin disabling</li>
18 * </ol>
19 * <p>
20 * <strong>Note:</strong> for this to work a component must be exposed as an OSGi service with {@code LifecycleAware} as a declared
21 * interface. For transformerless plugins using the atlassian spring scanner, this can be done using the {@code ExportAsService}
22 * annotation. For transformed plugins, use a {@code <component>} with a {@code public="true"} attribute and an
23 * {@code <interface>com.atlassian.sal.api.lifecycle.LifecycleAware</interface>} child element. For example:
24 * <pre>
25 * <component key="my-cool-component" class="com.atlassian.stash.MyCoolComponent" public="true">
26 * <interface>com.atlassian.sal.api.lifecycle.LifecycleAware</interface>
27 * </component>
28 * </pre>
29 * <p>
30 *
31 * @since 2.0
32 */
33 public interface LifecycleAware {
34 /**
35 * Notification that the plugin is enabled and the application is started, including after being restored from backup.
36 */
37 void onStart();
38
39 /**
40 * Notification that the plugin is going to be stopped.
41 * <p>
42 * Will be invoked if previously notified with {@link #onStart()}, before the plugin is disabled or framework is
43 * shut down.
44 *
45 * @since 3.0
46 */
47 void onStop();
48 }