Skip to content

Commit

Permalink
Improve CApp classloader to handle connector dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arunans23 committed Dec 16, 2024
1 parent 61ab8c7 commit 173438d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class CarbonApplication {
private String appVersion;
private boolean deploymentCompleted;
private String mainSequence;
private ClassLoader classLoader;

private ApplicationConfiguration appConfig;

Expand Down Expand Up @@ -109,5 +110,13 @@ public String getMainSequence() {
public void setMainSequence(String mainSequence) {
this.mainSequence = mainSequence;
}

public ClassLoader getClassLoader() {
return classLoader;
}

public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisC
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact()
.getDependencies();

deployClassMediators(artifacts, axisConfig);
deploySynapseLibrary(artifacts, axisConfig);
deployClassMediators(artifacts, axisConfig, carbonApp);
deploySynapseLibrary(artifacts, axisConfig, carbonApp);
Map<String, List<Artifact.Dependency>> artifactTypeMap = getOrderedArtifactsMap(artifacts);

//deploy artifacts
Expand Down Expand Up @@ -335,8 +335,8 @@ && handleMainFaultSeqUndeployment(artifact, axisConfig)) {
* @param axisConfig AxisConfiguration of the current tenant
* @throws DeploymentException if something goes wrong while deployment
*/
private void deployClassMediators(List<Artifact.Dependency> artifacts,
AxisConfiguration axisConfig) throws DeploymentException {
private void deployClassMediators(List<Artifact.Dependency> artifacts, AxisConfiguration axisConfig,
CarbonApplication carbonApplication) throws DeploymentException {
for (Artifact.Dependency dependency : artifacts) {

Artifact artifact = dependency.getArtifact();
Expand All @@ -354,7 +354,9 @@ private void deployClassMediators(List<Artifact.Dependency> artifacts,
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;

try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
DeploymentFileData deploymentFileData = new DeploymentFileData(new File(artifactPath), deployer);
deploymentFileData.setClassLoader(carbonApplication.getClassLoader());
deployer.deploy(deploymentFileData);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
Expand All @@ -372,8 +374,8 @@ private void deployClassMediators(List<Artifact.Dependency> artifacts,
* @param axisConfig AxisConfiguration of the current tenant
* @throws DeploymentException if something goes wrong while deployment
*/
private void deploySynapseLibrary(List<Artifact.Dependency> artifacts,
AxisConfiguration axisConfig) throws DeploymentException {
private void deploySynapseLibrary(List<Artifact.Dependency> artifacts, AxisConfiguration axisConfig,
CarbonApplication carbonApplication) throws DeploymentException {
for (Artifact.Dependency dependency : artifacts) {

Artifact artifact = dependency.getArtifact();
Expand All @@ -397,7 +399,9 @@ private void deploySynapseLibrary(List<Artifact.Dependency> artifacts,
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
} else {
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
DeploymentFileData deploymentFileData = new DeploymentFileData(new File(artifactPath), deployer);
deploymentFileData.setClassLoader(carbonApplication.getClassLoader());
deployer.deploy(deploymentFileData);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
try {
String artifactName = getArtifactName(artifactPath, axisConfig);
Expand Down Expand Up @@ -1122,7 +1126,9 @@ public void deployArtifactType(List<Artifact.Dependency> artifacts, CarbonApplic
} else {
try {
setCustomLogContent(deployer, carbonApp);
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
DeploymentFileData deploymentFileData = new DeploymentFileData(new File(artifactPath), deployer);
deploymentFileData.setClassLoader(carbonApp.getClassLoader());
deployer.deploy(deploymentFileData);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
Expand Down

0 comments on commit 173438d

Please sign in to comment.