public class RunnerHttp extends Runner
Modifier and Type | Field and Description |
---|---|
(package private) static char |
LIBRARY_SEPARATOR
Character used to separate individual items in libraries query
parameter.
|
(package private) Manifest |
manifest
Manifest from server response.
|
(package private) ResultString |
result
GlassFish administration command result.
|
auth, command, FALSE_VALUE, HTTP_CONNECTION_TIMEOUT, HTTP_RETRY_DELAY, ITEM_SEPARATOR, PARAM_ASSIGN_VALUE, PARAM_SEPARATOR, path, query, QUERY_SEPARATOR, retry, server, silentFailureAllowed, stateListeners, TRUE_VALUE
Modifier | Constructor and Description |
---|---|
|
RunnerHttp(GlassFishServer server,
Command command)
Constructs an instance of administration command executor using
HTTP interface.
|
(package private) |
RunnerHttp(GlassFishServer server,
Command command,
String query)
Constructs an instance of administration command executor using
HTTP interface.
|
protected |
RunnerHttp(GlassFishServer server,
Command command,
String path,
String query)
Constructs an instance of administration command executor using
HTTP interface.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsGzip()
Inform whether this runner implementation accepts gzip format.
|
protected String |
constructCommandUrl()
Build GlassFish HTTP command URL.
|
protected Result |
createResult()
Create
ResultString object corresponding
to String command execution value to be returned. |
boolean |
getDoOutput()
Do not send information to the server via HTTP POST by default.
|
(package private) byte[] |
getExtraProperties()
Get extra properties for ZIP entries.
|
private static String |
getHttpListenerProtocol(String hostname,
int port,
String url) |
String |
getLastModified()
Override to provide the lastModified date for data source whose
inputstream is returned by getInputStream.
|
private String |
getMessage(Manifest manifest)
Retrieve message from
Manifest object. |
protected String |
getRequestMethod()
Override to change the type of HTTP method used for this command.
|
protected void |
handleSend(HttpURLConnection hconn)
Handle sending data to server using HTTP command interface.
|
protected void |
prepareHttpConnection(HttpURLConnection conn)
Prepare headers for HTTP connection.
|
protected boolean |
processResponse()
Extracts result value from internal
Manifest object. |
(package private) static StringBuilder |
queryLibrariesAppend(StringBuilder sb,
File[] libraries,
String paramName,
boolean separator)
Append libraries to existing query string stored in given
StringBuilder . |
(package private) static int |
queryLibrariesLength(File[] libraries,
String paramName)
Calculate libraries length based on libraries array.
|
(package private) static StringBuilder |
queryPropertiesAppend(StringBuilder sb,
Map<String,String> properties,
String paramName,
boolean separator)
Append properties to existing query string stored in given
StringBuilder . |
(package private) static int |
queryPropertiesLength(Map<String,String> properties,
String paramName)
Calculate properties length based on properties map.
|
protected boolean |
readResponse(InputStream in,
HttpURLConnection hconn)
Reads response from server and stores it into internal
Manifest object. |
private static boolean |
successExitCode(Manifest manifest)
Check
Manifest exit-code attribute for result. |
call, execute, execute, getCommand, getCommandWithQuery, getContentType, getQuery, getResult, handleReceive, handleSecureConnection, handleStateChange, isSilentFailureAllowed, parallelExecutor, serializedExecutor, setReadyState, setSilentFailureAllowed, setStateListeners, stateChangeArgs, stateChangeArgs, toBoolean, toString
static final char LIBRARY_SEPARATOR
Manifest manifest
Manifest
instance is internal server response holder.
Manifest
instance life cycle is started
in readResponse
method where manifest returned from server
is read and stored internally.ResultString result
ExecutorService
's queue. method call()
is responsible for correct TaskState
and receiveResult value
handling.public RunnerHttp(GlassFishServer server, Command command)
server
- GlassFish server entity object.command
- GlassFish server administration command entity.RunnerHttp(GlassFishServer server, Command command, String query)
server
- GlassFish server entity object.command
- GlassFish server administration command entity.query
- Query string for this command.protected RunnerHttp(GlassFishServer server, Command command, String path, String query)
server
- GlassFish server entity object.command
- GlassFish server administration command entity.ide
- IDE Context object.path
- Server command path.query
- Query string for this command.static int queryPropertiesLength(Map<String,String> properties, String paramName)
properties
- Properties to be added into query string.paramName
- Properties parameter name in query string.static int queryLibrariesLength(File[] libraries, String paramName)
libraries
- Libraries to be added into query string.paramName
- Libraries parameter name in query string.static StringBuilder queryPropertiesAppend(StringBuilder sb, Map<String,String> properties, String paramName, boolean separator)
StringBuilder
.
sb
- Target StringBuilder
where to append
properties.properties
- Properties to be added into query string.paramName
- Properties parameter name in query string.separator
- Prepend parameter separator if true
StringBuilder
with properties appended.static StringBuilder queryLibrariesAppend(StringBuilder sb, File[] libraries, String paramName, boolean separator)
StringBuilder
.
sb
- Target StringBuilder
where to append
properties.libraries
- Libraries to be added into query string.paramName
- Libraries parameter name in query string.separator
- Prepend parameter separator if true
StringBuilder
with libraries appended.private static boolean successExitCode(Manifest manifest)
Manifest
exit-code attribute for result.
Missing value or any value differed to< code>"FAILED"
is considered as success.
Response processing helper method. Manifest must contain valid data.
manifest
- Manifest from server response.true
for success and false
for failure.private static String getHttpListenerProtocol(String hostname, int port, String url)
protected Result createResult()
ResultString
object corresponding
to String
command execution value to be returned.
createResult
in class Runner
String
command execution value to be returned.public boolean getDoOutput()
getDoOutput
in class Runner
true
if using HTTP POST to send to server
or false
otherwisepublic boolean acceptsGzip()
acceptsGzip
in class Runner
true
when gzip format is accepted,
false
otherwise.protected String constructCommandUrl() throws CommandException
constructCommandUrl
in class Runner
String
value containing command URL.CommandException
- if there is a problem with building
command URL.CommandException
protected String getRequestMethod()
getRequestMethod
in class Runner
protected void handleSend(HttpURLConnection hconn) throws IOException
handleSend
in class Runner
IOException
protected boolean readResponse(InputStream in, HttpURLConnection hconn)
Manifest
object. Value of exit-code attribute
is verified to detect if command completed successfully. If not,
message value is checked for "please wait" String
to eventually set retry
value to true
.
Override to read the response data sent by the server. Do not close
the stream parameter when finished. Caller will take care of that.
readResponse
in class Runner
in
- Stream to read data from.CommandException
- in case of stream error.protected boolean processResponse()
Manifest
object.
Value of message attribute in Manifest
object is
stored as value into ResultString
result object.
processResponse
in class Runner
null
messagevalue is considered as failure.public String getLastModified()
private String getMessage(Manifest manifest)
Manifest
object.
Response processing helper method. Manifest must contain valid data.
Manifest
instance is always created in
readResponse
method so no null
check is
required here.
manifest
- Manifest from server response.null
if
no such attribute exists.byte[] getExtraProperties()
protected void prepareHttpConnection(HttpURLConnection conn) throws CommandException
prepareHttpConnection
in class Runner
conn
- Target HTTP connection.CommandException
- if there is a problem with setting
the headers.CommandException
Copyright © 2013. All Rights Reserved.