Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#getLifecycleBeans()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#getLifecycleBeans() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteKernal.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cfg Ignite configuration to use.
 * @return Components provided in configuration which can implement {@link LifecycleAware} interface.
 */
private Iterable<Object> lifecycleAwares(IgniteConfiguration cfg) {
    Collection<Object> objs = new ArrayList<>();

    if (cfg.getLifecycleBeans() != null)
        Collections.addAll(objs, cfg.getLifecycleBeans());

    if (cfg.getSegmentationResolvers() != null)
        Collections.addAll(objs, cfg.getSegmentationResolvers());

    if (cfg.getConnectorConfiguration() != null) {
        objs.add(cfg.getConnectorConfiguration().getMessageInterceptor());
        objs.add(cfg.getConnectorConfiguration().getSslContextFactory());
    }

    objs.add(cfg.getMarshaller());
    objs.add(cfg.getGridLogger());
    objs.add(cfg.getMBeanServer());

    if (cfg.getCommunicationFailureResolver() != null)
        objs.add(cfg.getCommunicationFailureResolver());

    return objs;
}
 
Example 2
Source File: PlatformDotNetConfigurationClosure.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Find .Net lifecycle beans in configuration.
 *
 * @param cfg Configuration.
 * @return Beans.
 */
private static List<PlatformDotNetLifecycleBean> beans(IgniteConfiguration cfg) {
    List<PlatformDotNetLifecycleBean> res = new ArrayList<>();

    if (cfg.getLifecycleBeans() != null) {
        for (LifecycleBean bean : cfg.getLifecycleBeans()) {
            if (bean instanceof PlatformDotNetLifecycleBean)
                res.add((PlatformDotNetLifecycleBean)bean);
        }
    }

    return res;
}
 
Example 3
Source File: SpringCacheManagerContextInjectionTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBeanInjectionUsingConfigPath() throws Exception {
    new AnnotationConfigApplicationContext(TestPathConfiguration.class);

    Ignite grid = IgnitionEx.grid("springInjectionTest");

    IgniteConfiguration cfg = grid.configuration();

    LifecycleBean[] beans = cfg.getLifecycleBeans();

    assertEquals(2, beans.length);

    TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)beans[0];
    TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)beans[1];

    bean1.checkState();
    bean2.checkState();
}
 
Example 4
Source File: SpringTransactionManagerContextInjectionTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBeanInjectionUsingConfigPath() throws Exception {
    BeanFactory factory = new AnnotationConfigApplicationContext(TestPathConfiguration.class);

    Ignite grid = IgnitionEx.grid("springInjectionTest");

    IgniteConfiguration cfg = grid.configuration();

    LifecycleBean[] beans = cfg.getLifecycleBeans();

    assertEquals(2, beans.length);

    TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean)beans[0];
    TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean)beans[1];

    bean1.checkState();
    bean2.checkState();
}