Search in sources :

Example 6 with SpringContextComponent

use of com.alipay.sofa.runtime.spring.SpringContextComponent 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;
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) SpringContextImplementation(com.alipay.sofa.runtime.spring.SpringContextImplementation) ComponentManager(com.alipay.sofa.runtime.spi.component.ComponentManager) ComponentName(com.alipay.sofa.runtime.api.component.ComponentName) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) SpringContextComponent(com.alipay.sofa.runtime.spring.SpringContextComponent) SofaRuntimeContext(com.alipay.sofa.runtime.spi.component.SofaRuntimeContext)

Aggregations

ComponentName (com.alipay.sofa.runtime.api.component.ComponentName)6 ComponentInfo (com.alipay.sofa.runtime.spi.component.ComponentInfo)6 SpringContextComponent (com.alipay.sofa.runtime.spring.SpringContextComponent)6 ComponentManager (com.alipay.sofa.runtime.spi.component.ComponentManager)4 SpringContextImplementation (com.alipay.sofa.runtime.spring.SpringContextImplementation)4 ErrorCode (com.alipay.sofa.boot.error.ErrorCode)2 SofaRuntimeProperties (com.alipay.sofa.runtime.SofaRuntimeProperties)2 ServiceRuntimeException (com.alipay.sofa.runtime.api.ServiceRuntimeException)2 SofaLogger (com.alipay.sofa.runtime.log.SofaLogger)2 ComponentStatus (com.alipay.sofa.runtime.model.ComponentStatus)2 ComponentType (com.alipay.sofa.runtime.model.ComponentType)2 ClientFactoryInternal (com.alipay.sofa.runtime.spi.client.ClientFactoryInternal)2 Implementation (com.alipay.sofa.runtime.spi.component.Implementation)2 SofaRuntimeContext (com.alipay.sofa.runtime.spi.component.SofaRuntimeContext)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2