Search in sources :

Example 1 with SpringContextLoader

use of com.alipay.sofa.isle.loader.SpringContextLoader in project sofa-boot by sofastack.

the class SpringContextInstallStage method doProcess.

private void doProcess(ApplicationRuntimeModel application) throws Exception {
    outputModulesMessage(application);
    SpringContextLoader springContextLoader = createSpringContextLoader();
    installSpringContext(application, springContextLoader);
    if (sofaModuleProperties.isModuleStartUpParallel()) {
        refreshSpringContextParallel(application);
    } else {
        refreshSpringContext(application);
    }
}
Also used : SpringContextLoader(com.alipay.sofa.isle.loader.SpringContextLoader) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader)

Example 2 with SpringContextLoader

use of com.alipay.sofa.isle.loader.SpringContextLoader in project sofa-boot by alipay.

the class BeanHierarchyTest method refreshApplication.

private void refreshApplication(ApplicationRuntimeModel application) throws Exception {
    DefaultListableBeanFactory rootBeanFactory = new DefaultListableBeanFactory();
    ConfigurableApplicationContext rootApplicationContext = new GenericApplicationContext(rootBeanFactory);
    rootApplicationContext.refresh();
    SofaModuleProperties sofaModuleProperties = new SofaModuleProperties();
    sofaModuleProperties.setBeanLoadCost(1);
    rootBeanFactory.registerSingleton("sofaModuleProperties", sofaModuleProperties);
    rootBeanFactory.registerSingleton(SofaBootConstants.PROCESSORS_OF_ROOT_APPLICATION_CONTEXT, new HashMap<>());
    SpringContextLoader springContextLoader = new DynamicSpringContextLoader(rootApplicationContext);
    for (DeploymentDescriptor dd : application.getResolvedDeployments()) {
        if (dd.isSpringPowered()) {
            springContextLoader.loadSpringContext(dd, application);
            ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) dd.getApplicationContext();
            dd.startDeploy();
            ctx.refresh();
            dd.deployFinish();
        }
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringContextLoader(com.alipay.sofa.isle.loader.SpringContextLoader) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) FileDeploymentDescriptor(com.alipay.sofa.isle.deployment.impl.FileDeploymentDescriptor) DeploymentDescriptor(com.alipay.sofa.isle.deployment.DeploymentDescriptor) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader) SofaModuleProperties(com.alipay.sofa.isle.spring.config.SofaModuleProperties)

Example 3 with SpringContextLoader

use of com.alipay.sofa.isle.loader.SpringContextLoader in project sofa-boot by alipay.

the class SpringContextInstallStage method doProcess.

private void doProcess(ApplicationRuntimeModel application) throws Exception {
    outputModulesMessage(application);
    SpringContextLoader springContextLoader = createSpringContextLoader();
    installSpringContext(application, springContextLoader);
    if (sofaModuleProperties.isModuleStartUpParallel()) {
        refreshSpringContextParallel(application);
    } else {
        refreshSpringContext(application);
    }
}
Also used : SpringContextLoader(com.alipay.sofa.isle.loader.SpringContextLoader) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader)

Example 4 with SpringContextLoader

use of com.alipay.sofa.isle.loader.SpringContextLoader in project sofa-boot by sofastack.

the class BeanHierarchyTest method refreshApplication.

private void refreshApplication(ApplicationRuntimeModel application) throws Exception {
    DefaultListableBeanFactory rootBeanFactory = new DefaultListableBeanFactory();
    ConfigurableApplicationContext rootApplicationContext = new GenericApplicationContext(rootBeanFactory);
    rootApplicationContext.refresh();
    SofaModuleProperties sofaModuleProperties = new SofaModuleProperties();
    sofaModuleProperties.setBeanLoadCost(1);
    rootBeanFactory.registerSingleton("sofaModuleProperties", sofaModuleProperties);
    rootBeanFactory.registerSingleton(SofaBootConstants.PROCESSORS_OF_ROOT_APPLICATION_CONTEXT, new HashMap<>());
    SpringContextLoader springContextLoader = new DynamicSpringContextLoader(rootApplicationContext);
    for (DeploymentDescriptor dd : application.getResolvedDeployments()) {
        if (dd.isSpringPowered()) {
            springContextLoader.loadSpringContext(dd, application);
            ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) dd.getApplicationContext();
            dd.startDeploy();
            ctx.refresh();
            dd.deployFinish();
        }
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringContextLoader(com.alipay.sofa.isle.loader.SpringContextLoader) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) FileDeploymentDescriptor(com.alipay.sofa.isle.deployment.impl.FileDeploymentDescriptor) DeploymentDescriptor(com.alipay.sofa.isle.deployment.DeploymentDescriptor) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) DynamicSpringContextLoader(com.alipay.sofa.isle.loader.DynamicSpringContextLoader) SofaModuleProperties(com.alipay.sofa.isle.spring.config.SofaModuleProperties)

Aggregations

DynamicSpringContextLoader (com.alipay.sofa.isle.loader.DynamicSpringContextLoader)4 SpringContextLoader (com.alipay.sofa.isle.loader.SpringContextLoader)4 DeploymentDescriptor (com.alipay.sofa.isle.deployment.DeploymentDescriptor)2 FileDeploymentDescriptor (com.alipay.sofa.isle.deployment.impl.FileDeploymentDescriptor)2 SofaModuleProperties (com.alipay.sofa.isle.spring.config.SofaModuleProperties)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)2 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2