public class CmdlineClient extends Object
Note that using this type of client limits the types of data that can be sent to the server; specifically
parameters to the command. Since arguments are parsed from the command line, only data that can be represented as a
String can be passed to the server as command parameters.
| Constructor and Description |
|---|
CmdlineClient() |
| Modifier and Type | Method and Description |
|---|---|
Command |
buildCommand(String[] args)
Simply builds and returns a command defined by the given cmdline arguments.
|
CommandClient |
buildCommandClient(String[] args)
Simply builds and returns a command client defined by the given cmdline arguments.
|
String |
getUsage()
Returns the help usage string.
|
CommandResponse |
issueCommand(CommandType commandType,
String locatorURI)
Convienence method that invokes a given command type on the remote server found at the given URI.
|
CommandResponse |
issueCommand(CommandType commandType,
String locatorURI,
Map<String,String> params)
Convienence method that invokes a given command type (with the given set of parameter values) on the remote
server found at the given URI.
|
CommandResponse |
issueCommand(String[] args)
Issues a command defined by the given cmdline arguments.
|
static void |
main(String[] args)
Main entry point to the command line client.
|
public static void main(String[] args)
args - specifies the command to invoke and its parameterspublic CommandClient buildCommandClient(String[] args) throws IllegalArgumentException, ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException
Given the command type information and the optional package locations where command clients can be found, this
will attempt to instantiate the specific client for the specific command. If the client cannot be found, an
attempt will be made to issue the command using the generic client.
args - cmdline argumentsIllegalArgumentException - if a failure occurred while processing the cmdline argumentsClassNotFoundException - if failed to find a valid command client classIllegalAccessException - if failed to instantiate the command's client classInstantiationException - if failed to instantiate the command's client classMalformedURLException - if the given URL is invalid and cannot be used to locate an invokerpublic Command buildCommand(String[] args) throws IllegalArgumentException, ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException
Given the command type information and the optional package locations where command clients can be found, this
will attempt to instantiate the specific client for the specific command. If the client cannot be found, an
attempt will be made to issue the command using the generic client.
args - cmdline argumentsIllegalArgumentException - if a failure occurred while processing the cmdline argumentsClassNotFoundException - if failed to find a valid command client classIllegalAccessException - if failed to instantiate the command's client classInstantiationException - if failed to instantiate the command's client classMalformedURLException - if the given URL is invalid and cannot be used to locate an invokerpublic CommandResponse issueCommand(String[] args) throws IllegalArgumentException, ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException, Throwable
Given the command type information and the optional package locations where command clients can be found, this
will attempt to instantiate the specific client for the specific command. If the client cannot be found, an
attempt will be made to issue the command using the generic client.
args - cmdline argumentsIllegalArgumentException - if a failure occurred while processing the cmdline argumentsClassNotFoundException - if failed to find a valid command client classIllegalAccessException - if failed to instantiate the command's client classInstantiationException - if failed to instantiate the command's client classMalformedURLException - if the given URL is invalid and cannot be used to locate an invokerThrowable - any other error that was due to a failure during the invocation of the commandpublic CommandResponse issueCommand(CommandType commandType, String locatorURI, Map<String,String> params) throws IllegalArgumentException, MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, Throwable
Note that this method may or may not be the most appropriate to use. Use this method if you do not know ahead
of time the type of command you are going to issue. If you already know the type of command you are going to
issue, it is best to use the command's more strongly typed client subclass method that implements
CommandClient.invoke(Command).
commandType - the type of command to issuelocatorURI - location of the remote serverparams - set of name/value parameters sent along with the command (may be null)IllegalArgumentException - if a failure occurred while processing the cmdline argumentsClassNotFoundException - if failed to find the command's client classIllegalAccessException - if failed to instantiate the command's client classInstantiationException - if failed to instantiate the command's client classMalformedURLException - if the given URL is invalid and cannot be used to locate an invokerThrowable - any other error that was due to a failure during the invocation of the commandpublic CommandResponse issueCommand(CommandType commandType, String locatorURI) throws IllegalArgumentException, MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, Throwable
commandType - the type of command to issuelocatorURI - location of the remote serverIllegalArgumentException - if a failure occurred while processing the cmdline argumentsClassNotFoundException - if failed to find the command's client classIllegalAccessException - if failed to instantiate the command's client classInstantiationException - if failed to instantiate the command's client classMalformedURLException - if the given URL is invalid and cannot be used to locate an invokerThrowable - any other error that was due to a failure during the invocation of the commandpublic String getUsage()
Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.