org.apache.ignite.lifecycle

## Interface LifecycleBean

- All Known Implementing Classes:
    PlatformDotNetLifecycleBean, org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean

      public interface LifecycleBean

  A bean that reacts to node lifecycle events defined in `LifecycleEventType`. Use this bean whenever you need to plug some custom logic before or after node startup and stopping routines.

  There are four events you can react to:

  - `LifecycleEventType.BEFORE_NODE_START` invoked before node startup routine is initiated. Note that node is not available during this event, therefore if you injected a ignite instance via `IgniteInstanceResource` annotation, you cannot use it yet.
  - `LifecycleEventType.AFTER_NODE_START` invoked right after node has started. At this point, if you injected a node instance via `IgniteInstanceResource` annotation, you can start using it. Note that you should not be using `Ignition` to get node instance from lifecycle bean.
  - `LifecycleEventType.BEFORE_NODE_STOP` invoked right before node stop routine is initiated. Node is still available at this stage, so if you injected a ignite instance via `IgniteInstanceResource` annotation, you can use it.
  - `LifecycleEventType.AFTER_NODE_STOP` invoked right after node has stopped. Note that node is not available during this event.

  # Resource Injection

  Lifecycle beans can be injected using IoC (dependency injection) with ignite resources. Both, field and method based injection are supported. The following ignite resources can be injected:
  - `LoggerResource`
  - `SpringApplicationContextResource`
  - `SpringResource`
  - `IgniteInstanceResource`
  Refer to corresponding resource documentation for more information.

  # Usage

  If you need to tie your application logic into Ignition lifecycle, you can configure lifecycle beans via standard node configuration, add your application library dependencies into `IGNITE_HOME/libs` folder, and simply start `IGNITE_HOME/ignite.{sh|bat}` scripts.

  # Configuration

  Node lifecycle beans can be configured programmatically as follows:

       IgniteConfiguration cfg = new IgniteConfiguration();

       cfg.setLifecycleBeans(new FooBarLifecycleBean1(), new FooBarLifecycleBean2());

       // Start grid with given configuration.
       Ignition.start(cfg);

  or from Spring XML configuration file as follows:

       <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
          ...
          <property name="lifecycleBeans">
             <list>
                <bean class="foo.bar.FooBarLifecycleBean1"/>
                <bean class="foo.bar.FooBarLifecycleBean2"/>
             </list>
          </property>
          ...
       </bean>

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `onLifecycleEvent(LifecycleEventType evt)` This method is called when lifecycle event occurs.

- - ### Method Detail

    - #### onLifecycleEvent

          void onLifecycleEvent(LifecycleEventType evt)
                         throws IgniteException

      This method is called when lifecycle event occurs.
      Parameters:
        `evt` - Lifecycle event.
      Throws:
        `IgniteException` - Thrown in case of any errors.

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023