1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.server;
|
12
|
|
13
|
import org.apache.commons.cli.Option;
|
14
|
import org.apache.commons.cli.OptionBuilder;
|
15
|
import org.apache.commons.cli.Options;
|
16
|
|
17
|
public class CommandOptions{
|
18
|
|
19
|
private static Options options = null;
|
20
|
|
21
|
public static final Option HELP = new Option( "help", "print this message" );
|
22
|
public static final Option JMX = new Option( "jmx", "Start the server with the Jetty MBeans in JMX Management mode. \n" +
|
23
|
"For testing you can use the following jvm options:\n" +
|
24
|
" -Dcom.sun.management.jmxremote.ssl=false\n" +
|
25
|
" -Dcom.sun.management.jmxremote.authenticate=false\n" +
|
26
|
" -Dcom.sun.management.jmxremote.port=9999" );
|
27
|
public static final Option WIN32SERVICE= new Option("win32service", "ONLY USED INTERNALLY - prepare for running as win32 service, the server will not be started automatically!");
|
28
|
|
29
|
@SuppressWarnings("static-access")
|
30
|
public static final Option WEBAPP = OptionBuilder
|
31
|
.withArgName("file")
|
32
|
.hasArg()
|
33
|
.withDescription( "Defines the webapplication to run from, this either can be a compressed war or extracted file.\n" +
|
34
|
"Defaults to the cdm-remote-webapp.war which is found in cdm-server/traget\n" +
|
35
|
"If this option is used extracting the war from the cdmserver jar file is omitted.\n \n" +
|
36
|
"DEVELOPMENT MODE:\n" +
|
37
|
" If the specified path points to a directory the cdm-server will run in development mode.\n" +
|
38
|
" In development mode the default webapplication containing the cdm-server management web \n" +
|
39
|
" interface will be loaded from the source folder cdm-server/src/main/webapp. In normal \n" +
|
40
|
" mode the default-webapp.war file will be used insead.\n" +
|
41
|
" Using the following paths developers can run the cdm-webapp instances completely\n" +
|
42
|
" from the target folder or from source (examples are for the eclipse ide):\n" +
|
43
|
" - run from maven target: '{cdmlib-project-root}/cdm-webapp/target/cdmserver'\n " +
|
44
|
" - run from source: '{cdmlib-project-root}/cdm-webapp/src/main/webapp'\n" +
|
45
|
" When running from source you must also set the webapp-classpath option: \n" +
|
46
|
" -webappClasspath=${project_classpath:cdm-webapp} " )
|
47
|
.create("webapp");
|
48
|
|
49
|
@SuppressWarnings("static-access")
|
50
|
public static final Option WEBAPP_CLASSPATH = OptionBuilder
|
51
|
.withArgName("classpath")
|
52
|
.hasArg()
|
53
|
.withDescription("Sets the classpath for the cdm-webapp instance when running from source code,\n" +
|
54
|
"e.g: ${project_classpath:cdm-webapp}\n" +
|
55
|
"See option -webapp")
|
56
|
.create("webappClasspath");
|
57
|
|
58
|
@SuppressWarnings("static-access")
|
59
|
public static final Option HTTP_PORT = OptionBuilder
|
60
|
.withArgName("httpPortNumber")
|
61
|
.hasArg()
|
62
|
.withDescription( "set the http listening port. Default is 8080")
|
63
|
.create("httpPort") ;
|
64
|
|
65
|
@SuppressWarnings("static-access")
|
66
|
public static final Option LOG_DIR = OptionBuilder
|
67
|
.withArgName("file")
|
68
|
.hasArg()
|
69
|
.withDescription( "Alternative location to write logs to. " +
|
70
|
"By default the cdm server will use ${user.home}/.cdmLibrary/logs/" )
|
71
|
.create("logdir");
|
72
|
|
73
|
@SuppressWarnings("static-access")
|
74
|
public static final Option DATASOURCES_FILE = OptionBuilder
|
75
|
.withArgName("datasourcesfile")
|
76
|
.hasArg()
|
77
|
.withDescription( "use the specified datasources file. Default is {user.home}/.cdmLibrary/datasources.xml")
|
78
|
.create("datasources");
|
79
|
|
80
|
@SuppressWarnings("static-access")
|
81
|
public static final Option CONTEXT_PATH_PREFIX = OptionBuilder
|
82
|
.withArgName("url path element")
|
83
|
.hasArg()
|
84
|
.withDescription(
|
85
|
"The url path element to use as prefix for all cdm-server instances.\n" +
|
86
|
"Per default the instances are running at the server root.")
|
87
|
.create("contextPathPrefix") ;
|
88
|
|
89
|
|
90
|
public static Options getOptions(){
|
91
|
if(options == null){
|
92
|
options = new Options();
|
93
|
options.addOption(HELP);
|
94
|
options.addOption(WEBAPP);
|
95
|
options.addOption(WEBAPP_CLASSPATH);
|
96
|
options.addOption(HTTP_PORT);
|
97
|
options.addOption(LOG_DIR);
|
98
|
options.addOption(DATASOURCES_FILE);
|
99
|
options.addOption(JMX);
|
100
|
options.addOption(WIN32SERVICE);
|
101
|
options.addOption(CONTEXT_PATH_PREFIX);
|
102
|
}
|
103
|
return options;
|
104
|
}
|
105
|
|
106
|
|
107
|
}
|