return;
}
Collection allApps = (Collection) configRegistry.get(AppDeployerConstants.APPLICATIONS);
String[] appPaths = allApps.getChildren();
ApplicationManager appManager = ApplicationManager.getInstance();
String tenantId = AppDeployerUtils.getTenantIdString(axisConfig);
for (String currentAppPath : appPaths) {
CarbonApplication carbonApp = new CarbonApplication();
//get application collection
Collection currentAppCollection = (Collection) configRegistry.get(currentAppPath);
carbonApp.setAppName(currentAppCollection.getProperty(AppDeployerConstants.NAME));
carbonApp.setAppFilePath(currentAppCollection.
getProperty(AppDeployerConstants.APP_FILE_PATH));
//read the artifacts.xml and construct the ApplicationConfiguration
String artifactsXmlPath = currentAppPath + AppDeployerConstants.APP_ARTIFACTS_XML;
if (configRegistry.resourceExists(artifactsXmlPath)) {
Resource artifactXmlResource = configRegistry.get(artifactsXmlPath);
InputStream artifactsXmlStream = artifactXmlResource.getContentStream();
if (artifactsXmlStream != null) {
ApplicationConfiguration appConfig =
new ApplicationConfiguration(this, artifactsXmlStream);
carbonApp.setAppConfig(appConfig);
}
}
String dependencyPath = currentAppPath + AppDeployerConstants.APP_DEPENDENCIES;
// list to keep all artifacts
List<Artifact> allArtifacts = new ArrayList<Artifact>();
if (configRegistry.resourceExists(dependencyPath)) {
Collection dependencies = (Collection) configRegistry.get(dependencyPath);
for (String depPath : dependencies.getChildren()) {
Resource artifactResource = configRegistry.get(depPath +
AppDeployerConstants.ARTIFACT_XML);
InputStream xmlStream = artifactResource.getContentStream();
Artifact artifact = null;
if (xmlStream != null) {
artifact = appManager.buildAppArtifact(carbonApp, xmlStream);
}
if (artifact != null) {
Collection artCollection = (Collection) configRegistry.get(depPath);
artifact.setRuntimeObjectName(artCollection
.getProperty(AppDeployerConstants.RUNTIME_OBJECT_NAME));
allArtifacts.add(artifact);
}
}
}
Artifact appArtifact = carbonApp.getAppConfig().getApplicationArtifact();
appManager.buildDependencyTree(appArtifact, allArtifacts);
appManager.addCarbonApp(tenantId, carbonApp);
}
} catch (RegistryException e) {
String msg = "Unable to load Applications. Registry transactions failed.";
log.error(msg, e);
throw new Exception(msg, e);