Search in sources :

Example 1 with SpringComponentRegistry

use of com.ctrip.xpipe.lifecycle.SpringComponentRegistry in project x-pipe by ctripcorp.

the class AppTest method initComponentRegistry.

private void initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
    ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
    registry.initialize();
    registry.start();
    ComponentRegistryHolder.initializeRegistry(registry);
}
Also used : SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) ComponentRegistry(com.ctrip.xpipe.api.lifecycle.ComponentRegistry) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry)

Example 2 with SpringComponentRegistry

use of com.ctrip.xpipe.lifecycle.SpringComponentRegistry in project x-pipe by ctripcorp.

the class KeeperContainerApplication method initComponentRegistry.

private static ComponentRegistry initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
    final ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
    registry.initialize();
    registry.start();
    ComponentRegistryHolder.initializeRegistry(registry);
    return registry;
}
Also used : SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) ComponentRegistry(com.ctrip.xpipe.api.lifecycle.ComponentRegistry) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry)

Example 3 with SpringComponentRegistry

use of com.ctrip.xpipe.lifecycle.SpringComponentRegistry in project x-pipe by ctripcorp.

the class SpringComponentRegistryTest method test.

@Test
public void test() throws Exception {
    ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(TestFactory.class);
    ComponentRegistry componentRegistry = new SpringComponentRegistry(applicationContext);
    componentRegistry.initialize();
    componentRegistry.start();
    Map<String, Lifecycle> objects = componentRegistry.getComponents(Lifecycle.class);
    for (Lifecycle lifecycle : objects.values()) {
        if (lifecycle instanceof TopElement) {
            Assert.assertTrue(lifecycle.getLifecycleState().isStarted());
        } else {
            Assert.assertTrue(lifecycle.getLifecycleState().isEmpty());
        }
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) TopElement(com.ctrip.xpipe.api.lifecycle.TopElement) ComponentRegistry(com.ctrip.xpipe.api.lifecycle.ComponentRegistry) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) Lifecycle(com.ctrip.xpipe.api.lifecycle.Lifecycle) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Aggregations

ComponentRegistry (com.ctrip.xpipe.api.lifecycle.ComponentRegistry)3 SpringComponentRegistry (com.ctrip.xpipe.lifecycle.SpringComponentRegistry)3 CreatedComponentRedistry (com.ctrip.xpipe.lifecycle.CreatedComponentRedistry)2 DefaultRegistry (com.ctrip.xpipe.lifecycle.DefaultRegistry)2 AbstractTest (com.ctrip.xpipe.AbstractTest)1 Lifecycle (com.ctrip.xpipe.api.lifecycle.Lifecycle)1 TopElement (com.ctrip.xpipe.api.lifecycle.TopElement)1 Test (org.junit.Test)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1