当前位置: 首页>>代码示例>>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;未经允许,请勿转载。