PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/sitebricks/src/main/java/com/google/sitebricks/SitebricksServletSupportModule.java

http://github.com/dhanji/sitebricks
Java | 37 lines | 27 code | 7 blank | 3 comment | 0 complexity | caf58cdaa2a94a31ae7d06b14ccf93d9 MD5 | raw file
 1package com.google.sitebricks;
 2
 3import java.util.Locale;
 4
 5import javax.servlet.http.HttpServletRequest;
 6
 7import com.google.inject.AbstractModule;
 8import com.google.inject.Provides;
 9import com.google.inject.TypeLiteral;
10import com.google.inject.servlet.RequestScoped;
11import com.google.sitebricks.headless.Request;
12
13/**
14 * @author dhanji@gmail.com (Dhanji R. Prasanna)
15 */
16class SitebricksServletSupportModule extends AbstractModule {
17  @Override
18  protected void configure() {
19      bind(new TypeLiteral<Request>(){}).toProvider(ServletRequestProvider.class).in(RequestScoped.class);
20  }
21
22  @Provides
23  @RequestScoped
24  Locale provideLocale(HttpServletRequest request) {
25    return request.getLocale();
26  }
27
28  @Override
29  public boolean equals(Object o) {
30    return o instanceof SitebricksServletSupportModule;
31  }
32
33  @Override
34  public int hashCode() {
35    return SitebricksServletSupportModule.class.hashCode();
36  }
37}