Package org.glassfish.api
Class ActionReport
- java.lang.Object
-
- org.glassfish.api.ActionReport
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ActionReporter
,CliActionReport
@Contract public abstract class ActionReport extends Object implements Serializable
An action report is an abstract class allowing any type of server side action like a service execution, a command execution to report on its execution to the originator of the action. Implementations of this interface should provide a good reporting experience based on the user's interface like a browser or a command line shell.- Author:
- Jerome Dochez
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ActionReport.ExitCode
static class
ActionReport.MessagePart
-
Constructor Summary
Constructors Constructor Description ActionReport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ActionReport
addSubActionsReport()
abstract void
appendMessage(String message)
void
failure(Logger logger, String message)
Short forfailure(logger,message,null)
void
failure(Logger logger, String message, Throwable e)
Report a failure to the logger andActionReport
.String
findProperty(String key)
Search in message parts properties then in extra properties and then in sub reports.abstract ActionReport.ExitCode
getActionExitCode()
abstract String
getContentType()
Properties
getExtraProperties()
abstract Throwable
getFailureCause()
abstract String
getMessage()
<T> T
getResultType(Class<T> resultType)
Gets a type that was set by the command implementationabstract List<? extends ActionReport>
getSubActionsReport()
abstract ActionReport.MessagePart
getTopMessagePart()
abstract boolean
hasFailures()
return true if the action report or a subaction report has ExitCode.FAILURE.abstract boolean
hasSuccesses()
return true if the action report or a subaction report has ExitCode.SUCCESS.abstract boolean
hasWarnings()
return true if the action report or a subaction report has ExitCode.WARNING.abstract void
setActionDescription(String message)
abstract void
setActionExitCode(ActionReport.ExitCode exitCode)
Sets the exit code for the report.abstract void
setContentType(String s)
void
setExtraProperties(Properties properties)
abstract void
setFailureCause(Throwable t)
abstract void
setMessage(InputStream in)
abstract void
setMessage(String message)
<T> void
setResultType(Class<T> resultType, T resultTypeInstance)
Stores the supplies type and its instance.String
toString()
abstract void
writeReport(OutputStream os)
Outputs the formatted information
-
-
-
Method Detail
-
setActionDescription
public abstract void setActionDescription(String message)
-
setFailureCause
public abstract void setFailureCause(Throwable t)
-
getFailureCause
public abstract Throwable getFailureCause()
-
setMessage
public abstract void setMessage(String message)
-
appendMessage
public abstract void appendMessage(String message)
-
writeReport
public abstract void writeReport(OutputStream os) throws IOException
Outputs the formatted information- Parameters:
os
- The OutputStream to which the information is sent to- Throws:
IOException
-
setMessage
public abstract void setMessage(InputStream in)
-
getMessage
public abstract String getMessage()
-
getTopMessagePart
public abstract ActionReport.MessagePart getTopMessagePart()
-
addSubActionsReport
public abstract ActionReport addSubActionsReport()
-
setActionExitCode
public abstract void setActionExitCode(ActionReport.ExitCode exitCode)
Sets the exit code for the report. Note that subreports may have a different exitcode.- Parameters:
exitCode
-
-
getActionExitCode
public abstract ActionReport.ExitCode getActionExitCode()
-
getContentType
public abstract String getContentType()
-
setContentType
public abstract void setContentType(String s)
-
getSubActionsReport
public abstract List<? extends ActionReport> getSubActionsReport()
-
failure
public final void failure(Logger logger, String message, Throwable e)
Report a failure to the logger andActionReport
. This is more of a convenience to the caller.- Parameters:
logger
-message
-e
-
-
failure
public final void failure(Logger logger, String message)
Short forfailure(logger,message,null)
- Parameters:
logger
-message
-- See Also:
failure(Logger, String, Throwable)
-
hasSuccesses
public abstract boolean hasSuccesses()
return true if the action report or a subaction report has ExitCode.SUCCESS.- Returns:
-
hasWarnings
public abstract boolean hasWarnings()
return true if the action report or a subaction report has ExitCode.WARNING.- Returns:
-
hasFailures
public abstract boolean hasFailures()
return true if the action report or a subaction report has ExitCode.FAILURE.- Returns:
-
getExtraProperties
public final Properties getExtraProperties()
-
setExtraProperties
public void setExtraProperties(Properties properties)
-
getResultType
public <T> T getResultType(Class<T> resultType)
Gets a type that was set by the command implementation- Parameters:
resultType
- the type requested- Returns:
the actual instance that was set
-
setResultType
public <T> void setResultType(Class<T> resultType, T resultTypeInstance)
Stores the supplies type and its instance. This is a way for the command implementation to pass information between Supplemental command(s) and the main command. For example, the Supplemental command for DeployCommand requires information on pay load, generated directories etc. In this case, the DeployCommand will be expected to set this information in, for example DeployResult, and set it in the ActionReport. The Supplemental Command will then retrieve the DeployResult for its use.- Parameters:
resultType
- the typeresultTypeInstance
- the actual instance
-
findProperty
public String findProperty(String key)
Search in message parts properties then in extra properties and then in sub reports. Returns first occurrence of the key.- Parameters:
key
-- Returns:
-
-