summaryrefslogtreecommitdiff
path: root/external/ZendFramework-1.9.5/externals/dojo/demos/offline/editor/server/org/dojo/moxie/Main.java
blob: becd5207b5dc236a683f4d39d20fc66a2e7d6c93 (plain)
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
package org.dojo.moxie;

import javax.servlet.*;
import javax.servlet.http.*;
 
import org.mortbay.jetty.*;
import org.mortbay.jetty.handler.*;
import org.mortbay.jetty.servlet.*;

/**
	A quick starter class that enables users to run the Moxie
	server-side extremely quickly. We use the embedded Derby
	database that comes bundled with Java, coupled with an
	embedded version of the tiny Jetty embedded web-server.
	
	@author Brad Neuberg, bkn3@columbia.edu
*/
public class Main{
	public static void main(String args[]){
		try{
			// start our embedded web server, Jetty
			Server server = new Server(8000);   
			
			// serve up our Moxie/Dojo files
			ResourceHandler resourceHandler = new ResourceHandler();
			resourceHandler.setResourceBase("../../../..");
			server.addHandler(resourceHandler);
			
			// add the Moxie servlet
			Context moxieRoot = new Context(server, "/moxie", Context.SESSIONS);
			Servlet moxieServlet = new MoxieServlet("jdbc:derby:moxie;create=true", null, null,
													"org.apache.derby.jdbc.EmbeddedDriver");
			moxieRoot.addServlet(new ServletHolder(moxieServlet), "/*");
			
			System.out.println("Starting web server on port 8000...");
			server.start();
		
			System.out.println("Moxie ready to try on port 8000.");
			System.out.println("Open a web browser and go to:");
			System.out.println("http://localhost:8000/demos/offline/editor/editor.html");
		}catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
}