001package edu.pdx.cs410J.di; 002 003import com.google.inject.Singleton; 004import com.google.inject.servlet.ServletModule; 005import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher; 006 007import java.io.File; 008 009/** 010 * A Guice module that binds in all of the REST services and filters 011 */ 012public class RestModule extends ServletModule 013{ 014 @Override 015 protected void configureServlets() 016 { 017 bindRestServices(); 018 019 bind(HttpServletDispatcher.class).in( Singleton.class ); 020 serve( "/rest*" ).with( HttpServletDispatcher.class ); 021 filter( "/rest*" ).through( RestLoggingFilter.class ); 022 023 // The Logger is already bound by someone else (Resteasy, perhaps?) 024 bind(File.class).annotatedWith(DataDirectory.class).toInstance(new File(System.getProperty("user.dir"))); 025 bind(CreditCardDatabase.class).in(Singleton.class); 026 } 027 028 private void bindRestServices() 029 { 030 bind( RestfulCreditCardService.class); 031 } 032}