use of com.alipay.sofa.isle.deployment.DeploymentDescriptorConfiguration in project sofa-boot by alipay.
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);
}
}
}
}
use of com.alipay.sofa.isle.deployment.DeploymentDescriptorConfiguration in project sofa-boot by sofastack.
the class ModelCreatingStage method getAllDeployments.
protected void getAllDeployments(ApplicationRuntimeModel application) throws IOException, DeploymentException {
Enumeration<URL> urls = appClassLoader.getResources(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)) {
validateDuplicateModule(application.addDeployment(dd), dd);
} else {
application.addInactiveDeployment(dd);
}
}
}
}
use of com.alipay.sofa.isle.deployment.DeploymentDescriptorConfiguration in project sofa-boot by sofastack.
the class DeploymentExceptionTest method test.
@Test(expected = DeploymentException.class)
public void test() throws Exception {
// create ApplicationRuntimeModel with dependency problem
ApplicationRuntimeModel application = new ApplicationRuntimeModel();
application.setAppName("testCase");
application.setModuleDeploymentValidator(new DefaultModuleDeploymentValidator());
DeploymentDescriptorConfiguration deploymentDescriptorConfiguration = new DeploymentDescriptorConfiguration(Collections.singletonList(SofaBootConstants.MODULE_NAME), Collections.singletonList(SofaBootConstants.REQUIRE_MODULE));
Properties props = new Properties();
props.setProperty(SofaBootConstants.MODULE_NAME, "com.alipay.test");
props.setProperty(SofaBootConstants.REQUIRE_MODULE, "com.alipay.dependency");
URL fileUrl = new URL("file:/demo/path/isle-module.config");
application.addDeployment(DeploymentBuilder.build(fileUrl, props, deploymentDescriptorConfiguration, ApplicationRuntimeModelTest.class.getClassLoader()));
// mock ApplicationContext
AbstractApplicationContext applicationContext = mock(AbstractApplicationContext.class);
when(applicationContext.getBean(SofaBootConstants.APPLICATION, ApplicationRuntimeModel.class)).thenReturn(application);
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);
when(applicationContext.getEnvironment()).thenReturn(environment);
when(environment.getProperty(SofaBootConstants.APP_NAME_KEY)).thenReturn("testCase");
new SpringContextInstallStage(applicationContext, new SofaModuleProperties()).process();
}
use of com.alipay.sofa.isle.deployment.DeploymentDescriptorConfiguration 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