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:

    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: 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>