com.sun.enterprise.admin.cli
Class ProgramOptions

java.lang.Object
  extended by com.sun.enterprise.admin.cli.ProgramOptions

public class ProgramOptions
extends Object

Representation of the options known to the asadmin program. These options control the overall behavior of asadmin, e.g., the server to contact, and aren't specific to any of the commands supported by asadmin.

In GlassFish v3, asadmin program options are normally specified before the asadmin command name, with command options after the command name (although intermixed program and command options are still supported for compatibility).


Nested Class Summary
static class ProgramOptions.PasswordLocation
           
 
Field Summary
static String AUTHTOKEN
           
static String AUXINPUT
           
private  String className
           
private  String classPath
           
static String ECHO
           
private  Environment env
           
static String HELP
           
static String HOST
           
static String INTERACTIVE
           
private  ProgramOptions.PasswordLocation location
           
private static Logger logger
           
private  ParameterMap options
           
private  boolean optionsSet
           
private  String password
           
static String PASSWORDFILE
           
static String PORT
           
private static Set<CommandModel.ParamModel> programOptions
           
static String SECURE
           
private static LocalStringsImpl strings
           
static String TERSE
           
static String USER
           
 
Constructor Summary
ProgramOptions(Environment env)
          Initialize program options based only on environment defaults, with no options from the command line.
ProgramOptions(ParameterMap options, Environment env)
          Initialize the programoptions based on parameters parsed from the command line, with defaults supplied by the environment.
ProgramOptions(ProgramOptions other)
          Copy constructor.
 
Method Summary
private static void addMetaOption(Set<CommandModel.ParamModel> opts, String name, char sname, Class type, boolean req, String def)
          Helper method to define a meta-option.
 String getAuthToken()
           
 String getAuxInput()
           
 String getClassName()
           
 String getClassPath()
           
 String getHost()
           
 String getPassword()
           
 String getPasswordFile()
           
 ProgramOptions.PasswordLocation getPasswordLocation()
           
 int getPort()
           
 String[] getProgramArguments()
          Return an array of asadmin command line options that specify all the options of this ProgramOptions instance.
private  String getString(String optionName)
           
 String getUser()
           
static Collection<CommandModel.ParamModel> getValidOptions()
          Return a set of all the valid program options.
 boolean isEcho()
           
 boolean isHelp()
           
 boolean isInteractive()
           
 boolean isOptionsSet()
           
 boolean isSecure()
           
 boolean isTerse()
           
private static boolean ok(String s)
           
private  void putEnv(Environment env, String name)
           
 void setAuthToken(String token)
           
 void setAuxInput(String authInput)
           
 void setClassName(String className)
           
 void setClassPath(String classPath)
           
 void setEcho(boolean echo)
           
 void setHelp(boolean help)
           
 void setHost(String host)
           
 void setHostAndPort(HostAndPort address)
          Convenience method to set the host and port (and secure) attributes from a HostAndPort object.
 void setInteractive(boolean interactive)
           
 void setOptionsSet(boolean optionsSet)
          Set whether the program options have already been set.
 void setPassword(String password, ProgramOptions.PasswordLocation location)
           
 void setPasswordFile(String passwordFile)
           
 void setPort(int port)
           
 void setSecure(boolean secure)
           
 void setTerse(boolean terse)
           
 void setUser(String user)
           
 void toEnvironment(Environment env)
          Copy the program options that were specified on the command line into the corresponding environment variables.
 String toString()
          String representation of the asadmin program options.
 void updateOptions(ParameterMap newOptions)
          Update the program options based on the specified options from the command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

programOptions

private static final Set<CommandModel.ParamModel> programOptions

HOST

public static final String HOST
See Also:
Constant Field Values

PORT

public static final String PORT
See Also:
Constant Field Values

USER

public static final String USER
See Also:
Constant Field Values

PASSWORDFILE

public static final String PASSWORDFILE
See Also:
Constant Field Values

TERSE

public static final String TERSE
See Also:
Constant Field Values

ECHO

public static final String ECHO
See Also:
Constant Field Values

INTERACTIVE

public static final String INTERACTIVE
See Also:
Constant Field Values

SECURE

public static final String SECURE
See Also:
Constant Field Values

HELP

public static final String HELP
See Also:
Constant Field Values

AUTHTOKEN

public static final String AUTHTOKEN
See Also:
Constant Field Values

AUXINPUT

public static final String AUXINPUT
See Also:
Constant Field Values

logger

private static final Logger logger

strings

private static final LocalStringsImpl strings

options

private ParameterMap options

env

private Environment env

optionsSet

private boolean optionsSet

password

private String password

location

private ProgramOptions.PasswordLocation location

classPath

private String classPath

className

private String className
Constructor Detail

ProgramOptions

public ProgramOptions(Environment env)
               throws CommandException
Initialize program options based only on environment defaults, with no options from the command line.

Throws:
CommandException

ProgramOptions

public ProgramOptions(ParameterMap options,
                      Environment env)
               throws CommandException
Initialize the programoptions based on parameters parsed from the command line, with defaults supplied by the environment.

Throws:
CommandException

ProgramOptions

public ProgramOptions(ProgramOptions other)
Copy constructor. Create a new ProgramOptions with the same options as the specified ProgramOptions.

Method Detail

addMetaOption

private static void addMetaOption(Set<CommandModel.ParamModel> opts,
                                  String name,
                                  char sname,
                                  Class type,
                                  boolean req,
                                  String def)
Helper method to define a meta-option.

Parameters:
name - long option name
sname - short option name
type - option type (String.class, Boolean.class, etc.)
req - is option required?
def - default value for option

updateOptions

public void updateOptions(ParameterMap newOptions)
                   throws CommandException
Update the program options based on the specified options from the command line.

Throws:
CommandException

ok

private static boolean ok(String s)

getValidOptions

public static Collection<CommandModel.ParamModel> getValidOptions()
Return a set of all the valid program options.

Returns:
the valid program options

toEnvironment

public void toEnvironment(Environment env)
Copy the program options that were specified on the command line into the corresponding environment variables.


putEnv

private void putEnv(Environment env,
                    String name)

getHost

public String getHost()
Returns:
the host

setHost

public void setHost(String host)
Parameters:
host - the host to set

getPort

public int getPort()
Returns:
the port

setPort

public void setPort(int port)
Parameters:
port - the port to set

setHostAndPort

public void setHostAndPort(HostAndPort address)
Convenience method to set the host and port (and secure) attributes from a HostAndPort object.

Parameters:
address - the HostAndPort object from which to set the attributes

getUser

public String getUser()
Returns:
the user

setUser

public void setUser(String user)
Parameters:
user - the user to set

getPassword

public String getPassword()
Returns:
the password

getPasswordLocation

public ProgramOptions.PasswordLocation getPasswordLocation()
Returns:
the password location

setPassword

public void setPassword(String password,
                        ProgramOptions.PasswordLocation location)
Parameters:
password - the password to set

getPasswordFile

public String getPasswordFile()
Returns:
the passwordFile

setPasswordFile

public void setPasswordFile(String passwordFile)
Parameters:
passwordFile - the passwordFile to set

isSecure

public boolean isSecure()
Returns:
the secure

setSecure

public void setSecure(boolean secure)
Parameters:
secure - the secure to set

setAuthToken

public void setAuthToken(String token)

getAuthToken

public String getAuthToken()

setAuxInput

public void setAuxInput(String authInput)

getAuxInput

public String getAuxInput()

getString

private String getString(String optionName)

isTerse

public boolean isTerse()
Returns:
the terse

setTerse

public void setTerse(boolean terse)
Parameters:
terse - the terse to set

isEcho

public boolean isEcho()
Returns:
the echo

setEcho

public void setEcho(boolean echo)
Parameters:
echo - the echo to set

isInteractive

public boolean isInteractive()
Returns:
the interactive

setInteractive

public void setInteractive(boolean interactive)
Parameters:
interactive - the interactive to set

isHelp

public boolean isHelp()
Returns:
the help

setHelp

public void setHelp(boolean help)
Parameters:
help - the help to set

isOptionsSet

public boolean isOptionsSet()
Returns:
were options set on the command line?

setOptionsSet

public void setOptionsSet(boolean optionsSet)
Set whether the program options have already been set.


getProgramArguments

public String[] getProgramArguments()
Return an array of asadmin command line options that specify all the options of this ProgramOptions instance.


getClassPath

public String getClassPath()
Returns:
the classPath

setClassPath

public void setClassPath(String classPath)
Parameters:
classPath - the classPath to set

getClassName

public String getClassName()
Returns:
the className

setClassName

public void setClassName(String className)
Parameters:
className - the className to set

toString

public String toString()
String representation of the asadmin program options. Included in the --echo output.

Overrides:
toString in class Object


Copyright © 2012 GlassFish Community. All Rights Reserved.