4 import org
.mortbay
.jetty
.Server
;
5 import org
.mortbay
.jetty
.webapp
.WebAppContext
;
9 * This class launches the web application in an embedded Jetty container.
10 * This is the entry point to your application. The Java command that is used for
11 * launching should fire this main method.
19 public static void main(String
[] args
) throws Exception
{
20 String webappDirLocation
= "src/main/webapp/";
22 //The port that we should run on can be set into an environment variable
23 //Look for that variable and default to 8080 if it isn't there.
24 String webPort
= System
.getenv("PORT");
25 if(webPort
== null || webPort
.isEmpty()) {
29 Server server
= new Server(Integer
.valueOf(webPort
));
30 WebAppContext root
= new WebAppContext();
32 root
.setContextPath("/");
33 root
.setDescriptor(webappDirLocation
+"/WEB-INF/web.xml");
34 root
.setResourceBase(webappDirLocation
);
36 //Parent loader priority is a class loader setting that Jetty accepts.
37 //By default Jetty will behave like most web containers in that it will
38 //allow your application to replace non-server libraries that are part of the
39 //container. Setting parent loader priority to true changes this behavior.
40 //Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
41 root
.setParentLoaderPriority(true);
43 server
.setHandler(root
);