Project

General

Profile

Download (4.65 KB) Statistics
| Branch: | Tag: | Revision:
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 cdmlib-remote-webapp instaces 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}/cdmlib-remote-webapp/target/cdmserver'\n " +
44
                    "   - run from source: '{cdmlib-project-root}/cdmlib-remote-webapp/src/main/webapp'\n" +
45
                    "     When running from source you must also set the webapp-classpath option: \n" +
46
                    "     -webappClasspath=${project_classpath:cdmlib-remote-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 cdmlib-remote-webapp instance when running from source code,\n" +
54
                    "e.g: ${project_classpath:cdmlib-remote-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

    
81

    
82

    
83
    public static Options getOptions(){
84
        if(options == null){
85
            options = new Options();
86
            options.addOption(HELP);
87
            options.addOption(WEBAPP);
88
            options.addOption(WEBAPP_CLASSPATH);
89
            options.addOption(HTTP_PORT);
90
            options.addOption(LOG_DIR);
91
            options.addOption(DATASOURCES_FILE);
92
            options.addOption(JMX);
93
            options.addOption(WIN32SERVICE);
94
        }
95
        return options;
96
    }
97

    
98

    
99
}
(3-3/5)