com.twitter.common.application.http
Class Registration

java.lang.Object
  extended by com.twitter.common.application.http.Registration

public final class Registration
extends Object

Utility class for registering HTTP servlets and assets.


Method Summary
static void registerHttpAsset(Binder binder, String servedPath, Class<?> contextClass, String assetRelativePath, String assetType, boolean silent)
          Registers a binding for a classpath resource to be served by the HTTP server, using a resource path relative to a class.
static void registerHttpAsset(Binder binder, String servedPath, URL asset, String assetType, boolean silent)
          Registers a binding for a URL asset to be served by the HTTP server, with an optional entity tag for cache control.
static void registerServlet(Binder binder, HttpServletConfig config)
          Registers a binding for an HttpServlet to be exported at a specified path.
static void registerServlet(Binder binder, String path, Class<? extends javax.servlet.http.HttpServlet> servletClass, boolean silent)
          Equivalent to registerServlet(binder, new HttpServletConfig(path, servletClass, silent)).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerServlet

public static void registerServlet(Binder binder,
                                   String path,
                                   Class<? extends javax.servlet.http.HttpServlet> servletClass,
                                   boolean silent)
Equivalent to registerServlet(binder, new HttpServletConfig(path, servletClass, silent)).


registerServlet

public static void registerServlet(Binder binder,
                                   HttpServletConfig config)
Registers a binding for an HttpServlet to be exported at a specified path.

Parameters:
binder - a guice binder to register the handler with
config - a servlet mounting specification

registerHttpAsset

public static void registerHttpAsset(Binder binder,
                                     String servedPath,
                                     URL asset,
                                     String assetType,
                                     boolean silent)
Registers a binding for a URL asset to be served by the HTTP server, with an optional entity tag for cache control.

Parameters:
binder - a guice binder to register the handler with
servedPath - Path to serve the resource from in the HTTP server.
asset - Resource to be served.
assetType - MIME-type for the asset.
silent - Whether the server should hide this asset on the index page.

registerHttpAsset

public static void registerHttpAsset(Binder binder,
                                     String servedPath,
                                     Class<?> contextClass,
                                     String assetRelativePath,
                                     String assetType,
                                     boolean silent)
Registers a binding for a classpath resource to be served by the HTTP server, using a resource path relative to a class.

Parameters:
binder - a guice binder to register the handler with
servedPath - Path to serve the asset from in the HTTP server.
contextClass - Context class for defining the relative path to the asset.
assetRelativePath - Path to the served asset, relative to contextClass.
assetType - MIME-type for the asset.
silent - Whether the server should hide this asset on the index page.