use of com.alipay.sofa.runtime.spi.component.SofaRuntimeContext in project sofa-boot by sofastack.
the class ComponentManagerShutdownTest method initComponentManager.
private ComponentManager initComponentManager() {
AnnotationConfigApplicationContext rootContext = new AnnotationConfigApplicationContext(ComponentManagerTestConfiguration.class);
SofaRuntimeContext sofaRuntimeContext = rootContext.getBean(SofaRuntimeContext.class);
ComponentManager componentManager = sofaRuntimeContext.getComponentManager();
ComponentName serviceComponentName = ComponentNameFactory.createComponentName(SERVICE_COMPONENT_TYPE, SampleService.class, "");
ComponentInfo serviceComponentInfo = componentManager.getComponentInfo(serviceComponentName);
componentManager.register(serviceComponentInfo);
GenericApplicationContext applicationContext = new GenericApplicationContext();
ComponentName springComponentName = ComponentNameFactory.createComponentName(SPRING_COMPONENT_TYPE, "testModule");
ComponentInfo springComponentInfo = new SpringContextComponent(springComponentName, new SpringContextImplementation(applicationContext), sofaRuntimeContext);
applicationContext.refresh();
componentManager.register(springComponentInfo);
return componentManager;
}
Aggregations