use of com.ctrip.xpipe.api.lifecycle.TopElement in project x-pipe by ctripcorp.
the class SpringComponentRegistry method lifecycleCallable.
@Override
public List<Lifecycle> lifecycleCallable() {
List<Lifecycle> result = new LinkedList<>();
Map<String, Lifecycle> beans = applicationContext.getBeansOfType(Lifecycle.class);
for (Entry<String, Lifecycle> entry : beans.entrySet()) {
@SuppressWarnings("unused") String name = entry.getKey();
Lifecycle bean = entry.getValue();
if (bean instanceof TopElement) {
result.add((Lifecycle) bean);
}
}
return sort(result);
}
use of com.ctrip.xpipe.api.lifecycle.TopElement 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());
}
}
}
Aggregations