Class LocalServerCommand
java.lang.Object
com.sun.enterprise.admin.cli.CLICommand
com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
- All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct
- Direct Known Subclasses:
LocalDomainCommand
public abstract class LocalServerCommand
extends com.sun.enterprise.admin.cli.CLICommand
A class that's supposed to capture all the behavior common to operation on a "local" server. It's getting fairly
complicated thus the "section headers" comments. This class plays two roles,
- a place for putting common code - which are final methods. A parent class that is communicating with its own unknown sub-classes. These are non-final methods
- Author:
- Byron Nevins
-
Field Summary
Fields inherited from class com.sun.enterprise.admin.cli.CLICommand
argv, commandModel, CONNECTION_ERROR, env, ERROR, INVALID_COMMAND_ERROR, logger, metadataErrors, name, operands, options, passwords, programOpts, SUCCESS, WARNING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanOverride this method and return false to turn-off the file validation.protected final com.sun.enterprise.util.HostAndPortReturns the admin address.protected final com.sun.enterprise.util.HostAndPortgetAdminAddress(String serverName) Returns the admin address of a particular server parsed from the domain.xml.protected final Fileprotected final StringGet the master password, either from a password file or by asking the user.protected Fileprotected final com.sun.enterprise.util.io.ServerDirsprotected final intAsks remote server for the PIDprotected final longGet uptime from the server.protected final booleanisLocal()protected final booleanSee if the server is restartable As of March 2011 -- this only returns false if a passwordfile argument was given when the server started -- but it is no longer available - i.e. the user deleted it or made it unreadable.protected final booleanisThisServer(File ourDir, String directoryKey) See if the server is alive and is the one at the specified directory.protected booleanloadAndVerifyKeystore(File jks, String mpv) protected final StringChecks if the create-domain was created using --savemasterpassword flag which obtains security by obfuscation!protected final voidprotected final voidSets the local password loaded from serverDirs.protected final voidsetServerDirs(com.sun.enterprise.util.io.ServerDirs sd) protected final voidprotected final booleanprotected final voidwaitForRestart(int oldPid, com.sun.enterprise.util.HostAndPort oldAdminAddress, com.sun.enterprise.util.HostAndPort newAdminAddress) Waits until server stops and startsMethods inherited from class com.sun.enterprise.admin.cli.CLICommand
checkHelp, checkSanity, execute, executeCommand, expandManPage, getBooleanOption, getBriefCommandUsage, getCommand, getCommand, getCommandScope, getCommandUsage, getManPage, getName, getOperandModel, getOption, getOptions, getPassword, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, getUsage, initializeLogger, initializePasswords, inject, ok, parse, postConstruct, prepare, prevalidate, processProgramOptions, quote, readPassword, setCommandScope, toString, usageOptions, validate
-
Constructor Details
-
LocalServerCommand
public LocalServerCommand()
-
-
Method Details
-
checkForSpecialFiles
protected boolean checkForSpecialFiles()Override this method and return false to turn-off the file validation. E.g. it demands that config/domain.xml be present. In special cases like Synchronization -- this is how you turn off the testing.- Returns:
- true - do the checks, false - don't do the checks
-
getAdminAddress
protected final com.sun.enterprise.util.HostAndPort getAdminAddress() throws org.glassfish.api.admin.CommandExceptionReturns the admin address.The address atributes can be overriden from the command line by specifying --host, --port and --secure arguments. If some is missing, it is loaded from domain.xml or set to default.
For remote access it uses just command line arguments and defaults.
- Returns:
- HostAndPort object with admin server address.
- Throws:
org.glassfish.api.admin.CommandException- in case of parsing errors
-
getAdminAddress
protected final com.sun.enterprise.util.HostAndPort getAdminAddress(String serverName) throws org.glassfish.api.admin.CommandException Returns the admin address of a particular server parsed from the domain.xml. For remote access it uses command line arguments and defaults.- Returns:
- HostAndPort object with admin server address.
- Throws:
org.glassfish.api.admin.CommandException- in case of parsing errors
-
setServerDirs
protected final void setServerDirs(com.sun.enterprise.util.io.ServerDirs sd) -
isLocal
protected final boolean isLocal()- Returns:
- true if something called
setServerDirs(ServerDirs)to a non-null value and serverName is not null.
-
setLocalPassword
protected final void setLocalPassword()Sets the local password loaded from serverDirs. -
unsetLocalPassword
protected final void unsetLocalPassword() -
resetServerDirs
- Throws:
IOException
-
getServerDirs
protected final com.sun.enterprise.util.io.ServerDirs getServerDirs() -
getDomainXml
-
readFromMasterPasswordFile
Checks if the create-domain was created using --savemasterpassword flag which obtains security by obfuscation! Returns null in case of failure of any kind.- Returns:
- String representing the password from the JCEKS store named master-password in domain folder
-
verifyMasterPassword
-
loadAndVerifyKeystore
-
getMasterPassword
Get the master password, either from a password file or by asking the user.- Throws:
org.glassfish.api.admin.CommandException
-
isThisServer
See if the server is alive and is the one at the specified directory.- Returns:
- true if it's the DAS at this domain directory
-
getServerPid
protected final int getServerPid()Asks remote server for the PID- Returns:
- PID or -1 if unreachable
-
waitForRestart
protected final void waitForRestart(int oldPid, com.sun.enterprise.util.HostAndPort oldAdminAddress, com.sun.enterprise.util.HostAndPort newAdminAddress) throws org.glassfish.api.admin.CommandException Waits until server stops and starts- Parameters:
oldPid-oldAdminAddress-newAdminAddress- new admin endpoint - usually same as old, but it could change with restart.- Throws:
org.glassfish.api.admin.CommandException- if we time out.
-
getUptime
protected final long getUptime() throws org.glassfish.api.admin.CommandExceptionGet uptime from the server.- Throws:
org.glassfish.api.admin.CommandException
-
isRestartable
protected final boolean isRestartable() throws org.glassfish.api.admin.CommandExceptionSee if the server is restartable As of March 2011 -- this only returns false if a passwordfile argument was given when the server started -- but it is no longer available - i.e. the user deleted it or made it unreadable.- Throws:
org.glassfish.api.admin.CommandException
-
getMasterPasswordFile
-