View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-shell Project
18  //
19  // UTGBPortableConfig.java
20  // Since: Sep 2, 2008
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.shell;
26  
27  import org.xerial.lens.JSONLens;
28  import org.xerial.util.opt.Option;
29  
30  /**
31   * The configuration parameters of the UTGBPortable
32   * 
33   * @author leo
34   * 
35   */
36  public class UTGBPortableConfig {
37  
38  	@Option(symbol = "p", longName = "port", varName = "PORT_NUMBER", description = "specify the port number of the local web server (default = 8989)")
39  	int portNumber = 8989;
40  
41  	@Option(symbol = "c", longName = "contextPath", varName = "PATH", description = "context path. default=/utgb")
42  	String contextPath = null;
43  
44  	String projectRoot = null;
45  
46  	@Option(symbol = "w", longName = "webapp", varName = "DIR", description = "webapp (web application) directory. default = src/main/webapp")
47  	String webAppDir = UTGBShellCommand.WEBAPP_FOLDER;
48  
49  	@Option(symbol = "t", longName = "workdir", varName = "DIR", description = "working directory (tomcat base). default= target/utgb")
50  	String workingDir = UTGBShellCommand.EXPLODED_WEBAPP_DIR;
51  
52  	String projectConfigDir = "config";
53  
54  	@Option(symbol = "v", longName = "verbose", description = "display verbose log message")
55  	boolean isVerbose = false;
56  
57  	@Option(symbol = "g", description = "launch in GUI mode")
58  	boolean useGUI = false;
59  
60  	@Option(symbol = "h", longName = "help", description = "display help message")
61  	boolean displayHelp = false;
62  
63  	@Option(longName = "module", description = "GWT modules name. default = utgb")
64  	String gwtModule = "utgb";
65  
66  	public UTGBPortableConfig() {
67  	}
68  
69  	public UTGBPortableConfig(int portNumber, String contextPath, String projectRoot) {
70  		this.portNumber = portNumber;
71  		this.contextPath = contextPath;
72  		this.projectRoot = projectRoot;
73  	}
74  
75  	public String getServerURL() {
76  		return String.format("http://localhost:%d%s", portNumber, contextPath);
77  	}
78  
79  	public String generateServerURLLinkHTML() {
80  		String serverURL = getServerURL();
81  		return String.format("<html><a href=\"%s\">%s</a></html>", serverURL, serverURL);
82  	}
83  
84  	@Override
85  	public String toString() {
86  		return JSONLens.toJSON(this);
87  	}
88  
89  	public int getPortNumber() {
90  		return portNumber;
91  	}
92  
93  	public String getContextPath() {
94  		return contextPath;
95  	}
96  
97  	public String getProjectRoot() {
98  		return projectRoot;
99  	}
100 
101 	public String getWebAppDir() {
102 		return webAppDir;
103 	}
104 
105 	public String getWorkingDir() {
106 		return workingDir;
107 	}
108 
109 	public String getGWTModuleName() {
110 		return gwtModule;
111 	}
112 
113 	public String getProjectConfigDir() {
114 		return projectConfigDir;
115 	}
116 
117 	public boolean isVerbose() {
118 		return isVerbose;
119 	}
120 
121 	public boolean isUseGUI() {
122 		return useGUI;
123 	}
124 
125 	public boolean isDisplayHelp() {
126 		return displayHelp;
127 	}
128 
129 }