DeploymentManager dmgr = connection.getDeploymentManager();
if(dmgr instanceof GeronimoDeploymentManager) {
try {
GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
if (commandArgs.getArgs().length == 0) {
throw new DeploymentException("Must specify Plugin CAR file");
}
File carFile = new File(commandArgs.getArgs()[0]);
carFile = carFile.getAbsoluteFile();
if(!carFile.exists() || !carFile.canRead()) {
throw new DeploymentException("CAR file cannot be read: "+carFile.getAbsolutePath());
}
//TODO figure out if there is a plausible default repo
Object key = mgr.startInstall(carFile, null, false, null, null);
long start = System.currentTimeMillis();
DownloadResults results = showProgress(consoleReader, mgr, key);
int time = (int)(System.currentTimeMillis() - start) / 1000;
printResults(consoleReader, results, time);
if(results.isFinished() && !results.isFailed() && results.getInstalledConfigIDs().size() == 1) {
Artifact target = results.getInstalledConfigIDs().get(0);
consoleReader.printString(DeployUtils.reformat("Now starting "+target+"...", 4, 72));
consoleReader.flushConsole();
new CommandStart().execute(consoleReader, connection, new BaseCommandArgs(new String[]{target.toString()}));
}
} catch (IOException e) {
throw new DeploymentException("Cannot install plugin", e);
}
} else {
throw new DeploymentException("Cannot install plugins when connected to "+connection.getServerURI());
}
}