use of com.alipay.sofa.isle.deployment.DeploymentDescriptor 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();
}
}
}
use of com.alipay.sofa.isle.deployment.DeploymentDescriptor in project sofa-boot by sofastack.
the class FileDeploymentDescriptorWhiteSpacePathTest method test.
@Test
public void test() throws Exception {
ClassLoader classLoader = this.getClass().getClassLoader();
Enumeration<URL> urls = classLoader.getResources("white space/" + SofaBootConstants.SOFA_MODULE_FILE);
while (urls != null && urls.hasMoreElements()) {
URL url = urls.nextElement();
DeploymentDescriptor dd = DeploymentBuilder.build(url, null, null, classLoader);
Assert.assertTrue(dd.isSpringPowered());
}
}
use of com.alipay.sofa.isle.deployment.DeploymentDescriptor in project sofa-boot by sofastack.
the class TestModelCreatingStage method getAllDeployments.
@Override
protected void getAllDeployments(ApplicationRuntimeModel application) throws IOException {
Enumeration<URL> urls = appClassLoader.getResources("META-INF/" + SofaBootConstants.SOFA_MODULE_FILE);
if (urls == null || !urls.hasMoreElements()) {
return;
}
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
UrlResource urlResource = new UrlResource(url);
Properties props = new Properties();
props.load(urlResource.getInputStream());
DeploymentDescriptorConfiguration deploymentDescriptorConfiguration = new DeploymentDescriptorConfiguration(Collections.singletonList(SofaBootConstants.MODULE_NAME), Collections.singletonList(SofaBootConstants.REQUIRE_MODULE));
DeploymentDescriptor dd = DeploymentBuilder.build(url, props, deploymentDescriptorConfiguration, appClassLoader);
if (application.isModuleDeployment(dd)) {
if (sofaModuleProfileChecker.acceptModule(dd)) {
application.addDeployment(dd);
} else {
application.addInactiveDeployment(dd);
}
}
}
}
Aggregations