Context context = new Context(server, "/", Context.SESSIONS);
//context.setBaseResource(Resource.newClassPathResource("/endtoend"));
context.setResourceBase(Resource.newClassPathResource("/endtoend").getFile().getAbsolutePath());
ServletHolder defaultHolder = new ServletHolder(new DefaultServlet());
context.addServlet(defaultHolder, "/");
context.addEventListener(new GuiceServletContextListener());
Map<String, String> initParams = Maps.newHashMap();
String modules = Joiner.on(":")
.join(SampleModule.class.getName(), DefaultGuiceModule.class.getName(),
PropertiesModule.class.getName(), OAuthModule.class.getName());
initParams.put(GuiceServletContextListener.MODULES_ATTRIBUTE, modules);
context.setInitParams(initParams);
// Attach the ConcatProxyServlet - needed for rewriting
ServletHolder concatHolder = new ServletHolder(new ConcatProxyServlet());
context.addServlet(concatHolder, CONCAT_BASE);
// Attach the JS
ServletHolder jsHolder = new ServletHolder(new JsServlet());
context.addServlet(jsHolder, JS_BASE);
// Attach the metatdata handler
ServletHolder metadataHolder = new ServletHolder(new RpcServlet());
context.addServlet(metadataHolder, METADATA_BASE);
// Attach the Proxy
ServletHolder proxyHolder = new ServletHolder(new ProxyServlet());
context.addServlet(proxyHolder, PROXY_BASE);
// Attach the gadget rendering servlet
ServletHolder gadgetServletHolder = new ServletHolder(new GadgetRenderingServlet());
context.addServlet(gadgetServletHolder, GADGET_BASE);
context.addFilter(AuthenticationServletFilter.class, GADGET_BASE, 0);
// Attach the html acceleration rendering servlet
ServletHolder accelServletHolder = new ServletHolder(new HtmlAccelServlet());
context.addServlet(accelServletHolder, ACCEL_BASE);
context.addFilter(AuthenticationServletFilter.class, ACCEL_BASE, 0);
// Attach the make-request servlet
ServletHolder makeRequestHolder = new ServletHolder(new MakeRequestServlet());
context.addServlet(makeRequestHolder, MAKEREQUEST_BASE);
context.addFilter(AuthenticationServletFilter.class, MAKEREQUEST_BASE, 0);
// Attach the gadgets rpc servlet
ServletHolder gadgetsRpcServletHolder = new ServletHolder(new JsonRpcServlet());
gadgetsRpcServletHolder.setInitParameter("handlers", "org.apache.shindig.gadgets.handlers");
context.addServlet(gadgetsRpcServletHolder, GADGETS_RPC_BASE);
context.addFilter(AuthenticationServletFilter.class, GADGETS_RPC_BASE, 0);
// Attach the gadgets rest servlet
ServletHolder gadgetsRestServletHolder = new ServletHolder(new DataServiceServlet());
gadgetsRestServletHolder.setInitParameter("handlers", "org.apache.shindig.gadgets.handlers");
context.addServlet(gadgetsRestServletHolder, GADGETS_REST_BASE);
context.addFilter(AuthenticationServletFilter.class, GADGETS_REST_BASE, 0);
// Attach DataServiceServlet
ServletHolder restServletHolder = new ServletHolder(new DataServiceServlet());
restServletHolder.setInitParameter("handlers", "org.apache.shindig.social.handlers");
context.addServlet(restServletHolder, REST_BASE);
context.addFilter(AuthenticationServletFilter.class, REST_BASE, 0);
// Attach JsonRpcServlet
ServletHolder rpcServletHolder = new ServletHolder(new JsonRpcServlet());
rpcServletHolder.setInitParameter("handlers", "org.apache.shindig.social.handlers");
context.addServlet(rpcServletHolder, JSON_RPC_BASE);
context.addFilter(AuthenticationServletFilter.class, JSON_RPC_BASE, 0);
DefaultServlet defaultServlet = new DefaultServlet() {
public Resource getResource(String s) {
// Skip Gzip
if (s.endsWith(".gz")) return null;
String stripped = s.substring("/gadgets/files/".length());