Skip to content

Instantly share code, notes, and snippets.

@markchadwick
Created November 9, 2011 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markchadwick/1352886 to your computer and use it in GitHub Desktop.
Save markchadwick/1352886 to your computer and use it in GitHub Desktop.
class RoutingModule extends ServletModule {
override def configureServlets() = {
filter("*").through(classOf[vistar.adserver.servlet.LoggingFilter])
serve("/api/v1/get_ad/json").with(classOf[JsonAdRequestHandler])
serve("/api/v1/get_ad/park/*").with(classOf[ParkMediaAdRequestHandler])
}
}
package com.rightaction.servlet
class ServletConfig extends GuiceServletContextListener {
private var injector: Injector = null
override def getInjector = {
Guice.createInjector(new ProductionModule(),
new InstrumentationModule(),
new RoutingModule())
}
// You get normal ServletContextListener methods here, so context created and
// context destroyed stuff. You can hide .init() calls here for now
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<listener>
<listener-class>com.rightaction.servlet.ServletConfig</listener-class>
</listener>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment