use of fish.payara.micro.cmd.options.RuntimeOptions in project Payara by payara.
the class PayaraMicroImpl method scanArgs.
private void scanArgs(String[] args) {
RuntimeOptions options = null;
try {
options = new RuntimeOptions(args);
} catch (ValidationException ex) {
LOGGER.log(Level.SEVERE, ex.getMessage());
System.exit(-1);
}
processUserProperties(options);
setArgumentsFromSystemProperties();
for (RUNTIME_OPTION option : options.getOptions()) {
List<String> values = options.getOption(option);
for (String value : values) {
switch(option) {
case port:
{
httpPort = Integer.parseInt(value);
break;
}
case sslport:
{
sslPort = Integer.parseInt(value);
break;
}
case sslcert:
{
sslCert = value;
break;
}
case version:
{
printVersion();
System.exit(1);
break;
}
case maxhttpthreads:
{
maxHttpThreads = Integer.parseInt(value);
break;
}
case minhttpthreads:
{
minHttpThreads = Integer.parseInt(value);
break;
}
case mcaddress:
hzMulticastGroup = value;
break;
case clustername:
hzClusterName = value;
break;
case clusterpassword:
hzClusterPassword = value;
break;
case hostaware:
{
hostAware = true;
break;
}
case nohostaware:
{
hostAware = false;
break;
}
case mcport:
{
hzPort = Integer.parseInt(value);
break;
}
case startport:
hzStartPort = Integer.parseInt(value);
break;
case name:
instanceName = value;
break;
case instancegroup:
case group:
instanceGroup = value;
break;
case deploymentdir:
case deploydir:
deploymentRoot = new File(value);
break;
case rootdir:
rootDir = new File(value);
break;
case addlibs:
case addjars:
List<File> files = UberJarCreator.parseFileList(value, File.pathSeparator);
if (!files.isEmpty()) {
if (libraries == null) {
libraries = new LinkedList<>();
}
libraries.addAll(files);
}
break;
case deploy:
File deployment = new File(value);
if (deployments == null) {
deployments = new LinkedList<>();
}
deployments.add(deployment);
break;
case domainconfig:
alternateDomainXML = new File(value);
break;
case nocluster:
noCluster = true;
break;
case lite:
liteMember = true;
break;
case hzconfigfile:
alternateHZConfigFile = new File(value);
break;
case autobindhttp:
autoBindHttp = true;
break;
case autobindssl:
autoBindSsl = true;
break;
case autobindrange:
autoBindRange = Integer.parseInt(value);
break;
case enablehealthcheck:
enableHealthCheck = Boolean.valueOf(value);
break;
case deployfromgav:
if (GAVs == null) {
GAVs = new LinkedList<>();
}
GAVs.add(value);
break;
case additionalrepository:
try {
// If there isn't a trailing /, add one
if (!value.endsWith("/")) {
value = value + "/";
repositoryURLs.add(new URL(value + "/"));
} else {
repositoryURLs.add(new URL(value));
}
} catch (MalformedURLException ex) {
LOGGER.log(Level.SEVERE, "{0} is not a valid URL and will be ignored", value);
}
break;
case outputuberjar:
uberJar = new File(value);
break;
case copytouberjar:
copyDirectory = new File(value);
break;
case disablephonehome:
disablePhoneHome = true;
break;
case enablerequesttracing:
enableRequestTracing = true;
// Split strings from numbers
if (value != null) {
String[] requestTracing = value.split("(?<=\\d)(?=\\D)|(?=\\d)(?<=\\D)");
// If valid, there should be no more than 2 entries
if (requestTracing.length <= 2) {
// If the first entry is a number
if (requestTracing[0].matches("\\d+")) {
try {
requestTracingThresholdValue = Long.parseLong(requestTracing[0]);
} catch (NumberFormatException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid request tracing " + "threshold value", requestTracing[0]);
throw e;
}
// If there is a second entry, and it's a String
if (requestTracing.length == 2 && requestTracing[1].matches("\\D+")) {
String parsedUnit = parseRequestTracingUnit(requestTracing[1]);
try {
TimeUnit.valueOf(parsedUnit.toUpperCase());
requestTracingThresholdUnit = parsedUnit.toUpperCase();
} catch (IllegalArgumentException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid request " + "tracing threshold unit", requestTracing[1]);
throw e;
}
} else // If there is a second entry, and it's not a String
if (requestTracing.length == 2 && !requestTracing[1].matches("\\D+")) {
throw new IllegalArgumentException();
}
} else // If the first entry is a String
if (requestTracing[0].matches("\\D+")) {
String parsedUnit = parseRequestTracingUnit(requestTracing[0]);
try {
TimeUnit.valueOf(parsedUnit.toUpperCase());
requestTracingThresholdUnit = parsedUnit.toUpperCase();
} catch (IllegalArgumentException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid request " + "tracing threshold unit", requestTracing[0]);
throw e;
}
// There shouldn't be a second entry
if (requestTracing.length == 2) {
throw new IllegalArgumentException();
}
}
} else {
throw new IllegalArgumentException();
}
}
break;
case requesttracingthresholdunit:
try {
String parsedUnit = parseRequestTracingUnit(value);
TimeUnit.valueOf(parsedUnit.toUpperCase());
requestTracingThresholdUnit = parsedUnit.toUpperCase();
} catch (IllegalArgumentException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid value for --requestTracingThresholdUnit", value);
throw e;
}
break;
case requesttracingthresholdvalue:
try {
requestTracingThresholdValue = Long.parseLong(value);
} catch (NumberFormatException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid value for --requestTracingThresholdValue", value);
throw e;
}
break;
case enablerequesttracingadaptivesampling:
enableRequestTracingAdaptiveSampling = true;
break;
case requesttracingadaptivesamplingtargetcount:
enableRequestTracingAdaptiveSampling = true;
try {
requestTracingAdaptiveSamplingTargetCount = Integer.parseInt(value);
} catch (NumberFormatException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid value for --requestTracingAdaptiveSamplingTargetCount", value);
throw e;
}
break;
case requesttracingadaptivesamplingtimevalue:
enableRequestTracingAdaptiveSampling = true;
try {
requestTracingAdaptiveSamplingTimeValue = Integer.parseInt(value);
} catch (NumberFormatException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid value for --requestTracingAdaptiveSamplingTimeValue", value);
throw e;
}
break;
case requesttracingadaptivesamplingtimeunit:
enableRequestTracingAdaptiveSampling = true;
try {
TimeUnit.valueOf(value.toUpperCase());
requestTracingAdaptiveSamplingTimeUnit = value.toUpperCase();
} catch (IllegalArgumentException e) {
LOGGER.log(Level.WARNING, "{0} is not a valid value for --requestTracingAdaptiveSamplingTimeUnit", value);
throw e;
}
break;
case help:
RuntimeOptions.printHelp();
System.exit(1);
break;
case logtofile:
setUserLogFile(value);
break;
case accesslog:
File file = new File(value);
setAccessLogDir(file.getAbsolutePath());
break;
case accesslogformat:
setAccessLogFormat(value);
break;
case logproperties:
setLogPropertiesFile(new File(value));
break;
case logo:
generateLogo = true;
break;
case postbootcommandfile:
postBootFileName = value;
break;
case prebootcommandfile:
preBootFileName = value;
break;
case postdeploycommandfile:
postDeployFileName = value;
break;
case clustermode:
clustermode = value;
break;
case interfaces:
interfaces = value;
break;
case secretsdir:
secretsDir = value;
break;
case showservletmappings:
showServletMappings = true;
break;
default:
break;
}
}
}
}
Aggregations