
org.glassfish.embed.CommandExecution Maven / Gradle / Ivy
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.glassfish.embed;
import com.sun.enterprise.v3.common.PropsFileActionReporter;
import org.glassfish.api.ActionReport;
/**
* Holds information about the command execution, such as the exit code and
* message.
*
*
* CommandExecution ce = server.execute("deploy", myWar);
* ActionReport.ExitCode exitCode = ce.getExitCode();
* String msg = ce.getMessage();
*
* @author Jennifer
*/
public class CommandExecution {
/**
* org.glassfish.api.ActionReport
contains information about
* the execution of the command. The content of the
* org.glassfish.api.ActionReport
is set by the individual
* commands. This information may include command execution
* messages and exit codes. This method is called after {@link execute} to
* retrieve an ActionReport
that has been populated by the command.
* It will be empty if no command has been executed.
*
* Example of how to use org.glassfish.api.ActionReport
with a list command.
*
*
* ce.execute("list-jdbc-connection-pools", options);
ActionReport report = ce.getReport();
List list = report.getTopMessagePart().getChildren();
for (org.glassfish.api.ActionReport.MessagePart mp : list) {
System.out.println(mp.getMessage());
}
*
*
* @return the {@link org.glassfish.api.ActionReport}
*/
public ActionReport getActionReport() {
return report;
}
/**
* Returns the exit code from the command execution. This method is called
* after Server execute(String commandName, CommandParameters params)
* to retrieve an org.glassfish.api.ActionReport.ExitCode
* from the command.
*
* - SUCCESS
* - FAILURE
*
* @return the exit code from the org.glassfish.api.ActionReport
*/
public ActionReport.ExitCode getExitCode() {
return report.getActionExitCode();
}
/**
* Returns the message if any from the command execution. This method is
* called after Server execute(String commandName, CommandParameters params)
* to retrieve a message from the command.
* If this method returns an empty string, either no command was executed or
* the command did not set any message on the org.glassfish.api.ActionReport
*
* @return the message from the org.glassfish.api.ActionReport
*/
public String getMessage() {
String msg = report.getMessage();
return msg==null ? "" : msg;
}
void setActionReport(ActionReport report) {
this.report = report;
}
void setExitCode(ActionReport.ExitCode exitCode) {
this.report.setActionExitCode(exitCode);
}
void setMessage(String msg) {
this.report.setMessage(msg);
}
private ActionReport report = new PropsFileActionReporter();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy