public String deploy(Archive<?> archive, String target) throws DeploymentException {
try {
final InputStream input = archive.as(ZipExporter.class).exportAsInputStream();
try {
InitialDeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
DeploymentPlan plan = builder.add(archive.getName(), input).andDeploy().toServerGroup(target).build();
DeploymentAction deployAction = plan.getDeploymentActions().get(plan.getDeploymentActions().size() - 1);
return executeDeploymentPlan(plan, deployAction);
} finally {
if (input != null)
try {