public abstract class NuxeoLauncher extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
NuxeoLauncher.ShutdownThread |
Modifier and Type | Field and Description |
---|---|
protected String |
command |
protected ConfigurationGenerator |
configurationGenerator |
static String |
CONNECT_TC_URL |
CommandSetInfo |
cset |
static int |
EXIT_CODE_ERROR
Generic or unspecified error.
|
static int |
EXIT_CODE_INVALID
Invalid or excess argument(s).
|
static int |
EXIT_CODE_NOT_CONFIGURED
Program is not configured.
|
static int |
EXIT_CODE_NOT_INSTALLED
Program is not installed.
|
static int |
EXIT_CODE_NOT_RUNNING
Program is not running.
|
static int |
EXIT_CODE_OK |
static int |
EXIT_CODE_UNAUTHORIZED
User had insufficient privilege.
|
static int |
EXIT_CODE_UNIMPLEMENTED
Unimplemented feature.
|
protected Process |
nuxeoProcess |
protected static String |
OPTION_ACCEPT |
protected static String |
OPTION_CLID |
protected static String |
OPTION_DEBUG |
protected static String |
OPTION_DEBUG_CATEGORY |
protected static String |
OPTION_ENCRYPT |
protected static String |
OPTION_FORCE |
protected static String |
OPTION_GET |
protected static String |
OPTION_GET_REGEXP |
protected static String |
OPTION_GUI |
protected static String |
OPTION_GZIP_OUTPUT |
protected static String |
OPTION_HELP |
protected static String |
OPTION_HIDE_DEPRECATION |
protected static String |
OPTION_HIDE_DEPRECATION_DESC |
protected static String |
OPTION_IGNORE_MISSING |
protected static String |
OPTION_IGNORE_MISSING_DESC |
protected static String |
OPTION_JSON |
protected static String |
OPTION_NODEPS |
protected static String |
OPTION_OUTPUT |
protected static String |
OPTION_PRETTY_PRINT |
protected static String |
OPTION_QUIET |
protected static String |
OPTION_RELAX |
protected static String |
OPTION_RENEW |
protected static String |
OPTION_SET |
protected static String |
OPTION_SNAPSHOT |
protected static String |
OPTION_STRICT |
protected static String |
OPTION_XML |
protected static String |
OUTPUT_UNSET_VALUE |
protected boolean |
overrideJavaTmpDir |
protected String[] |
params |
protected String |
pid |
protected ProcessManager |
processManager |
static int |
STATUS_CODE_OFF
Program is not running.
|
static int |
STATUS_CODE_ON
Program is running or service is OK.
|
static int |
STATUS_CODE_UNKNOWN
Program or service status is unknown.
|
Constructor and Description |
---|
NuxeoLauncher(ConfigurationGenerator configurationGenerator) |
Modifier and Type | Method and Description |
---|---|
protected void |
addShutdownHook() |
protected String |
addToClassPath(String cp,
String filename) |
void |
checkNoRunningServer()
Check if some server is already running (from another thread) and throw a
Runtime exception if it finds one.
|
boolean |
commandIs(String aCommand) |
protected boolean |
commandRequiresNoGUI() |
protected boolean |
commandRequiresNoRunningServer() |
protected void |
config() |
void |
configure()
Configure the server after checking installation
|
static NuxeoLauncher |
createLauncher(String[] args) |
protected void |
decrypt() |
boolean |
doStart()
Call
doStart(boolean) with false as parameter. |
boolean |
doStart(boolean logProcessOutput)
Starts the server in background.
|
boolean |
doStartAndWait() |
boolean |
doStartAndWait(boolean logProcessOutput)
Whereas
doStart() considers the server as started when the
process is running, doStartAndWait() waits for effective start
by watching the logs |
protected boolean |
dumpConnectReport(OutputStream out,
boolean prettyprint) |
protected void |
encrypt() |
protected abstract String |
getClassPath() |
protected String |
getClassPath(String classpath,
File baseDir) |
String |
getCommand() |
protected void |
getConfigProperties() |
ConfigurationGenerator |
getConfigurationGenerator() |
protected ConnectBroker |
getConnectBroker() |
protected ConnectRegistrationBroker |
getConnectRegistrationBroker() |
int |
getErrorValue()
Last error value set by any method.
|
protected File[] |
getFilename(File baseDir,
String filePattern) |
NuxeoLauncherGUI |
getGUI() |
InstanceInfo |
getInfo()
Provides this instance info
|
protected List<String> |
getJavaOptsProperty(Function<String,String> mapper)
Gets the Java options defined in Nuxeo configuration files, e.g.
|
File |
getLogFile() |
protected Collection<? extends String> |
getNuxeoProperties() |
protected abstract String |
getServerPrint() |
protected abstract Collection<? extends String> |
getServerProperties() |
protected abstract String |
getShutdownClassPath() |
String |
getStartupSummary() |
int |
getStatus()
Last status value set by
status() . |
String |
getURL() |
void |
init() |
protected void |
initConnectBroker() |
protected static org.apache.commons.cli.Options |
initParserOptions() |
boolean |
isQuiet() |
boolean |
isRunning()
Work best with current nuxeoProcess.
|
boolean |
isStarted() |
boolean |
isUsingGui() |
protected XMLStreamWriter |
jsonWriter(JAXBContext context,
OutputStream out) |
static void |
launch(NuxeoLauncher launcher) |
ArrayList<ThreadedStreamGobbler> |
logProcessStreams(Process process,
boolean logProcessOutput) |
static void |
main(String[] args) |
protected static OutputStream |
openOutput(Path path,
boolean gzip) |
protected boolean |
pack()
Since 5.5
|
protected static org.apache.commons.cli.CommandLine |
parseOptions(String[] args) |
protected boolean |
pkgAdd(String[] pkgNames) |
protected boolean |
pkgCompoundRequest(List<String> request)
Combined install/uninstall request
|
protected boolean |
pkgHotfix()
Install the hotfixes available for the instance
|
protected boolean |
pkgInit()
Add packages from the distribution to the local cache
|
protected boolean |
pkgInstall(String[] pkgIDs) |
protected void |
pkgList()
List all local packages.
|
protected void |
pkgListAll()
List all packages including remote ones.
|
protected boolean |
pkgPurge()
Uninstall and remove all packages from the local cache
|
protected boolean |
pkgRefreshCache()
Update the cached list of remote packages
|
protected boolean |
pkgRemove(String[] pkgIDs) |
protected boolean |
pkgRequest(List<String> pkgsToAdd,
List<String> pkgsToInstall,
List<String> pkgsToUninstall,
List<String> pkgsToRemove) |
protected boolean |
pkgReset() |
protected boolean |
pkgSetRequest(List<String> request,
boolean nodeps) |
protected boolean |
pkgShow(String[] packages)
dpkg-like command which returns package location, version, dependencies,
conflicts, ...
|
protected boolean |
pkgUninstall(String[] pkgIDs) |
protected boolean |
pkgUpgrade()
Upgrade the Nuxeo Packages (addons) available for the instance
|
protected void |
printInstanceXMLOutput(InstanceInfo instance) |
protected void |
printInstanceXMLOutput(InstanceInfo instance,
OutputStream out) |
static void |
printLongHelp() |
static void |
printShortHelp() |
protected void |
printXMLOutput() |
protected void |
printXMLOutput(JAXBContext jaxbContext,
Object objectToOutput) |
protected void |
printXMLOutput(JAXBContext context,
Object object,
OutputStream out) |
String |
prompt(String message,
Predicate<String> predicate,
String error)
Prompt for a value read from the console or stdin.
|
String |
promptDescription() |
String |
promptEmail()
Prompts for a valid email address according to RFC 822 standards.
|
org.nuxeo.connect.connector.NuxeoClientInstanceType |
promptInstanceType() |
char[] |
promptPassword(boolean confirmation) |
char[] |
promptPassword(String message) |
org.nuxeo.connect.data.ConnectProject |
promptProject(List<org.nuxeo.connect.data.ConnectProject> projects) |
boolean |
register()
Register the instance, generating the CLID or using the passed one; or renew a registration.
|
protected boolean |
registerRemoteInstance() |
protected boolean |
registerRemoteInstance(String username,
char[] password,
org.nuxeo.connect.data.ConnectProject project,
org.nuxeo.connect.connector.NuxeoClientInstanceType type,
String description) |
protected boolean |
registerRenew() |
protected boolean |
registerSaveCLID() |
boolean |
registerTrial()
Deprecated.
Since 9.3: To register for a free 30 day trial on Nuxeo Online Services, please visit
https://connect.nuxeo.com/register
|
protected void |
removeShutdownHook() |
protected void |
setConfigProperties() |
protected static void |
setDebug(boolean activateDebug) |
protected static void |
setDebug(String categories) |
protected static void |
setDebug(String[] categories,
String defaultCategory) |
protected static void |
setDebug(String categories,
boolean activateDebug) |
void |
setGUI(NuxeoLauncherGUI gui) |
protected void |
setJSONOutput() |
protected static void |
setQuiet()
Set launcher in quiet mode
|
protected abstract void |
setServerStartCommand(List<String> command) |
protected abstract void |
setServerStopCommand(List<String> command) |
protected static void |
setStrict(boolean isStrict) |
protected void |
setXMLOutput() |
protected void |
showConfig() |
protected void |
start(boolean logProcessOutput)
Do not directly call this method without a call to
checkNoRunningServer() |
protected boolean |
startWizard() |
String |
status()
Return process status (running or not) as String, depending on OS
capability to manage processes.
|
void |
stop() |
void |
stop(boolean logProcessOutput)
Stops the server.
|
protected boolean |
waitForEffectiveStart() |
void |
waitForProcessStreams(ArrayList<ThreadedStreamGobbler> sgArray)
Stop stream gobblers contained in the given ArrayList
|
boolean |
wasStartupFine()
Must be called after
getStartupSummary() |
protected XMLStreamWriter |
xmlWriter(JAXBContext context,
OutputStream out) |
protected static final String OUTPUT_UNSET_VALUE
protected static final String OPTION_NODEPS
protected static final String OPTION_GUI
protected static final String OPTION_JSON
protected static final String OPTION_XML
protected static final String OPTION_DEBUG
protected static final String OPTION_DEBUG_CATEGORY
protected static final String OPTION_QUIET
protected static final String OPTION_HELP
protected static final String OPTION_RELAX
protected static final String OPTION_ACCEPT
protected static final String OPTION_SNAPSHOT
protected static final String OPTION_FORCE
protected static final String OPTION_STRICT
protected static final String OPTION_HIDE_DEPRECATION
protected static final String OPTION_HIDE_DEPRECATION_DESC
protected static final String OPTION_IGNORE_MISSING
protected static final String OPTION_IGNORE_MISSING_DESC
protected static final String OPTION_CLID
protected static final String OPTION_RENEW
protected static final String OPTION_ENCRYPT
protected static final String OPTION_SET
protected static final String OPTION_GET
protected static final String OPTION_GET_REGEXP
protected static final String OPTION_GZIP_OUTPUT
protected static final String OPTION_OUTPUT
protected static final String OPTION_PRETTY_PRINT
protected boolean overrideJavaTmpDir
public static final int STATUS_CODE_ON
public static final int STATUS_CODE_OFF
public static final int STATUS_CODE_UNKNOWN
public static final int EXIT_CODE_OK
public static final int EXIT_CODE_ERROR
public static final int EXIT_CODE_INVALID
public static final int EXIT_CODE_UNIMPLEMENTED
public static final int EXIT_CODE_UNAUTHORIZED
public static final int EXIT_CODE_NOT_INSTALLED
public static final int EXIT_CODE_NOT_CONFIGURED
public static final int EXIT_CODE_NOT_RUNNING
public static final String CONNECT_TC_URL
protected ConfigurationGenerator configurationGenerator
protected ProcessManager processManager
protected Process nuxeoProcess
public CommandSetInfo cset
public NuxeoLauncher(ConfigurationGenerator configurationGenerator)
protected boolean commandRequiresNoRunningServer()
protected boolean commandRequiresNoGUI()
public final ConfigurationGenerator getConfigurationGenerator()
public String getCommand()
public boolean isUsingGui()
public boolean isQuiet()
public NuxeoLauncherGUI getGUI()
public void setGUI(NuxeoLauncherGUI gui)
public void init()
protected void start(boolean logProcessOutput) throws IOException, InterruptedException
checkNoRunningServer()
IOException
- In case of issue with process.InterruptedException
- If any thread has interrupted the current thread.doStart()
protected List<String> getJavaOptsProperty(Function<String,String> mapper)
public void checkNoRunningServer() throws IllegalStateException
isRunning()
won't.IllegalThreadStateException
- Thrown if a server is already running.IllegalStateException
public ArrayList<ThreadedStreamGobbler> logProcessStreams(Process process, boolean logProcessOutput)
protected abstract String getServerPrint()
protected abstract Collection<? extends String> getServerProperties()
protected abstract void setServerStartCommand(List<String> command)
protected abstract String getClassPath()
protected abstract String getShutdownClassPath()
protected Collection<? extends String> getNuxeoProperties()
protected String addToClassPath(String cp, String filename)
protected static org.apache.commons.cli.Options initParserOptions()
protected static org.apache.commons.cli.CommandLine parseOptions(String[] args) throws org.apache.commons.cli.ParseException
org.apache.commons.cli.ParseException
public static void launch(NuxeoLauncher launcher) throws IOException, org.nuxeo.connect.update.PackageException, ConfigurationException, org.apache.commons.cli.ParseException, GeneralSecurityException
IOException
org.nuxeo.connect.update.PackageException
ConfigurationException
org.apache.commons.cli.ParseException
GeneralSecurityException
protected static OutputStream openOutput(Path path, boolean gzip) throws IOException
IOException
public String promptEmail() throws IOException, ConfigurationException
ConfigurationException
- If the user input is read from stdin and is null
or
does not match the regex
IOException
public String promptDescription() throws ConfigurationException, IOException
ConfigurationException
IOException
public String prompt(String message, Predicate<String> predicate, String error) throws IOException, ConfigurationException
message
- message to display at promptpredicate
- a predicate that must match a correct user input. Ignored if
null
.error
- an error message to display or raise when the user input is
null
or does not match the regex
ConfigurationException
- If the user input is read from stdin and is null
or
does not match the regex
IOException
public char[] promptPassword(String message) throws IOException
message
- message to display at promptIOException
public char[] promptPassword(boolean confirmation) throws IOException, ConfigurationException
confirmation
- if true, password is asked twice.IOException
ConfigurationException
public org.nuxeo.connect.connector.NuxeoClientInstanceType promptInstanceType() throws IOException, ConfigurationException
NuxeoClientInstanceType
. Never null
.IOException
ConfigurationException
public org.nuxeo.connect.data.ConnectProject promptProject(@NotNull List<org.nuxeo.connect.data.ConnectProject> projects) throws ConfigurationException, IOException, org.nuxeo.connect.update.PackageException
projects
- available projects the user must choose one amongst.ConfigurationException
- If projects
is empty or if there is not such a
project named as the parameter read from stdin.IOException
org.nuxeo.connect.update.PackageException
public boolean register() throws IOException, ConfigurationException, org.nuxeo.connect.update.PackageException
nuxeoctl register [<username> [<project> [<type> <description>] [pwd]]]
nuxeoctl register --clid <file>
nuxeoctl register --renew [--clid <file>]
Missing parameters are read from stdin.IOException
ConfigurationException
org.nuxeo.connect.update.PackageException
protected boolean registerRenew() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean registerSaveCLID() throws IOException, ConfigurationException, org.nuxeo.connect.update.PackageException
IOException
ConfigurationException
org.nuxeo.connect.update.PackageException
protected boolean registerRemoteInstance() throws IOException, ConfigurationException, org.nuxeo.connect.update.PackageException
IOException
ConfigurationException
org.nuxeo.connect.update.PackageException
protected boolean registerRemoteInstance(String username, char[] password, org.nuxeo.connect.data.ConnectProject project, org.nuxeo.connect.connector.NuxeoClientInstanceType type, String description) throws IOException, ConfigurationException, org.nuxeo.connect.update.PackageException
IOException
ConfigurationException
org.nuxeo.connect.update.PackageException
@Deprecated public boolean registerTrial() throws IOException, ConfigurationException, org.nuxeo.connect.update.PackageException
nuxeoctl register-trial [ <first> <last> <email> <company> <project> ]
IOException
ConfigurationException
org.nuxeo.connect.update.PackageException
protected void encrypt() throws ConfigurationException, GeneralSecurityException
ConfigurationException
GeneralSecurityException
protected void decrypt() throws ConfigurationException
ConfigurationException
protected void config() throws ConfigurationException, IOException, GeneralSecurityException
ConfigurationException
IOException
GeneralSecurityException
protected void getConfigProperties()
protected void setConfigProperties() throws ConfigurationException, IOException, GeneralSecurityException
ConfigurationException
IOException
GeneralSecurityException
protected boolean pack()
protected boolean startWizard() throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
public boolean doStartAndWait() throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
doStartAndWait(boolean)
public void stop()
stop(boolean)
public boolean doStart() throws org.nuxeo.connect.update.PackageException
doStart(boolean)
with false as parameter.org.nuxeo.connect.update.PackageException
doStart(boolean)
public boolean doStartAndWait(boolean logProcessOutput) throws org.nuxeo.connect.update.PackageException
doStart()
considers the server as started when the
process is running, doStartAndWait()
waits for effective start
by watching the logslogProcessOutput
- Must process output stream must be logged or not.org.nuxeo.connect.update.PackageException
protected void removeShutdownHook()
protected boolean waitForEffectiveStart() throws InterruptedException
InterruptedException
public boolean wasStartupFine()
getStartupSummary()
public String getStartupSummary()
public boolean doStart(boolean logProcessOutput) throws org.nuxeo.connect.update.PackageException
org.nuxeo.connect.update.PackageException
protected void printXMLOutput()
protected void printXMLOutput(JAXBContext jaxbContext, Object objectToOutput)
protected void printXMLOutput(JAXBContext context, Object object, OutputStream out) throws XMLStreamException, FactoryConfigurationError, JAXBException
XMLStreamException
FactoryConfigurationError
JAXBException
protected XMLStreamWriter jsonWriter(JAXBContext context, OutputStream out)
protected XMLStreamWriter xmlWriter(JAXBContext context, OutputStream out) throws XMLStreamException, FactoryConfigurationError
public void waitForProcessStreams(ArrayList<ThreadedStreamGobbler> sgArray)
logProcessStreams(Process, boolean)
protected String getClassPath(String classpath, File baseDir) throws IOException
IOException
protected File[] getFilename(File baseDir, String filePattern)
protected void addShutdownHook()
public void stop(boolean logProcessOutput)
protected abstract void setServerStopCommand(List<String> command)
public void configure() throws ConfigurationException
ConfigurationException
- If an installation error is detected or if configuration
failspublic String status()
getStatus()
public int getErrorValue()
public static NuxeoLauncher createLauncher(String[] args) throws ConfigurationException, org.apache.commons.cli.ParseException, IOException, org.nuxeo.connect.update.PackageException
ConfigurationException
- If server cannot be identifiedorg.apache.commons.cli.ParseException
IOException
org.nuxeo.connect.update.PackageException
protected static void setQuiet()
protected static void setDebug(String[] categories, String defaultCategory)
categories
- Root categories to switch DEBUG on.protected static void setDebug(String categories)
categories
- Root categories to switch DEBUG on.protected static void setDebug(String categories, boolean activateDebug)
categories
- Root categories to switch DEBUG on or offactivateDebug
- Set DEBUG on or off.protected static void setDebug(boolean activateDebug)
activateDebug
- if true, will activate the DEBUG logsprotected static void setStrict(boolean isStrict)
isStrict
- if true
, set the launcher strict optionOPTION_STRICT_DESC
protected void setXMLOutput()
protected void setJSONOutput()
public static void printShortHelp()
public static void printLongHelp()
public boolean isRunning()
public InstanceInfo getInfo()
public boolean isStarted()
public File getLogFile()
protected void initConnectBroker() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected ConnectBroker getConnectBroker() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected ConnectRegistrationBroker getConnectRegistrationBroker() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected void pkgList() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected void pkgListAll() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgAdd(String[] pkgNames) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgInstall(String[] pkgIDs) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgUninstall(String[] pkgIDs) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgRemove(String[] pkgIDs) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgReset() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected void printInstanceXMLOutput(InstanceInfo instance)
protected void printInstanceXMLOutput(InstanceInfo instance, OutputStream out) throws JAXBException, XMLStreamException, FactoryConfigurationError
protected void showConfig() throws IOException, org.nuxeo.connect.update.PackageException, ConfigurationException
IOException
org.nuxeo.connect.update.PackageException
ConfigurationException
protected boolean pkgRequest(List<String> pkgsToAdd, List<String> pkgsToInstall, List<String> pkgsToUninstall, List<String> pkgsToRemove) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgRefreshCache() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgInit() throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgPurge() throws org.nuxeo.connect.update.PackageException, IOException
true
if command succeedorg.nuxeo.connect.update.PackageException
IOException
protected boolean pkgHotfix() throws IOException, org.nuxeo.connect.update.PackageException
true
if command succeedIOException
org.nuxeo.connect.update.PackageException
protected boolean pkgUpgrade() throws IOException, org.nuxeo.connect.update.PackageException
true
if command succeedIOException
org.nuxeo.connect.update.PackageException
protected boolean pkgCompoundRequest(List<String> request) throws IOException, org.nuxeo.connect.update.PackageException
request
- Space separated list of package names or IDs prefixed with +
(install) or - (uninstall)IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgSetRequest(List<String> request, boolean nodeps) throws IOException, org.nuxeo.connect.update.PackageException
IOException
org.nuxeo.connect.update.PackageException
protected boolean pkgShow(String[] packages) throws IOException, org.nuxeo.connect.update.PackageException
packages
- List of packages identified by their ID, name or local
filename.IOException
org.nuxeo.connect.update.PackageException
protected boolean dumpConnectReport(OutputStream out, boolean prettyprint)
Copyright © 2018 Nuxeo. All rights reserved.