xitiomet is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againplacebohttp / src / PlaceboBase.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /*
Copyright (C) 2010 Brian Dunigan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import org.openstatic.placebo.CoreServer;
import org.openstatic.placebo.ControlPanel;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Properties;
public class PlaceboBase
{
public static void help()
{
System.err.println("Openstatic.org HTTP Server");
System.err.println("");
System.err.println(" --debug Turn debugging output on");
System.err.println(" --showdata Show response data (debug must be on)");
System.err.println(" --root [path] Set webroot");
System.err.println(" --port [port] Specify HTTP listening port");
System.err.println(" --help display this menu");
System.err.println(" --plugin [path] [class] Add A plugin to server");
System.err.println(" --headless Start up without swing");
System.err.println(" --start Start server immediately");
System.err.println(" --var [key] [val] Define global variable for plugins");
System.err.println("");
System.err.println("");
}
public static void main(String[] args)
{
int http_port = 9040;
boolean debug = false;
boolean show_data = false;
boolean start_gui = false;
String web_root = "placebohttp.jar/www";
boolean start_engine = false;
Hashtable<String, String> plugins = new Hashtable<String, String>();
Properties global_settings = new Properties();
for (int i = 0; i < args.length; i++)
{
String arg = args[i].toLowerCase();
String arg_p1 = null;
String arg_p2 = null;
if (i + 1 < args.length)
{
arg_p1 = args[i+1];
}
if (i + 2 < args.length)
{
arg_p2 = args[i+2];
}
if (arg.equals("--port"))
{
http_port = Integer.valueOf(arg_p1);
}
if (arg.equals("--help"))
{
help();
System.exit(0);
}
if (arg.equals("--var"))
{
global_settings.setProperty(arg_p1, arg_p2);
}
if (arg.equals("--root"))
{
web_root = arg_p1;
}
if (arg.equals("--plugin"))
{
plugins.put(arg_p1, arg_p2);
}
if (arg.equals("--debug"))
{
System.err.println("Openstatic.org Placebo HTTP Server");
System.err.println("----------------------------------");
debug = true;
}
if (arg.equals("--showdata"))
{
show_data = true;
}
if (arg.equals("--headless"))
{
start_engine = true;
}
if (arg.equals("--start"))
{
start_gui = true;
}
}
if (start_engine)
{
CoreServer x = new CoreServer(global_settings);
x.setPort(http_port);
x.setWebRoot(web_root);
x.setDebug(debug);
x.setShowData(show_data);
x.start();
x.addPlugins(plugins);
} else {
ControlPanel cp = new ControlPanel();
cp.setGlobalSettings(global_settings);
cp.setPort(http_port);
cp.setWebRoot(web_root);
cp.setDebug(debug);
cp.setShowData(show_data);
cp.setPlugins(plugins);
if (start_gui)
{
cp.start_server();
}
}
}
}
|