當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestScoped類代碼示例

本文整理匯總了Java中com.google.inject.servlet.RequestScoped的典型用法代碼示例。如果您正苦於以下問題:Java RequestScoped類的具體用法?Java RequestScoped怎麽用?Java RequestScoped使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestScoped類屬於com.google.inject.servlet包,在下文中一共展示了RequestScoped類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: beforeEach

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
public void beforeEach(final ExtensionContext context) throws Exception {
	final GuicyTest testInstance = (GuicyTest)context.getTestInstance().get();
	final Module module = testInstance.module();

	final RequestScope requestScope = new RequestScope();

	final AbstractModule basicTestModule = new AbstractModule() {
		@Override
		protected void configure() {
			this.bindScope(RequestScoped.class, requestScope);
			this.bind(RequestScope.class).toInstance(requestScope);

			this.bind(HttpServletRequest.class).to(FakeHttpServletRequest.class);
			this.bind(HttpServletResponse.class).to(FakeHttpServletResponse.class);
		}
	};

	final Injector injector = Guice.createInjector(Modules.override(basicTestModule).with(module));
	context.getStore(NAMESPACE).put(Injector.class, injector);

	final ScopeRequestFilter scopeFilter = injector.getInstance(ScopeRequestFilter.class);
	injector.getInstance(Requestor.class).addFilter(scopeFilter);
}
 
開發者ID:stickfigure,項目名稱:gstrap,代碼行數:25,代碼來源:GuiceExtension.java

示例2: getCookieMap

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Provides
@CookieMap
@RequestScoped
Multimap<String,Cookie> getCookieMap(
    Provider<HttpServletRequest> httpServletRequestProvider) {
  
  Cookie[] cookies = httpServletRequestProvider.get().getCookies();
  ImmutableMultimap.Builder<String, Cookie> temp = 
    new ImmutableMultimap.Builder<String, Cookie>();
  if (cookies != null) {
    for (Cookie cookie : cookies) {
      temp.put(cookie.getName(), cookie);
    }
  }
  return temp.build();
}
 
開發者ID:zorzella,項目名稱:guiceberry,代碼行數:17,代碼來源:TestIdServerModule.java

示例3: module

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
static Module module() {
  return new AbstractModule() {
    @Override
    public void configure() {
      install(new GerritRequestModule());
      bind(RequestScopePropagator.class).to(Propagator.class);
      bindScope(RequestScoped.class, InProcessProtocol.REQUEST);
    }

    @Provides
    @RemotePeer
    SocketAddress getSocketAddress() {
      // TODO(dborowitz): Could potentially fake this with thread ID or
      // something.
      throw new OutOfScopeException("No remote peer in acceptance tests");
    }
  };
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:19,代碼來源:InProcessProtocol.java

示例4: module

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
public static Module module() {
  return new CacheModule() {
    @Override
    protected void configure() {
      persist(WebSessionManager.CACHE_NAME, String.class, Val.class)
          .maximumWeight(1024) // reasonable default for many sites
          .expireAfterWrite(
              CacheBasedWebSession.MAX_AGE_MINUTES,
              MINUTES) // expire sessions if they are inactive
      ;
      install(new FactoryModuleBuilder().build(WebSessionManagerFactory.class));
      DynamicItem.itemOf(binder(), WebSession.class);
      DynamicItem.bind(binder(), WebSession.class)
          .to(H2CacheBasedWebSession.class)
          .in(RequestScoped.class);
    }
  };
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:19,代碼來源:H2CacheBasedWebSession.java

示例5: provideAppengineUser

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Provides @RequestScoped
User provideAppengineUser(UserService userService) {
  User user = userService.getCurrentUser();
  if (user == null) {
    throw new ProvisionException("Not logged in");
  }
  return user;
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:9,代碼來源:WalkaroundServletModule.java

示例6: provideWaveUrlBase

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Provides @RequestScoped @Named("wave url base")
String provideWaveUrlBase(HttpServletRequest req) throws MalformedURLException {
  URL requestUrl = new URL(req.getRequestURL().toString());
  String portString = requestUrl.getPort() == -1 ? "" : ":" + requestUrl.getPort();
  String waveUrlBase = requestUrl.getProtocol() + "://" + requestUrl.getHost() + portString + "/";
  log.info("requestUrl=" + requestUrl + ", waveUrlBase=" + waveUrlBase);
  return waveUrlBase;
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:9,代碼來源:WalkaroundServletModule.java

示例7: get

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Provides
@RequestScoped
TestId get(@CookieMap Multimap<String,Cookie> cookieMap) {
  Collection<Cookie> temp = cookieMap.get(TestId.COOKIE_NAME);
  if (temp.size() > 1) {
    throw new IllegalStateException(String.format(
        "There's more than one Cookie named '%s'.", TestId.COOKIE_NAME));
  } else if (temp.size() == 0) {
    return null;
  }
  return new TestId(temp.iterator().next());
}
 
開發者ID:zorzella,項目名稱:guiceberry,代碼行數:13,代碼來源:TestIdServerModule.java

示例8: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure() {
  bind(RequestScopePropagator.class).to(GuiceRequestScopePropagator.class);
  bind(HttpRequestContext.class);

  installAuthModule();
  if (options.enableMasterFeatures()) {
    install(new UrlModule(options, authConfig));
    install(new UiRpcModule());
  }
  install(new GerritRequestModule());
  install(new GitOverHttpServlet.Module(options.enableMasterFeatures()));

  if (gitwebCgiConfig.getGitwebCgi() != null) {
    install(new GitwebModule());
  }

  install(new AsyncReceiveCommits.Module());

  bind(SocketAddress.class)
      .annotatedWith(RemotePeer.class)
      .toProvider(HttpRemotePeerProvider.class)
      .in(RequestScoped.class);

  bind(ProxyProperties.class).toProvider(ProxyPropertiesProvider.class);

  listener().toInstance(registerInParentInjectors());

  install(UniversalWebLoginFilter.module());
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:31,代碼來源:WebModule.java

示例9: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure() {
  bind(RequestCleanup.class).in(RequestScoped.class);
  bind(RequestScopedReviewDbProvider.class);
  bind(IdentifiedUser.RequestFactory.class).in(SINGLETON);

  bind(PerRequestProjectControlCache.class).in(RequestScoped.class);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:9,代碼來源:GerritRequestModule.java

示例10: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure()
{
	bind(Gson.class).toInstance(new GsonBuilder().setPrettyPrinting().create());
	bind(LabelJsonProvider.class).to(LabelJsonFromFileProvider.class).in(Scopes.SINGLETON);
	bind(GlobalConfigurationJsonStore.class).in(Scopes.SINGLETON);
	bind(IdentityConfJsonStore.class).in(Scopes.SINGLETON);
	bind(UserPermissionsJsonStore.class).in(Scopes.SINGLETON);
	bind(ExperimentalConfJsonStore.class).in(Scopes.SINGLETON);
	bind(RequestBodyReader.class).in(RequestScoped.class);
}
 
開發者ID:codeine-cd,項目名稱:codeine,代碼行數:12,代碼來源:CodeineGeneralModule.java

示例11: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure() {
  
  Provider<Injector> injector = getProvider(Injector.class);
  bind(ServiceLocator.class).toProvider(new ServiceLocatorProvider(injector, locator))
    .in(Singleton.class);
  
  Provider<ServiceLocator> provider = getProvider(ServiceLocator.class);
  
  bind(Application.class)
    .toProvider(new JerseyProvider<>(provider, Application.class));
  
  bind(Providers.class)
    .toProvider(new JerseyProvider<>(provider, Providers.class));
  
  bind(UriInfo.class)
    .toProvider(new JerseyProvider<>(provider, UriInfo.class))
    .in(RequestScoped.class);
  
  bind(HttpHeaders.class)
    .toProvider(new JerseyProvider<>(provider, HttpHeaders.class))
    .in(RequestScoped.class);
  
  bind(SecurityContext.class)
    .toProvider(new JerseyProvider<>(provider, SecurityContext.class))
    .in(RequestScoped.class);
  
  bind(Request.class)
    .toProvider(new JerseyProvider<>(provider, Request.class))
    .in(RequestScoped.class);
}
 
開發者ID:Squarespace,項目名稱:jersey2-guice,代碼行數:32,代碼來源:JerseyGuiceModule.java

示例12: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure() {
  bindScope(RequestScoped.class, ServletScopes.REQUEST);
  for (Binding binding : bindings) {
    binding.bind();
  }
}
 
開發者ID:signal,項目名稱:agathon,代碼行數:8,代碼來源:ModuleTester.java

示例13: provideAppengineUser

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Provides
@RequestScoped
User provideAppengineUser(UserService userService) {
  User user = userService.getCurrentUser();
  if (user == null) {
    throw new ProvisionException("Not logged in");
  }
  return user;
}
 
開發者ID:larrytin,項目名稱:realtime-server-appengine,代碼行數:10,代碼來源:RealtimeServletModule.java

示例14: configure

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
@Override
protected void configure() {
  configureHandlers();

  bindScope(RequestScoped.class, requestScope);
  bind(RequestScope.class).toInstance(requestScope);

  bind(new Key<List<RequestMatcher>>() {}).toInstance(matchers.build());
  bind(Servlet.class).to(RequestHandlerServlet.class).in(Singleton.class);

  bind(GatewayRequestHandler.Factory.class).toProvider(
      FactoryProvider.newFactory(
          GatewayRequestHandler.Factory.class, GatewayRequestHandler.class));
  bind(GatewayConfiguration.class).in(Singleton.class);
}
 
開發者ID:BladeRunnerJS,項目名稱:brjs-JsTestDriver,代碼行數:16,代碼來源:RequestHandlersModule.java

示例15: serve

import com.google.inject.servlet.RequestScoped; //導入依賴的package包/類
protected void serve(HttpMethod method, String pattern, Class<? extends RequestHandler> withHttpHandler) {
  logger.debug("Registering {} on {} to {}", new Object[]{method, pattern, withHttpHandler});
  RequestMatcher matcher = new RequestMatcher(method, pattern);
  matchers.add(matcher);
  MapBinder.newMapBinder(binder(), RequestMatcher.class, RequestHandler.class)
      .addBinding(matcher).to(withHttpHandler).in(RequestScoped.class);
}
 
開發者ID:BladeRunnerJS,項目名稱:brjs-JsTestDriver,代碼行數:8,代碼來源:RequestHandlersModule.java


注:本文中的com.google.inject.servlet.RequestScoped類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。