System.arraycopy(params, 0, newParams, 0, params.length);
newParams[params.length] = file.getAbsolutePath();
CommandExecutorImpl executer = habitat.getService(CommandExecutorImpl.class);
try {
String command = "deploy";
ActionReport actionReport = executer.createActionReport();
ParameterMap commandParams = executer.getParameters(command, newParams);
org.glassfish.api.admin.CommandRunner.CommandInvocation inv =
executer.getCommandRunner().getCommandInvocation(command, actionReport, kernelIdentity.getSubject());
inv.parameters(commandParams);
// set outputbound payload if --retrieve option is specified.
Payload.Outbound outboundPayload = null;
String retrieveOpt = commandParams.getOne("retrieve");
File retrieve = retrieveOpt != null ? new File(retrieveOpt) : null;
if (retrieve != null && retrieve.exists()) {
outboundPayload = PayloadImpl.Outbound.newInstance();
inv.outbound(outboundPayload);
}
inv.execute();
// extract the outbound payload.
if (outboundPayload != null) {
extractPayload(outboundPayload, actionReport, retrieve);
}
return actionReport.getResultType(String.class);
} catch (CommandException e) {
throw new GlassFishException(e);
}
}