server.addConnector(connector);
ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);
Context context = new Context(contexts,"/",Context.NO_SECURITY|Context.SESSIONS);
String version = Server.getVersion();
if (Server.UNKNOWN_VERSION.equals(version))
version=Server.SNAPSHOT_VERSION;
context.setBaseResource(new ResourceCollection(new Resource[]
{
Resource.newResource(base+"/../demo/src/main/webapp/"),
Resource.newResource(base+"/../demo/target/cometd-demo-"+version+"/"),
}));
// Cometd servlet
ServletHolder cometd_holder = new ServletHolder(ContinuationCometdServlet.class);
cometd_holder.setInitParameter("timeout","200000");
cometd_holder.setInitParameter("interval","100");
cometd_holder.setInitParameter("maxInterval","100000");
cometd_holder.setInitParameter("multiFrameInterval","1500");
cometd_holder.setInitParameter("directDeliver","true");
cometd_holder.setInitParameter("logLevel","1");
cometd_holder.setInitOrder(1);
context.addServlet(cometd_holder, "/cometd/*");
ServletHolder oort_holder = new ServletHolder(OortServlet.class);
oort_holder.setInitParameter(Oort.OORT_URL,"http://localhost:"+port+"/cometd");
oort_holder.setInitParameter(Oort.OORT_CHANNELS,"/chat/**");
oort_holder.setInitParameter(Oort.OORT_CLOUD,(port==8080)?"http://localhost:"+8081+"/cometd":"http://localhost:"+8080+"/cometd");
oort_holder.setInitOrder(2);
context.addServlet(oort_holder, "/oort/*");
ServletHolder seti_holder = new ServletHolder(SetiServlet.class);
seti_holder.setInitParameter(Seti.SETI_SHARD,"S"+(port%2));
seti_holder.setInitOrder(2);
context.addServlet(seti_holder, "/seti/*");
ServletHolder demo_holder = new ServletHolder(OortDemoServlet.class);
demo_holder.setInitOrder(3);
context.getServletHandler().addServlet(demo_holder);
context.addServlet("org.mortbay.jetty.servlet.DefaultServlet", "/");
server.start();
_oort = (Oort)context.getServletContext().getAttribute(Oort.OORT_ATTRIBUTE);
assert(_oort!=null);
}