public abstract class Runner extends Object implements Callable<Result>
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
auth
Authentication success or failure.
|
(package private) Command |
command
Holding data for command execution.
|
private static ExecutorService |
executor
Executor used to serialize administration commands passed to GlassFish
server.
|
(package private) static String |
FALSE_VALUE
String value for false . |
static int |
HTTP_CONNECTION_TIMEOUT
Socket connection timeout (in miliseconds).
|
static int |
HTTP_RETRY_DELAY
Delay before administration command execution will be retried.
|
(package private) static char |
ITEM_SEPARATOR
Character used to separate individual items in parameters.
|
private static Logger |
LOGGER
Logger instance for this class.
|
(package private) static char |
PARAM_ASSIGN_VALUE
Character used to assign value to parameter.
|
(package private) static char |
PARAM_SEPARATOR
Character used to separate individual parameters.
|
protected String |
path
Server command path (e.g.
|
(package private) String |
query
Query string for this command.
|
(package private) static char |
QUERY_SEPARATOR
Character used to separate query string from list of parameters.
|
(package private) Result |
result
GlassFish administration command execution result.
|
(package private) boolean |
retry
Sometimes (e.g.
|
protected GlassFishServer |
server
Holding GlassFish server for command execution.
|
protected boolean |
silentFailureAllowed
Allow commands to fail without a big message.
|
protected TaskStateListener[] |
stateListeners
Listeners that want to know about command state.
|
(package private) static String |
TRUE_VALUE
String value for true . |
Constructor and Description |
---|
Runner(GlassFishServer server,
Command command,
String path)
Constructs an instance of administration command executor using
HTTP interface.
|
Runner(GlassFishServer server,
Command command,
String path,
String query)
Constructs an instance of administration command executor using HTTP
interface.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
acceptsGzip()
Inform whether this runner implementation accepts gzip format.
|
Result |
call()
GlassFish server administration command execution call.
|
protected abstract String |
constructCommandUrl()
Template method to allow descendants to implement creation of command
url.
|
protected abstract Result |
createResult()
Create
Result object corresponding to command execution
value to be returned. |
(package private) Future<? extends Result> |
execute()
Execute an arbitrary server command.
|
(package private) Future<? extends Result> |
execute(ExecutorService executor)
Execute an arbitrary server command using provided executor.
|
(package private) Command |
getCommand()
Get GlassFish server administration command entity.
|
(package private) String |
getCommandWithQuery()
Construct string containing
Command string with
query parameters appended. |
String |
getContentType()
Override to set the content-type of information sent to the server.
|
abstract boolean |
getDoOutput()
Send information to the server via HTTP POST.
|
(package private) String |
getQuery()
Returns the query string for this command.
|
protected abstract String |
getRequestMethod()
Override to change the type of HTTP method used for this command.
|
Result |
getResult()
Get command execution result after task is finished.
|
protected boolean |
handleReceive(HttpURLConnection hconn) |
protected void |
handleSecureConnection(HttpsURLConnection conn) |
protected abstract void |
handleSend(HttpURLConnection hconn)
Override this method to handle sending data to server.
|
(package private) Result |
handleStateChange(TaskState newTaskState,
TaskEvent taskEvent,
String... args)
Update task state value in
Result object and notify
all registered command execution state listeners about command execution
state change. |
protected boolean |
isSilentFailureAllowed()
Do we allow commands to fail without a big message?
SDK Exception functional test.
|
(package private) static ExecutorService |
parallelExecutor(int size)
Returns individual
Executor instance to run administration
commands passed to GlassFish server in parallel. |
protected void |
prepareHttpConnection(HttpURLConnection conn)
Prepare headers for HTTP connection.
|
protected abstract boolean |
processResponse()
Override to parse, validate, and/or format any data read from the server
in readResponse() / readManifest().
|
protected abstract boolean |
readResponse(InputStream in,
HttpURLConnection hconn)
Override this method to read response from provided input stream.
|
(package private) static ExecutorService |
serializedExecutor()
Returns shared
Executor instance to serialize administration
commands passed to GlassFish server. |
void |
setReadyState()
Used with external execution code to prepare initial task state before
task is passed to executor.
|
void |
setSilentFailureAllowed(boolean silentFailureAllowed)
Set whether we allow commands to fail without a big message.
|
void |
setStateListeners(TaskStateListener[] listeners)
Set listeners to notify about task state changes.
|
(package private) String[] |
stateChangeArgs(String exMessage)
Build arguments for operationStateChanged method listening for state
changes.
|
(package private) String[] |
stateChangeArgs(String exMessage,
boolean display)
Build arguments for operationStateChanged method listening for state
changes.
|
(package private) static boolean |
toBoolean(String constant)
Convert
String constant representing boolean
value to it's original boolean value. |
(package private) static String |
toString(boolean value)
Convert
boolean value to String constant. |
private static final Logger LOGGER
public static final int HTTP_CONNECTION_TIMEOUT
public static final int HTTP_RETRY_DELAY
static final char QUERY_SEPARATOR
static final char PARAM_SEPARATOR
static final char ITEM_SEPARATOR
static final char PARAM_ASSIGN_VALUE
static final String TRUE_VALUE
String
value for true
.static final String FALSE_VALUE
String
value for false
.private static volatile ExecutorService executor
protected boolean silentFailureAllowed
protected String path
boolean retry
boolean auth
protected GlassFishServer server
final Command command
Result result
ExecutorService
's queue. method call()
is responsible for correct TaskState
and receiveResult value
handling.final String query
protected TaskStateListener[] stateListeners
Runner(GlassFishServer server, Command command, String path)
server
- GlassFish server entity object.command
- GlassFish Server HTTP Administration Command Entity.path
- Server command path.Runner(GlassFishServer server, Command command, String path, String query)
server
- GlassFish server entity object.command
- GlassFish Server HTTP Administration Command Entity.path
- Server command path.query
- Query string for this command.static ExecutorService serializedExecutor()
Executor
instance to serialize administration
commands passed to GlassFish server.
Executor
instance is handled internally.
Executor
instance.static ExecutorService parallelExecutor(int size)
Executor
instance to run administration
commands passed to GlassFish server in parallel.
size
- Thread pool size.Executor
instance.static String toString(boolean value)
boolean
value to String
constant.
value
- boolean
value to be converted.String
constant.static boolean toBoolean(String constant) throws CommandException
String
constant representing boolean
value to it's original boolean
value.
constant
- Constant representing boolean
value.boolean
value.CommandException
- when constant representing boolean
value is not recognized.protected abstract Result createResult()
Result
object corresponding to command execution
value to be returned.public abstract boolean getDoOutput()
true
if using HTTP POST to send to server
or false
otherwisepublic abstract boolean acceptsGzip()
true
when gzip format is accepted,
false
otherwise.protected abstract String constructCommandUrl() throws CommandException
CommandException
protected abstract String getRequestMethod()
protected abstract void handleSend(HttpURLConnection hconn) throws IOException
hconn
- IOException
protected abstract boolean readResponse(InputStream in, HttpURLConnection hconn)
in
- Stream to read data from.IOException
- in case of stream error.protected abstract boolean processResponse()
String getQuery()
Command getCommand()
public Result getResult()
protected boolean isSilentFailureAllowed()
public void setSilentFailureAllowed(boolean silentFailureAllowed)
silentFailureAllowed
- The silentFailureAllowed to set.public void setStateListeners(TaskStateListener[] listeners)
stateListener
- Listeners to notify about task state changes.public String getContentType()
String getCommandWithQuery()
Command
string with
query
parameters appended.
Command
string with query
parameters appended.String[] stateChangeArgs(String exMessage, boolean display)
String arguments passed to state listener:
args[0]
server name
args[1]
administration command
args[2]
exception message
args[3]
display message in GUI
exMessage
- Exception message.display
- Display this event in GUI (Transformed
to String
value containing
"true"
value when user should be notified
or "true"
or null
otherwise.String[] stateChangeArgs(String exMessage)
false
display argument to operationStateChanged method
to not display GUI message about this event.
exMessage
- Exception message.Result handleStateChange(TaskState newTaskState, TaskEvent taskEvent, String... args)
Result
object and notify
all registered command execution state listeners about command execution
state change. This method is not responsible for setting receiveResult
value returned by GlassFish.
This method is used after task is submitted into
ExecutorService
's queue and Result object is initialized.
newTaskState
- New task execution state.taskEvent
- Event related to execution state change.args
- Additional arguments.public void setReadyState()
Future<? extends Result> execute()
Future
object to retrieve receiveResult of
asynchronous execution.Future<? extends Result> execute(ExecutorService executor)
executor
- {@see ExecutorService) instance used to run this task.Future
object to retrieve receiveResult of
asynchronous execution.protected void prepareHttpConnection(HttpURLConnection conn) throws CommandException
conn
- Target HTTP connection.CommandException
- if there is a problem with setting
the headers.CommandException
protected void handleSecureConnection(HttpsURLConnection conn)
protected boolean handleReceive(HttpURLConnection hconn) throws IOException
IOException
Copyright © 2013. All Rights Reserved.