try {
// If the deployment is to server.xml, then update server.xml with the application information
if (containerConfiguration.isDeployTypeXML()) {
// Throw error if deployment type is not ear, war, or eba
if (!archiveType.equalsIgnoreCase("ear") && !archiveType.equalsIgnoreCase("war") && !archiveType.equalsIgnoreCase("eba"))
throw new DeploymentException("Invalid archive type: " + archiveType + ". Valid archive types are ear, war, and eba.");
// Save the archive to disk so it can be loaded by the container.
String appDir = getAppDirectory();
File exportedArchiveLocation = new File(appDir, archiveName);
archive.as(ZipExporter.class).exportTo(exportedArchiveLocation, true);
// Read server.xml file into Memory
Document document = readServerXML();
// Add the archive as appropriate to the server.xml file
addApplication(document, deployName, archiveName, archiveType);
// Update server.xml on file system
writeServerXML(document);
}
// Otherwise put the application in the dropins directory
else {
// Save the archive to disk so it can be loaded by the container.
String dropInDir = getDropInDirectory();
File exportedArchiveLocation = new File(dropInDir, archiveName);
archive.as(ZipExporter.class).exportTo(exportedArchiveLocation, true);
}
// Wait until the application is deployed and available
waitForApplicationTargetState(deployName, true, containerConfiguration.getAppDeployTimeout());
// Return metadata on how to contact the deployed application
ProtocolMetaData metaData = new ProtocolMetaData();
HTTPContext httpContext = new HTTPContext("localhost", containerConfiguration.getHttpPort());
httpContext.add(new Servlet("ArquillianServletRunner", deployName));
metaData.addContext(httpContext);
if (log.isLoggable(Level.FINER)) {
log.exiting(className, "deploy");
}
return metaData;
} catch (Exception e) {
throw new DeploymentException("Exception while deploying application.", e);
}
}