Package com.sun.enterprise.v3.admin
Class CommandRunnerImpl
- java.lang.Object
-
- com.sun.enterprise.v3.admin.CommandRunnerImpl
-
- All Implemented Interfaces:
CommandRunner
@Service public class CommandRunnerImpl extends Object implements CommandRunner
Encapsulates the logic needed to execute a server-side command (for example, a descendant of AdminCommand) including injection of argument values into the command.- Author:
- dochez, tjquinn, Bill Shannon
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.api.admin.CommandRunner
CommandRunner.CommandInvocation
-
-
Constructor Summary
Constructors Constructor Description CommandRunnerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeFromCheckpoint(JobManager.Checkpoint checkpoint, boolean revert, AdminCommandEventBroker eventBroker)
ActionReport
getActionReport(String name)
Returns an initialized ActionReport instance for the passed type or null if it cannot be found.AdminCommand
getCommand(String scope, String commandName, ActionReport report, Logger logger)
Obtain and return the command implementation defined by the passed commandName.AdminCommand
getCommand(String commandName, ActionReport report, Logger logger)
Obtain and return the command implementation defined by the passed commandName for the null scope.CommandRunner.CommandInvocation
getCommandInvocation(String scope, String name, ActionReport report, Subject subject)
Obtain a new command invocation object.CommandRunner.CommandInvocation
getCommandInvocation(String scope, String name, ActionReport report, Subject subject, boolean isNotify)
Obtain a new command invocation object.CommandRunner.CommandInvocation
getCommandInvocation(String name, ActionReport report, Subject subject)
Obtain a new command invocation object for the null scope.CommandRunner.CommandInvocation
getCommandInvocation(String name, ActionReport report, Subject subject, boolean isNotify)
Obtain a new command invocation object for the null scope.void
getHelp(AdminCommand command, ActionReport report)
BufferedReader
getHelp(CommandModel model)
Returns manpage for the command.static BufferedReader
getManPage(String commandName, CommandModel model)
Return an InputStream for the man page for the named command.CommandModel
getModel(String scope, String commandName, Logger logger)
Returns the command model for a command name.CommandModel
getModel(String commandName, Logger logger)
Returns the command model for a command name.static boolean
injectParameters(CommandModel model, Object injectionTarget, InjectionResolver<Param> injector, ActionReport report)
boolean
validateCommandModelETag(AdminCommand command, String eTag)
Checks if given command model eTag is equal to current command model eTagboolean
validateCommandModelETag(CommandModel model, String eTag)
Checks if given command model eTag is equal to current command model eTag
-
-
-
Method Detail
-
getActionReport
public ActionReport getActionReport(String name)
Returns an initialized ActionReport instance for the passed type or null if it cannot be found.- Specified by:
getActionReport
in interfaceCommandRunner
- Parameters:
name
- action report type name- Returns:
- uninitialized action report or null
-
getModel
public CommandModel getModel(String commandName, Logger logger)
Returns the command model for a command name.- Specified by:
getModel
in interfaceCommandRunner
- Parameters:
commandName
- command namelogger
- logger to log any error messages- Returns:
- model for this command (list of parameters,etc...), or null if command is not found
-
getModel
public CommandModel getModel(String scope, String commandName, Logger logger)
Returns the command model for a command name.- Specified by:
getModel
in interfaceCommandRunner
- Parameters:
commandName
- command namelogger
- logger to log any error messagesscope
- the scope (or namespace) for the command- Returns:
- model for this command (list of parameters,etc...), or null if command is not found
-
validateCommandModelETag
public boolean validateCommandModelETag(AdminCommand command, String eTag)
Description copied from interface:CommandRunner
Checks if given command model eTag is equal to current command model eTag- Specified by:
validateCommandModelETag
in interfaceCommandRunner
- Parameters:
command
- Command to be checkedeTag
- ETag to validate
-
validateCommandModelETag
public boolean validateCommandModelETag(CommandModel model, String eTag)
Description copied from interface:CommandRunner
Checks if given command model eTag is equal to current command model eTag- Specified by:
validateCommandModelETag
in interfaceCommandRunner
- Parameters:
model
- of command to be checkedeTag
- ETag to validate
-
getCommand
public AdminCommand getCommand(String commandName, ActionReport report, Logger logger)
Obtain and return the command implementation defined by the passed commandName for the null scope.- Specified by:
getCommand
in interfaceCommandRunner
- Parameters:
commandName
- command name as typed by usersreport
- report used to communicate command status back to the userlogger
- logger to log- Returns:
- command registered under commandName or null if not found
-
getCommand
public AdminCommand getCommand(String scope, String commandName, ActionReport report, Logger logger)
Obtain and return the command implementation defined by the passed commandName.- Specified by:
getCommand
in interfaceCommandRunner
- Parameters:
commandName
- command name as typed by usersreport
- report used to communicate command status back to the userlogger
- logger to logscope
- the scope (or namespace) for the command- Returns:
- command registered under commandName or null if not found
-
getCommandInvocation
public CommandRunner.CommandInvocation getCommandInvocation(String name, ActionReport report, Subject subject)
Description copied from interface:CommandRunner
Obtain a new command invocation object for the null scope. Command invocations can be configured and used to trigger a command execution.- Specified by:
getCommandInvocation
in interfaceCommandRunner
- Parameters:
name
- name of the requested command to invokereport
- where to place the status of the command executionsubject
- the Subject under which to execute the command- Returns:
- a new command invocation for that command name.
-
getCommandInvocation
public CommandRunner.CommandInvocation getCommandInvocation(String scope, String name, ActionReport report, Subject subject)
Description copied from interface:CommandRunner
Obtain a new command invocation object. Command invocations can be configured and used to trigger a command execution.- Specified by:
getCommandInvocation
in interfaceCommandRunner
- Parameters:
scope
- the scope (or namespace) for the commandname
- name of the requested command to invokereport
- where to place the status of the command executionsubject
- the Subject under which to execute the command- Returns:
- a new command invocation for that command name.
-
getCommandInvocation
public CommandRunner.CommandInvocation getCommandInvocation(String name, ActionReport report, Subject subject, boolean isNotify)
Obtain a new command invocation object for the null scope. Command invocations can be configured and used to trigger a command execution.- Specified by:
getCommandInvocation
in interfaceCommandRunner
- Parameters:
name
- name of the requested command to invokereport
- where to place the status of the command executionsubject
- the Subject under which to execute the commandisNotify
- should notification be enabled- Returns:
- a new command invocation for that command name
-
getCommandInvocation
public CommandRunner.CommandInvocation getCommandInvocation(String scope, String name, ActionReport report, Subject subject, boolean isNotify)
Obtain a new command invocation object. Command invocations can be configured and used to trigger a command execution.- Specified by:
getCommandInvocation
in interfaceCommandRunner
- Parameters:
scope
- the scope (or name space) for the commandname
- name of the requested command to invokereport
- where to place the status of the command executionsubject
- the Subject under which to execute the commandisNotify
- Should notification be enabled- Returns:
- a new command invocation for that command name
-
injectParameters
public static boolean injectParameters(CommandModel model, Object injectionTarget, InjectionResolver<Param> injector, ActionReport report)
-
getHelp
public BufferedReader getHelp(CommandModel model) throws com.sun.enterprise.v3.admin.CommandNotFoundException
Description copied from interface:CommandRunner
Returns manpage for the command.- Specified by:
getHelp
in interfaceCommandRunner
- Parameters:
model
- of command- Returns:
- Formated manpage
- Throws:
com.sun.enterprise.v3.admin.CommandNotFoundException
-
getHelp
public void getHelp(AdminCommand command, ActionReport report)
-
getManPage
public static BufferedReader getManPage(String commandName, CommandModel model)
Return an InputStream for the man page for the named command.
-
executeFromCheckpoint
public void executeFromCheckpoint(JobManager.Checkpoint checkpoint, boolean revert, AdminCommandEventBroker eventBroker)
-
-