Class CommandRunnable
- java.lang.Object
-
- com.sun.enterprise.v3.admin.cluster.CommandRunnable
-
- All Implemented Interfaces:
Runnable
public class CommandRunnable extends Object implements Runnable
This class wraps a CommandInvocation so that it can be run via a thread pool. On construction you pass it the CommandInvocation to execute as well as a response queue and the ActionReport that was set on the CommandInvocation. When the run() method is called the CommandInvocation is executed (which sets its results in the ActionReport) and then it adds itself to the response queue where it can be picked up and the ActionReport inspected for the results.- Author:
- dipol
-
-
Constructor Summary
Constructors Constructor Description CommandRunnable(CommandRunner.CommandInvocation commandInvocation, ActionReport report, BlockingQueue<CommandRunnable> responseQueue)
Construct a CommandRunnable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionReport
getActionReport()
Returns the ActionReport that was passed on the constructor.CommandRunner.CommandInvocation
getCommandInvocation()
Returns the CommandInvocation that was passed on the constructorString
getName()
Get the name that was previously set.void
run()
void
setName(String name)
Set a name on the runnable.String
toString()
-
-
-
Constructor Detail
-
CommandRunnable
public CommandRunnable(CommandRunner.CommandInvocation commandInvocation, ActionReport report, BlockingQueue<CommandRunnable> responseQueue)
Construct a CommandRunnable. This class wraps a CommandInvocation so that it can be executed via a thread pool.- Parameters:
commandInvocation
- A CommandInvocation containing the command you want to run.report
- The ActionReport you used with the CommandInvocationresponseQueue
- A blocking queue that this class will add itself to when its run method has completed. After dispatching this class to a thread pool the caller can block on the response queue where it will dequeue CommandRunnables and then use the getActionReport() method to retrieve the results.
-
-
Method Detail
-
setName
public void setName(String name)
Set a name on the runnable. The name is not interpreted to mean anything so the caller can use it for whatever it likes.- Parameters:
name
- The name
-
getName
public String getName()
Get the name that was previously set.- Returns:
- A name that was previously set or null if no name was set.
-
getCommandInvocation
public CommandRunner.CommandInvocation getCommandInvocation()
Returns the CommandInvocation that was passed on the constructor- Returns:
- The CommandInvocation that was passed on the constructor
-
getActionReport
public ActionReport getActionReport()
Returns the ActionReport that was passed on the constructor.- Returns:
- the ActionReport that was passed on the constructor.
-
-