Search in sources :

Example 16 with ApplicationRuntimeModel

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

the class ModelCreatingStageTest method test.

@Test
public void test() throws Exception {
    applicationContext.getBean("modelCreatingStage", ModelCreatingStage.class).process();
    ApplicationRuntimeModel application = applicationContext.getBean(SofaBootConstants.APPLICATION, ApplicationRuntimeModel.class);
    Assert.assertNotNull(application.getSofaRuntimeContext());
}
Also used : ModelCreatingStage(com.alipay.sofa.isle.stage.ModelCreatingStage) ApplicationRuntimeModel(com.alipay.sofa.isle.ApplicationRuntimeModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with ApplicationRuntimeModel

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

the class IsleBeanEndpointTest method testBeans.

@Test
public void testBeans() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext();
    context.setId("bootstrap");
    context.refresh();
    ApplicationRuntimeModel model = new ApplicationRuntimeModel();
    model.addInstalled(new MockDeploymentDescriptor("A"));
    model.addInstalled(new MockDeploymentDescriptor("B"));
    context.getBeanFactory().registerSingleton(SofaBootConstants.APPLICATION, model);
    IsleBeansEndpoint isleBeansEndpoint = new IsleBeansEndpoint(context);
    BeansEndpoint.ApplicationBeans applicationBeans = isleBeansEndpoint.beans();
    Assert.assertNotNull(applicationBeans);
    Map<String, BeansEndpoint.ContextBeans> beansMap = applicationBeans.getContexts();
    Assert.assertNotNull(beansMap);
    Assert.assertEquals(3, beansMap.size());
    Assert.assertNotNull(beansMap.get("bootstrap"));
    BeansEndpoint.ContextBeans contextBeansA = beansMap.get("isle-module-A");
    Assert.assertNotNull(contextBeansA);
    Assert.assertEquals("isle-module-parentA", contextBeansA.getParentId());
    Assert.assertTrue(contextBeansA.getBeans().toString().contains("com.alipay.sofa.boot.actuator.beans.IsleBeanEndpointTest$TestBean"));
    BeansEndpoint.ContextBeans contextBeansB = beansMap.get("isle-module-B");
    Assert.assertNotNull(contextBeansB);
    Assert.assertEquals("isle-module-parentB", contextBeansB.getParentId());
    Assert.assertTrue(contextBeansB.getBeans().toString().contains("com.alipay.sofa.boot.actuator.beans.IsleBeanEndpointTest$TestBean"));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BeansEndpoint(org.springframework.boot.actuate.beans.BeansEndpoint) ApplicationRuntimeModel(com.alipay.sofa.isle.ApplicationRuntimeModel) Test(org.junit.Test)

Example 18 with ApplicationRuntimeModel

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

the class IsleBeansEndpoint method beans.

@ReadOperation
@Override
public ApplicationBeans beans() {
    ApplicationBeans applicationBeans = super.beans();
    ApplicationRuntimeModel applicationRuntimeModel = context.getBean(SofaBootConstants.APPLICATION, ApplicationRuntimeModel.class);
    Map<String, ContextBeans> moduleApplicationContexts = getModuleApplicationContexts(applicationRuntimeModel);
    applicationBeans.getContexts().putAll(moduleApplicationContexts);
    return applicationBeans;
}
Also used : ApplicationRuntimeModel(com.alipay.sofa.isle.ApplicationRuntimeModel) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 19 with ApplicationRuntimeModel

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

the class ModelCreatingStage method doProcess.

@Override
protected void doProcess() throws Exception {
    ApplicationRuntimeModel application = new ApplicationRuntimeModel();
    application.setAppName(appName);
    SofaRuntimeManager sofaRuntimeManager = applicationContext.getBean(SofaRuntimeManager.class);
    application.setSofaRuntimeContext(sofaRuntimeManager.getSofaRuntimeContext());
    application.setModuleDeploymentValidator(new DefaultModuleDeploymentValidator());
    getAllDeployments(application);
    applicationContext.getBeanFactory().registerSingleton(SofaBootConstants.APPLICATION, application);
}
Also used : DefaultModuleDeploymentValidator(com.alipay.sofa.isle.deployment.impl.DefaultModuleDeploymentValidator) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) ApplicationRuntimeModel(com.alipay.sofa.isle.ApplicationRuntimeModel)

Example 20 with ApplicationRuntimeModel

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

the class ModuleLogOutputStage method doProcess.

@Override
protected void doProcess() throws Exception {
    ApplicationRuntimeModel application = applicationContext.getBean(SofaBootConstants.APPLICATION, ApplicationRuntimeModel.class);
    StringBuilder stringBuilder = new StringBuilder();
    logInstalledModules(stringBuilder, application.getInstalled());
    logFailedModules(stringBuilder, application.getFailed());
    logInfoBeanCost(stringBuilder, application.getInstalled());
    SofaLogger.info(stringBuilder.toString());
}
Also used : ApplicationRuntimeModel(com.alipay.sofa.isle.ApplicationRuntimeModel)

Aggregations

ApplicationRuntimeModel (com.alipay.sofa.isle.ApplicationRuntimeModel)22 Test (org.junit.Test)14 DeploymentDescriptor (com.alipay.sofa.isle.deployment.DeploymentDescriptor)10 DefaultModuleDeploymentValidator (com.alipay.sofa.isle.deployment.impl.DefaultModuleDeploymentValidator)8 DeploymentDescriptorConfiguration (com.alipay.sofa.isle.deployment.DeploymentDescriptorConfiguration)6 Properties (java.util.Properties)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 FileDeploymentDescriptor (com.alipay.sofa.isle.deployment.impl.FileDeploymentDescriptor)4 SofaModuleProperties (com.alipay.sofa.isle.spring.config.SofaModuleProperties)4 URL (java.net.URL)4 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4 BeanStat (com.alipay.sofa.boot.startup.BeanStat)2 JarDeploymentDescriptor (com.alipay.sofa.isle.deployment.impl.JarDeploymentDescriptor)2 BeanLoadCostBeanFactory (com.alipay.sofa.isle.spring.factory.BeanLoadCostBeanFactory)2 ModelCreatingStage (com.alipay.sofa.isle.stage.ModelCreatingStage)2 SpringContextInstallStage (com.alipay.sofa.isle.stage.SpringContextInstallStage)2 SofaRuntimeManager (com.alipay.sofa.runtime.spi.component.SofaRuntimeManager)2 File (java.io.File)2 BeanFactory (org.springframework.beans.factory.BeanFactory)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2