Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This code is placed in the public domain by its author, Tim Peierls.
- */
- package com.example.server;
- import com.google.common.collect.ImmutableMap;
- import com.google.inject.servlet.ServletModule;
- /**
- * Configure the main servlet to use MainComponent and to handle
- * context path correctly.
- * <p>
- * We make ServerServlet believe we are supplying the component via
- * init-param instead of by overriding it. If we don't do this,
- * ServerServlet won't know which "mode" we're running in.
- * See Restlet's ServerServlet javadocs for more info.
- * </p><p>
- * We set autoWire true to ensure that the servlet context path is
- * included. This means that in, for example, a foobar.war
- * file deployed at context path /foobar, the /foobar
- * part of the URI will be consumed by the time the Restlet Component
- * is handling the request. Without this setting, we'd have to deal
- * with a /foobar prefix to every request.
- * </p>
- */
- public class MainServletModule extends ServletModule {
- @Override protected void configureServlets() {
- serve("/*").with(MainServlet.class, ImmutableMap.<String, String>of(
- "org.restlet.component", MainComponent.class.getName(),
- "org.restlet.autoWire", "true"
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement