org.mule.runtime.module.deployment.internal.DomainArchiveDeployer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-module-deployment Show documentation
Show all versions of mule-module-deployment Show documentation
Provides container artifacts deployment functionality
The newest version!
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.runtime.module.deployment.internal;
import org.mule.runtime.api.util.Preconditions;
import org.mule.runtime.deployment.model.api.DeploymentException;
import org.mule.runtime.deployment.model.api.application.Application;
import org.mule.runtime.deployment.model.api.domain.Domain;
import org.mule.runtime.module.deployment.api.DeploymentListener;
import org.mule.runtime.module.deployment.api.DeploymentService;
import org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactFactory;
import java.io.File;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import org.apache.commons.lang3.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Archive deployer for domains.
*
* Knows how to deploy / undeploy a domain and a domain bundle (zip with domain + domains apps).
*/
public class DomainArchiveDeployer implements ArchiveDeployer {
private transient final Logger logger = LoggerFactory.getLogger(getClass());
public static final String DOMAIN_BUNDLE_APPS_FOLDER = "apps";
private final ArchiveDeployer domainDeployer;
private final DeploymentService deploymentService;
private final ArchiveDeployer applicationDeployer;
public DomainArchiveDeployer(ArchiveDeployer domainDeployer, ArchiveDeployer applicationDeployer,
DeploymentService deploymentService) {
this.domainDeployer = domainDeployer;
this.applicationDeployer = applicationDeployer;
this.deploymentService = deploymentService;
}
@Override
public boolean isUpdatedZombieArtifact(String artifactName) {
// Domains do not manage zombie artifacts
return true;
}
/**
* Undeploys a domain.
*
* Before undeploying the domain it undeploys the applications associated.
*
* @param artifactId domain name to undeploy
*/
@Override
public void undeployArtifact(String artifactId) {
Collection domainApplications = findApplicationsAssociated(artifactId);
for (Application domainApplication : domainApplications) {
applicationDeployer.undeployArtifact(domainApplication.getArtifactName());
}
domainDeployer.undeployArtifact(artifactId);
}
private Collection findApplicationsAssociated(String artifactId) {
Domain domain = deploymentService.findDomain(artifactId);
Preconditions.checkArgument(domain != null, String.format("Domain %s does not exists", artifactId));
return findApplicationsAssociated(domain);
}
private Collection findApplicationsAssociated(Domain domain) {
return deploymentService.findDomainApplications(domain.getArtifactName());
}
@Override
public File getDeploymentDirectory() {
return domainDeployer.getDeploymentDirectory();
}
@Override
public void setDeploymentListener(DeploymentListener deploymentListener) {
domainDeployer.setDeploymentListener(deploymentListener);
}
@Override
public Map> getArtifactsZombieMap() {
return domainDeployer.getArtifactsZombieMap();
}
@Override
public void setArtifactFactory(ArtifactFactory artifactFactory) {
domainDeployer.setArtifactFactory(artifactFactory);
}
@Override
public void undeployArtifactWithoutUninstall(Domain artifact) {
throw new NotImplementedException("undeploy without uninstall is not supported for domains");
}
@Override
public Domain deployPackagedArtifact(URI domainArchiveUri, Optional appProperties) throws DeploymentException {
return domainDeployer.deployPackagedArtifact(domainArchiveUri, appProperties);
}
@Override
public Domain deployPackagedArtifact(String zip, Optional deploymentProperties) throws DeploymentException {
return domainDeployer.deployPackagedArtifact(zip, deploymentProperties);
}
@Override
public void redeploy(Domain artifact, Optional deploymentProperties) throws DeploymentException {
try {
domainDeployer.redeploy(artifact, deploymentProperties);
} catch (DeploymentException e) {
logger.warn(String.format("Failure during redeployment of domain %s, domain applications deployment will be skipped",
artifact.getArtifactName()));
throw e;
}
}
@Override
public void deployArtifact(Domain artifact, Optional deploymentProperties) throws DeploymentException {
domainDeployer.deployArtifact(artifact, deploymentProperties);
}
@Override
public Domain deployExplodedArtifact(String artifactDir, Optional deploymentProperties) {
return domainDeployer.deployExplodedArtifact(artifactDir, deploymentProperties);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy