Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CApp classloader to handle connector dependencies #3835

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading