Class LocalInstanceCommand
- java.lang.Object
-
- com.sun.enterprise.admin.cli.CLICommand
-
- com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
-
- com.sun.enterprise.admin.cli.cluster.LocalInstanceCommand
-
- All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct
- Direct Known Subclasses:
ChangeNodeMasterPasswordCommand
,CreateLocalInstanceFilesystemCommand
,DeleteInstanceFilesystem
,DeleteLocalInstanceCommand
,ImportSyncBundleCommand
,StopLocalInstanceCommand
,SynchronizeInstanceCommand
,ValidateDasOptions
public abstract class LocalInstanceCommand extends LocalServerCommand
A base class for local commands that manage a local server instance. This base class is used by a LOT of other classes. There is a big comment before each section of the file -- sorted by visibility. If you specifically want a method to be overridden -- make it protected but not final. final protected means -- "call me but don't override me". This convention is to make things less confusing. If you add a method or change whether it is final -- move it to the right section. Default instance file structure.||---- <GlassFish Install Root> ||---- nodes (nodeDirRoot, --nodedir) ||---- <node-1> (nodeDirChild, --node) || ---- agent || ---- config | ---- das.properties || ---- <instance-1> (instanceDir) ||---- config ||---- applications ||---- java-web-start ||---- generated ||---- lib ||---- docroot || ---- <instance-2> (instanceDir) ||---- <node-2> (nodeDirChild)
- Author:
- Byron Nevins
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
checkOneAndOnly
protected String
domainName
protected File
instanceDir
protected String
instanceName
protected boolean
isCreateInstanceFilesystem
protected String
node
protected String
nodeDir
protected File
nodeDirChild
protected File
nodeDirRoot
-
Fields inherited from class com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
DEFAULT_MASTER_PASSWORD
-
Fields inherited from class com.sun.enterprise.admin.cli.CLICommand
argv, ASADMIN, commandModel, CONNECTION_ERROR, env, ERROR, INVALID_COMMAND_ERROR, lineReader, logger, metadataErrors, name, operands, options, passwords, programOpts, SUCCESS, terminal, WARNING
-
-
Constructor Summary
Constructors Constructor Description LocalInstanceCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Properties
getDasProperties(File propfile)
protected InstanceDirs
getInstanceDirs()
String
getInstanceName()
protected File
getMasterPasswordFile()
protected String
getNodeInstallDir()
protected Properties
getNodeProperties(File propertyFile)
protected String
getProductRootPath()
Gets the GlassFish product installation root (using property com.sun.aas.productRoot), first from asenv.conf.protected void
initInstance()
protected boolean
isDirectory(File f)
Override this method if your class does NOT want CommandException thrown if directory does not exist.protected boolean
mkdirs(File f)
Override this method if your class does NOT want to create directoriesprotected void
setDasDefaults(File propfile)
Set the programOpts based on the das.properties file.void
setInstanceName(String instanceName)
protected boolean
setServerDirs()
Override this method if your class does NOT want to set ServerDirsprotected void
validate()
The validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.protected void
validateDasOptions(String hostOption, String portOption, String isSecureOption, File propfile)
Checks if programOpts values match das.properties file.protected void
whackFilesystem()
-
Methods inherited from class com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
checkAdditionalTrustAndKeyStores, checkForSpecialFiles, dataGridEncryptionEnabled, getAdminAddress, getAdminAddress, getDomainXml, getInstallRootPath, getMasterPassword, getPrevPid, getServerDirs, getServerPid, getUptime, isLocal, isRemote, isRestartable, isRunning, isRunning, isThisServer, loadAndVerifyKeystore, readFromMasterPasswordFile, resetServerDirs, setLocalPassword, setServerDirs, unsetLocalPassword, verifyMasterPassword, waitForRestart, waitForRestart
-
Methods inherited from class com.sun.enterprise.admin.cli.CLICommand
buildLineReader, buildTerminal, checkHelp, closeTerminal, execute, execute, executeCommand, expandManPage, getBooleanOption, getBriefCommandUsage, getCommand, getCommand, getCommandScope, getCommandUsage, getManPage, getName, getOperandModel, getOption, getOptions, getPassword, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, getUsage, initializeLogger, initializePasswords, inject, newLineReaderBuilder, ok, parse, postConstruct, prepare, prevalidate, printExceptionStackTrace, processProgramOptions, quote, readPassword, setCommandScope, toString, usageOptions
-
-
-
-
Field Detail
-
nodeDir
protected String nodeDir
-
node
protected String node
-
instanceName
protected String instanceName
-
nodeDirRoot
protected File nodeDirRoot
-
nodeDirChild
protected File nodeDirChild
-
instanceDir
protected File instanceDir
-
domainName
protected String domainName
-
isCreateInstanceFilesystem
protected boolean isCreateInstanceFilesystem
-
checkOneAndOnly
protected boolean checkOneAndOnly
-
-
Method Detail
-
validate
protected void validate() throws CommandException, CommandValidationException
Description copied from class:CLICommand
The validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.- Overrides:
validate
in classCLICommand
- Throws:
CommandException
- if execution of the command failsCommandValidationException
- if there's something wrong with the options or arguments
-
mkdirs
protected boolean mkdirs(File f)
Override this method if your class does NOT want to create directories- Parameters:
f
- the directory to create- Returns:
- true iff the directory was created
-
isDirectory
protected boolean isDirectory(File f)
Override this method if your class does NOT want CommandException thrown if directory does not exist.- Parameters:
f
- directory to check
-
setServerDirs
protected boolean setServerDirs()
Override this method if your class does NOT want to set ServerDirs
-
initInstance
protected void initInstance() throws CommandException
- Throws:
CommandException
-
getInstanceDirs
protected final InstanceDirs getInstanceDirs()
-
setDasDefaults
protected final void setDasDefaults(File propfile) throws CommandException
Set the programOpts based on the das.properties file.- Throws:
CommandException
-
validateDasOptions
protected final void validateDasOptions(String hostOption, String portOption, String isSecureOption, File propfile) throws CommandException
Checks if programOpts values match das.properties file.- Throws:
CommandException
-
getDasProperties
protected final Properties getDasProperties(File propfile) throws CommandException
- Throws:
CommandException
-
getNodeProperties
protected final Properties getNodeProperties(File propertyFile) throws CommandException
- Throws:
CommandException
-
whackFilesystem
protected final void whackFilesystem() throws CommandException
- Throws:
CommandException
-
getProductRootPath
protected String getProductRootPath() throws CommandException
Gets the GlassFish product installation root (using property com.sun.aas.productRoot), first from asenv.conf. If that's not available, then from java.lang.System. This will typically be the parent of the glassfish install root- Returns:
- path of GlassFish product install root
- Throws:
CommandException
- if the GlassFish install root is not found
-
getNodeInstallDir
protected String getNodeInstallDir() throws CommandException
- Throws:
CommandException
-
getMasterPasswordFile
protected File getMasterPasswordFile()
- Overrides:
getMasterPasswordFile
in classLocalServerCommand
-
getInstanceName
public String getInstanceName()
- Returns:
- the instanceName
-
setInstanceName
public void setInstanceName(String instanceName)
- Parameters:
instanceName
- the instanceName to set
-
-