use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.
the class DefaultMuleDeployerTestCase method disposesAppOnDeployFailure.
@Test
public void disposesAppOnDeployFailure() throws Exception {
DefaultArtifactDeployer deployer = new DefaultArtifactDeployer();
Application app = mock(Application.class);
doThrow(new IllegalStateException()).when(app).init();
try {
deployer.deploy(app);
fail("Deployment is supposed to fail");
} catch (DeploymentException expected) {
}
verify(app, times(1)).dispose();
}
use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.
the class ArtifactArchiveInstaller method uninstallArtifact.
/**
* Uninstalls an artifact from the Mule container installation.
*
* It will remove the artifact folder and the anchor file related
*
* @param artifactName name of the artifact to be uninstalled.
*/
void uninstallArtifact(final String artifactName) {
try {
final File artifactDir = new File(artifactParentDir, artifactName);
deleteDirectory(artifactDir);
// remove a marker, harmless, but a tidy artifact dir is always better :)
File marker = getArtifactAnchorFile(artifactName);
marker.delete();
Introspector.flushCaches();
} catch (Throwable t) {
if (t instanceof DeploymentException) {
throw ((DeploymentException) t);
}
final String msg = String.format("Failed to undeployArtifact artifact [%s]", artifactName);
throw new DeploymentException(I18nMessageFactory.createStaticMessage(msg), t);
}
}
use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.
the class DefaultArchiveDeployer method deployExplodedApp.
private T deployExplodedApp(String addedApp, Optional<Properties> deploymentProperties) throws DeploymentException {
if (logger.isInfoEnabled()) {
logger.info("================== New Exploded Artifact: " + addedApp);
}
T artifact;
try {
File artifactLocation = new File(artifactDir, addedApp);
artifact = createArtifact(artifactLocation, deploymentProperties);
// add to the list of known artifacts first to avoid deployment loop on failure
trackArtifact(artifact);
} catch (Throwable t) {
final File artifactDir1 = artifactDir;
File artifactDir = new File(artifactDir1, addedApp);
addZombieFile(addedApp, artifactDir);
if (containsType(t, DeploymentStartException.class)) {
logger.error(miniSplash(format("Failed to deploy artifact '%s', see artifact's log for details", addedApp)));
logger.error(t.getMessage());
} else {
logger.error(miniSplash(format("Failed to deploy artifact '%s', see below", addedApp)), t);
}
deploymentListener.onDeploymentFailure(addedApp, t);
if (t instanceof DeploymentException) {
throw (DeploymentException) t;
} else {
throw new DeploymentException(createStaticMessage("Failed to deploy artifact: " + addedApp), t);
}
}
deployArtifact(artifact, deploymentProperties);
return artifact;
}
use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.
the class DefaultArchiveDeployer method deployPackagedArtifact.
@Override
public T deployPackagedArtifact(URI artifactAchivedUri, Optional<Properties> appProperties) throws DeploymentException {
Optional<T> foundMatchingArtifact = empty();
try {
File artifactLocation = installArtifact(artifactAchivedUri);
T artifact;
try {
artifact = createArtifact(artifactLocation, appProperties);
trackArtifact(artifact);
} catch (Throwable t) {
String artifactName = artifactLocation.getName();
// error text has been created by the deployer already
logDeploymentFailure(t, artifactName);
foundMatchingArtifact.ifPresent(a -> deploymentListener.onRedeploymentFailure(a.getArtifactName(), t));
addZombieFile(artifactName, artifactLocation);
deploymentListener.onDeploymentFailure(artifactName, t);
throw t;
}
deployArtifact(artifact, appProperties);
foundMatchingArtifact.ifPresent(a -> deploymentListener.onRedeploymentSuccess(a.getArtifactName()));
return artifact;
} catch (Throwable t) {
foundMatchingArtifact.ifPresent(a -> deploymentListener.onRedeploymentFailure(a.getArtifactName(), t));
if (t instanceof DeploymentException) {
// re-throw
throw ((DeploymentException) t);
}
final String msg = "Failed to deploy from URI: " + artifactAchivedUri;
throw new DeploymentException(createStaticMessage(msg), t);
}
}
use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.
the class DefaultArtifactDeployer method deploy.
public void deploy(T artifact) {
try {
artifact.install();
doInit(artifact);
artifact.start();
} catch (Throwable t) {
artifact.dispose();
if (t instanceof DeploymentException) {
throw ((DeploymentException) t);
}
final String msg = String.format("Failed to deploy artifact [%s]", artifact.getArtifactName());
throw new DeploymentException(I18nMessageFactory.createStaticMessage(msg), t);
}
}
Aggregations