Project

General

Profile

Download (5.05 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2009 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

    
10
package eu.etaxonomy.cdm.server;
11

    
12
import org.apache.commons.cli.Option;
13
import org.apache.commons.cli.OptionBuilder;
14
import org.apache.commons.cli.Options;
15

    
16
public class CommandOptions{
17

    
18
    private static Options options = null;
19

    
20
    public static final Option HELP = new Option( "help", "print this message" );
21
    public static final Option JMX = new Option( "jmx", "Start the server with the Jetty MBeans in JMX Management mode. \n" +
22
            "For testing you can use the following jvm options:\n" +
23
            "   -Dcom.sun.management.jmxremote.ssl=false\n" +
24
            "   -Dcom.sun.management.jmxremote.authenticate=false\n" +
25
            "   -Dcom.sun.management.jmxremote.port=9999" );
26
    public static final Option WIN32SERVICE= new Option("win32service", "ONLY USED INTERNALLY - prepare for running as win32 service, the server will not be started automatically!");
27

    
28
    @SuppressWarnings("static-access")
29
    public static final Option WEBAPP = OptionBuilder
30
            .withArgName("file")
31
            .hasArg()
32
            .withDescription( "Defines the webapplication to run from, this either can be a compressed war or extracted file.\n" +
33
                    "Defaults to the cdm-remote-webapp.war which is found in cdm-server/traget\n" +
34
                    "If this option is used extracting the war from the cdmserver jar file is omitted.\n \n" +
35
                    "DEVELOPMENT MODE:\n" +
36
                    "  If the specified path points to a directory the cdm-server will run in development mode.\n" +
37
                    "  In development mode the default webapplication containing the cdm-server management web \n" +
38
                    "  interface will be loaded from the source folder cdm-server/src/main/webapp. In normal \n" +
39
                    "  mode the default-webapp.war file will be used insead.\n" +
40
                    "  Using the following paths developers can run the cdm-webapp instances completely\n" +
41
                    "  from the target folder or from source (examples are for the eclipse ide):\n" +
42
                    "   - run from maven target: '{cdmlib-project-root}/cdm-webapp/target/cdmserver'\n " +
43
                    "   - run from source: '{cdmlib-project-root}/cdm-webapp/src/main/webapp'\n" +
44
                    "     When running from source you must also set the webapp-classpath option: \n" +
45
                    "     -webappClasspath=${project_classpath:cdm-webapp} " )
46
            .create("webapp");
47

    
48
  @SuppressWarnings("static-access")
49
    public static final Option WEBAPP_CLASSPATH = OptionBuilder
50
            .withArgName("classpath")
51
            .hasArg()
52
            .withDescription("Sets the classpath for the cdm-webapp instance when running from source code,\n" +
53
                    "e.g: ${project_classpath:cdm-webapp}\n" +
54
                    "See option -webapp")
55
            .create("webappClasspath");
56

    
57
    @SuppressWarnings("static-access")
58
    public static final Option HTTP_PORT = OptionBuilder
59
            .withArgName("httpPortNumber")
60
            .hasArg()
61
            .withDescription( "set the http listening port. Default is 8080")
62
            .create("httpPort") ;
63

    
64
    @SuppressWarnings("static-access")
65
    public static final Option DATASOURCES_FILE = OptionBuilder
66
        .withArgName("datasourcesfile")
67
        .hasArg()
68
        .withDescription( "use the specified datasources file. Default is {user.home}/.cdmLibrary/datasources.xml")
69
        .create("datasources");
70

    
71
    @SuppressWarnings("static-access")
72
    public static final Option CONTEXT_PATH_PREFIX = OptionBuilder
73
            .withArgName("url path element")
74
            .hasArg()
75
            .withDescription(
76
                    "The url path element to use as prefix for all cdm-server instances.\n" +
77
                    "Per default the instances are running at the server root.")
78
            .create("contextPathPrefix") ;
79

    
80
    public static final Option FORCE_SCHEMA_UPDATE = new Option( "forceSchemaUpdate",
81
            "USE THIS OPTION WITH CARE!"
82
            + " Outdated cdm database schema versions will"
83
            + " be forcably updated to the version of the cdm-server. This option is only intended"
84
            + " to be used for development purposes.");
85

    
86

    
87
    public static Options getOptions(){
88
        if(options == null){
89
            options = new Options();
90
            options.addOption(HELP);
91
            options.addOption(WEBAPP);
92
            options.addOption(WEBAPP_CLASSPATH);
93
            options.addOption(HTTP_PORT);
94
            options.addOption(DATASOURCES_FILE);
95
            options.addOption(JMX);
96
            options.addOption(WIN32SERVICE);
97
            options.addOption(CONTEXT_PATH_PREFIX);
98
            options.addOption(FORCE_SCHEMA_UPDATE);
99
        }
100
        return options;
101
    }
102
}
(3-3/6)