|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.enterprise.admin.remote.RemoteAdminCommand
public class RemoteAdminCommand
Utility class for executing remote admin commands. Each instance of RemoteAdminCommand represents a particular remote command on a particular remote server accessed using particular credentials. The instance can be reused to execute the same command multiple times with different arguments.
Arguments to the command are supplied using a ParameterMap passed to the executeCommand method. ParameterMap is a MultiMap where each key can have multiple values, although this class only supports a single value for each option. Operands for the command are stored as the option named "DEFAULT" and can have multiple values.
Before a command can be executed, the metadata for the command (in the form of a CommandModel) is required. The getCommandModel method will fetch the metadata from the server, save it, and return it. If the CommandModel for a command is known independently (e.g., stored in a local cache, or known a priori), it can be set using the setCommandModel method. If the metadata isn't known when the exectureCommand method is called, it will fetch the metadata from the server before executing the command.
Any files returned by the command will be stored in the current directory. The setFileOutputDirectory method can be used to control where returned files are saved.
| Field Summary | |
|---|---|
protected java.lang.String |
authToken
|
protected java.lang.String |
host
|
protected java.util.logging.Logger |
logger
|
protected java.lang.String |
name
|
protected java.util.List<java.lang.String> |
operands
|
protected ParameterMap |
options
|
protected java.lang.String |
output
|
protected java.lang.String |
password
|
protected int |
port
|
protected boolean |
prohibitDirectoryUploads
|
protected boolean |
secure
|
protected java.lang.String |
user
|
| Constructor Summary | |
|---|---|
RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port)
Helper ctor |
|
RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port,
boolean secure,
java.lang.String user,
java.lang.String password,
java.util.logging.Logger logger)
|
|
RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port,
boolean secure,
java.lang.String user,
java.lang.String password,
java.util.logging.Logger logger,
java.lang.String authToken,
boolean prohibitDirectoryUploads)
Construct a new remote command object. |
|
| Method Summary | |
|---|---|
protected void |
addAdditionalHeaders(java.net.URLConnection urlConnection)
Adds any headers needed for the current environment to the admin request. |
protected AuthenticationInfo |
authenticationInfo()
|
java.lang.String |
executeCommand(ParameterMap opts)
Run the command using the specified arguments. |
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
After a successful command execution, the attributes returned by the command are saved. |
CommandModel |
getCommandModel()
Get the CommandModel for the command from the server. |
protected java.lang.String |
getFromEnvironment(java.lang.String name)
Subclasses can override to supply parameter values from environment. |
protected HttpConnectorAddress |
getHttpConnectorAddress(java.lang.String host,
int port,
boolean shouldUseSecure)
Provides an HttpConnectorAddress for use in connecting to the desired admin listener. |
static int |
getReadTimeout()
|
java.lang.String |
getUsage()
Get the usage text. |
java.util.List<Header> |
headers()
Return a modifiable list of headers to be added to the request. |
protected java.lang.String |
reportAuthenticationException()
Return the error message to be used in the AuthenticationException. |
protected boolean |
retryUsingSecureConnection(java.lang.String host,
int port)
Called when a non-secure connection attempt fails and it appears that the server requires a secure connection. |
void |
setCommandModel(CommandModel commandModel)
Set the CommandModel used by this command. |
void |
setConnectTimeout(int connectTimeout)
Set the connect timeout for the URLConnection. |
void |
setFileOutputDirectory(java.io.File dir)
Set the directory in which any returned files will be stored. |
void |
setInteractive(boolean state)
Set the interactive mode for the command. |
void |
setReadTimeout(int readTimeout)
Set the read timeout for the URLConnection. |
void |
setResponseFormatType(java.lang.String responseFormatType)
Set the response type used in requests to the server. |
void |
setUserOut(java.io.OutputStream userOut)
If set, the raw response from the command is written to the specified stream. |
protected boolean |
updateAuthentication()
Return true if we're successful in collecting new information (and thus the caller should try the request again). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String output
protected java.lang.String name
protected java.lang.String host
protected int port
protected boolean secure
protected java.lang.String user
protected java.lang.String password
protected java.util.logging.Logger logger
protected java.lang.String authToken
protected boolean prohibitDirectoryUploads
protected ParameterMap options
protected java.util.List<java.lang.String> operands
| Constructor Detail |
|---|
public RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port)
throws CommandException
CommandException
public RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port,
boolean secure,
java.lang.String user,
java.lang.String password,
java.util.logging.Logger logger)
throws CommandException
CommandException
public RemoteAdminCommand(java.lang.String name,
java.lang.String host,
int port,
boolean secure,
java.lang.String user,
java.lang.String password,
java.util.logging.Logger logger,
java.lang.String authToken,
boolean prohibitDirectoryUploads)
throws CommandException
CommandException| Method Detail |
|---|
public void setResponseFormatType(java.lang.String responseFormatType)
public void setUserOut(java.io.OutputStream userOut)
public void setCommandModel(CommandModel commandModel)
public void setReadTimeout(int readTimeout)
public static int getReadTimeout()
public void setConnectTimeout(int connectTimeout)
public void setInteractive(boolean state)
public CommandModel getCommandModel()
throws CommandException
CommandException - if the server can't be contactedpublic void setFileOutputDirectory(java.io.File dir)
public java.util.List<Header> headers()
public java.lang.String executeCommand(ParameterMap opts)
throws CommandException
CommandExceptionpublic java.util.Map<java.lang.String,java.lang.String> getAttributes()
protected boolean updateAuthentication()
protected java.lang.String getFromEnvironment(java.lang.String name)
protected boolean retryUsingSecureConnection(java.lang.String host,
int port)
protected java.lang.String reportAuthenticationException()
protected HttpConnectorAddress getHttpConnectorAddress(java.lang.String host,
int port,
boolean shouldUseSecure)
This implementation works for true admin clients and will not work correctly for commands submitted to instances from inside the DAS. (That is done from the implementation in ServerRemoteAdminCommand which extends this class.)
This code constructs the HttpConnectorAddress in a way that uses either no SSLSocketFactory (if security is off) or uses an SSLSocketFactory linked to the asadmin truststore.
host - the host name to which the connection should be madeport - the admin port on that hostshouldUseSecure - whether SSL should be used to connect or not
protected void addAdditionalHeaders(java.net.URLConnection urlConnection)
urlConnection - protected AuthenticationInfo authenticationInfo()
public java.lang.String getUsage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||