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
package eu.etaxonomy.cdm.server;
10

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

    
15
public class CommandOptions{
16

    
17
    private static Options options = null;
18

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

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

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

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

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

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

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

    
85

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