• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UniqueAnnotations类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.inject.internal.UniqueAnnotations的典型用法代码示例。如果您正苦于以下问题:Java UniqueAnnotations类的具体用法?Java UniqueAnnotations怎么用?Java UniqueAnnotations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UniqueAnnotations类属于com.google.inject.internal包,在下文中一共展示了UniqueAnnotations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
public static void main(String[] args) {
    LifeManager manager = new LifeManager();
    manager.add(Guice.createInjector(new PrivateModule() {
        @Override
        protected void configure() {
            bind(Service.class).annotatedWith(Names.named("1"))
                    .to(ServiceImpl.class)
                    .in(Scopes.SINGLETON);
            expose(Service.class).annotatedWith(Names.named("1"));
            bind(ImplWorker.class).toInstance(new ImplWorker() {
                @Override
                public void work() {
                    System.out.println("work 1 done");
                }
            });
        }
    }, new PrivateModule() {
        @Override
        protected void configure() {
            bind(Service.class).annotatedWith(Names.named("2"))
                    .to(ServiceImpl.class)
                    .in(Scopes.SINGLETON);
            expose(Service.class).annotatedWith(Names.named("2"));

            bind(ImplWorker.class).toInstance(new ImplWorker() {
                @Override
                public void work() {
                    System.out.println("work 2 done");
                }
            });
        }
    }, new AbstractModule() {
        @Override
        protected void configure() {
            final Annotation id = UniqueAnnotations.create();
            bind(Listener.class).annotatedWith(id).to(Client.class).asEagerSingleton();
        }
    }));
    manager.start();
}
 
开发者ID:BruceZu,项目名称:KeepTry,代码行数:41,代码来源:Client.java


示例2: configure

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@Override
protected void configure() {
  bind(DestinationFactory.class).in(Scopes.SINGLETON);
  bind(ReplicationQueue.class).in(Scopes.SINGLETON);

  DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(ReplicationQueue.class);
  DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(ReplicationQueue.class);
  DynamicSet.bind(binder(), ProjectDeletedListener.class).to(ReplicationQueue.class);
  DynamicSet.bind(binder(), HeadUpdatedListener.class).to(ReplicationQueue.class);

  bind(OnStartStop.class).in(Scopes.SINGLETON);
  bind(LifecycleListener.class).annotatedWith(UniqueAnnotations.create()).to(OnStartStop.class);
  bind(LifecycleListener.class)
      .annotatedWith(UniqueAnnotations.create())
      .to(ReplicationLogFile.class);
  bind(CredentialsFactory.class)
      .to(AutoReloadSecureCredentialsFactoryDecorator.class)
      .in(Scopes.SINGLETON);
  bind(CapabilityDefinition.class)
      .annotatedWith(Exports.named(START_REPLICATION))
      .to(StartReplicationCapability.class);

  install(new FactoryModuleBuilder().build(PushAll.Factory.class));
  install(new FactoryModuleBuilder().build(RemoteSiteUser.Factory.class));

  bind(ReplicationConfig.class).to(AutoReloadConfigDecorator.class);
  bind(ReplicationStateListener.class).to(ReplicationStateLogger.class);

  EventTypes.register(RefReplicatedEvent.TYPE, RefReplicatedEvent.class);
  EventTypes.register(RefReplicationDoneEvent.TYPE, RefReplicationDoneEvent.class);
  EventTypes.register(ReplicationScheduledEvent.TYPE, ReplicationScheduledEvent.class);
  bind(SshSessionFactory.class).toProvider(ReplicationSshSessionFactoryProvider.class);
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:34,代码来源:ReplicationModule.java


示例3: configure

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@Override
protected final void configure()
{
    internalConfigure();
    configureServlets();

    for ( FilterDefinition filterDefinition : filterDefinitions )
    {
        bind(FilterDefinition.class).annotatedWith(UniqueAnnotations.create()).toInstance(filterDefinition);
    }
    for ( ServletDefinition servletDefinition : servletDefinitions )
    {
        bind(ServletDefinition.class).annotatedWith(UniqueAnnotations.create()).toInstance(servletDefinition);
    }
}
 
开发者ID:soabase,项目名称:soabase,代码行数:16,代码来源:JerseyMultiGuiceModule.java


示例4: visit

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@Override
public <T> Void visit(Binding<T> binding) {
  final Key<T> key = binding.getKey();

  if (!keysToIntercept.contains(key)) {
    return super.visit(binding);
  }

  binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, Void>() {
    @Override
    public Void visit(UntargettedBinding<? extends T> untargettedBinding) {
      binder.addError("Cannot intercept bare binding of %s. " +
          		"You may only intercept bindings that bind a class to something.", key);
      return null;
    }
  });

  Key<T> anonymousKey = Key.get(key.getTypeLiteral(), UniqueAnnotations.create());
  binder.bind(key).toProvider(new InterceptingProvider<T>(key, binder.getProvider(anonymousKey)));

  ScopedBindingBuilder scopedBindingBuilder = bindKeyToTarget(binding, binder, anonymousKey);

  // we scope the user's provider, not the interceptor. This is dangerous,
  // but convenient. It means that although the user's provider will live
  // in its proper scope, the intereptor gets invoked without a scope
  applyScoping(binding, scopedBindingBuilder);

  keysIntercepted.add(key);
  return null;
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:31,代码来源:InterceptingBindingsBuilder.java


示例5: visit

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@Override
public <T> Void visit(Binding<T> binding) {
  final Key<T> key = binding.getKey();

  if (!keysToIntercept.contains(key)) {
    return super.visit(binding);
  }

  binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, Void>() {
    @Override
    public Void visit(UntargettedBinding<? extends T> untargettedBinding) {
      binder.addError("Cannot intercept bare binding of %s. " +
          		"You may only intercept bindings that bind a class to something.", key);
      return null;
    }
  });

  Key<T> anonymousKey = Key.get(key.getTypeLiteral(), UniqueAnnotations.create());
  binder.bind(key).toProvider(new InterceptingProvider<T>(key, binder.getProvider(anonymousKey)));

  ScopedBindingBuilder scopedBindingBuilder = bindKeyToTarget(binding, binder, anonymousKey);

  // we scope the user's provider, not the interceptor. This is dangerous,
  // but convenient. It means that although the user's provider will live
  // in its proper scope, the interceptor gets invoked without a scope
  applyScoping(binding, scopedBindingBuilder);

  keysIntercepted.add(key);
  return null;
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:31,代码来源:InterceptingBindingsBuilder.java


示例6: bindServlet

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
protected <T extends HttpServlet> ServletBindingBuilder bindServlet(Class<T> servlet)
{
    Annotation annotation = UniqueAnnotations.create();
    Key<T> servletKey = Key.get(servlet, UniqueAnnotations.create());
    binder().bind(servletKey).to(servlet).in(Scopes.SINGLETON);
    return new ServletBindingBuilder(binder(), servletKey);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:8,代码来源:GuiceRsModule.java


示例7: addResources

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addResources(Class<?>... annotatedClass)
{
    for (Class<?> clazz : annotatedClass) {
        Key<Object> key = Key.get((Class<Object>) clazz, UniqueAnnotations.create());
        binder.bind(key).to(clazz);
        initializer.addResource(key, clazz);
    }
    return this;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:11,代码来源:GuiceRsModule.java


示例8: addProvider

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addProvider(Class<?> annotatedClass)
{
    Key<Object> key = Key.get((Class<Object>) annotatedClass, UniqueAnnotations.create());
    binder.bind(key).to(annotatedClass);
    initializer.addProvider(key);
    return this;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:9,代码来源:GuiceRsModule.java


示例9: addProviderInstance

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ApplicationBindingBuilder addProviderInstance(Object object)
{
    Key<Object> key = Key.get((Class<Object>) object.getClass(), UniqueAnnotations.create());
    binder.bind(key).toInstance(object);
    initializer.addProvider(key);
    return this;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:9,代码来源:GuiceRsModule.java


示例10: rpc

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
protected void rpc(String name, Class<? extends RemoteJsonService> clazz) {
  final Key<GerritJsonServlet> srv = Key.get(GerritJsonServlet.class, UniqueAnnotations.create());
  final GerritJsonServletProvider provider = new GerritJsonServletProvider(clazz);
  bind(clazz);
  serve(prefix + name).with(srv);
  bind(srv).toProvider(provider).in(Scopes.SINGLETON);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:RpcServletModule.java


示例11: key

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private Key<HttpServlet> key(HttpServlet servlet) {
  final Key<HttpServlet> srv = Key.get(HttpServlet.class, UniqueAnnotations.create());
  bind(srv)
      .toProvider(
          new Provider<HttpServlet>() {
            @Override
            public HttpServlet get() {
              return servlet;
            }
          })
      .in(SINGLETON);
  return srv;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:UrlModule.java


示例12: module

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
public static ServletModule module() {
  return new ServletModule() {
    @Override
    protected void configureServlets() {
      DynamicSet.setOf(binder(), AllRequestFilter.class);
      filter("/*").through(FilterProxy.class);

      bind(StopPluginListener.class)
          .annotatedWith(UniqueAnnotations.create())
          .to(FilterProxy.class);
    }
  };
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:AllRequestFilter.java


示例13: configureServlets

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
@Override
protected void configureServlets() {
  bind(HttpPluginServlet.class);
  serveRegex("^/(?:a/)?plugins/(.*)?$").with(HttpPluginServlet.class);

  bind(LfsPluginServlet.class);
  serveRegex(LfsDefinitions.LFS_URL_REGEX).with(LfsPluginServlet.class);

  bind(StartPluginListener.class)
      .annotatedWith(UniqueAnnotations.create())
      .to(HttpPluginServlet.class);

  bind(ReloadPluginListener.class)
      .annotatedWith(UniqueAnnotations.create())
      .to(HttpPluginServlet.class);

  bind(StartPluginListener.class)
      .annotatedWith(UniqueAnnotations.create())
      .to(LfsPluginServlet.class);

  bind(ReloadPluginListener.class)
      .annotatedWith(UniqueAnnotations.create())
      .to(LfsPluginServlet.class);

  bind(ModuleGenerator.class).to(HttpAutoRegisterModuleGenerator.class);

  install(
      new CacheModule() {
        @Override
        protected void configure() {
          cache(PLUGIN_RESOURCES, ResourceKey.class, Resource.class)
              .maximumWeight(2 << 20)
              .weigher(ResourceWeigher.class);
        }
      });

  DynamicMap.mapOf(binder(), DynamicOptions.DynamicBean.class);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:39,代码来源:HttpPluginModule.java


示例14: calculateBindAnnotation

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
public static Annotation calculateBindAnnotation(Class<Object> impl) {
  Annotation n = impl.getAnnotation(Export.class);
  if (n == null) {
    n = impl.getAnnotation(javax.inject.Named.class);
  }
  if (n == null) {
    n = impl.getAnnotation(com.google.inject.name.Named.class);
  }
  if (n == null) {
    n = UniqueAnnotations.create();
  }
  return n;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:AutoRegisterUtil.java


示例15: with

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private void with(
    Key<? extends HttpServlet> servletKey,
    Map<String, String> initParams,
    HttpServlet servletInstance) {
  for (UriPatternMatcher pattern : uriPatterns) {
    binder
        .bind(Key.get(ServletDefinition.class, UniqueAnnotations.create()))
        .toProvider(new ServletDefinition(servletKey, pattern, initParams, servletInstance));
  }
}
 
开发者ID:google,项目名称:guice,代码行数:11,代码来源:ServletsModuleBuilder.java


示例16: through

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private void through(
    Key<? extends Filter> filterKey, Map<String, String> initParams, Filter filterInstance) {
  for (UriPatternMatcher pattern : uriPatterns) {
    binder
        .bind(FilterDefinition.class)
        .annotatedWith(UniqueAnnotations.create())
        .toProvider(new FilterDefinition(filterKey, pattern, initParams, filterInstance));
  }
}
 
开发者ID:google,项目名称:guice,代码行数:10,代码来源:FiltersModuleBuilder.java


示例17: processSetBinding

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private static <T> Key<T> processSetBinding(Binder binder, Key<T> key) {
  Annotation annotation = key.getAnnotation();
  Multibinder<T> setBinder =
      (annotation != null)
          ? Multibinder.newSetBinder(binder, key.getTypeLiteral(), annotation)
          : Multibinder.newSetBinder(binder, key.getTypeLiteral());
  Key<T> newKey = Key.get(key.getTypeLiteral(), UniqueAnnotations.create());
  setBinder.addBinding().to(newKey);
  return newKey;
}
 
开发者ID:google,项目名称:guice,代码行数:11,代码来源:DaggerMethodScanner.java


示例18: toProviderMethod

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
ScopedBindingBuilder toProviderMethod(CheckedProviderMethod<?> target) {
  Key<CheckedProviderMethod<?>> targetKey =
      Key.get(CHECKED_PROVIDER_METHOD_TYPE, UniqueAnnotations.create());
  binder.bind(targetKey).toInstance(target);

  return toInternal(targetKey);
}
 
开发者ID:google,项目名称:guice,代码行数:8,代码来源:ThrowingProviderBinder.java


示例19: with

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private void with(Key<? extends HttpServlet> servletKey, Map<String, String> initParams,
    HttpServlet servletInstance) {
  for (String pattern : uriPatterns) {
    // Ensure two servlets aren't bound to the same pattern.
    if (!servletUris.add(pattern)) {
      binder.addError("More than one servlet was mapped to the same URI pattern: " + pattern);
    } else {
      binder.bind(Key.get(ServletDefinition.class, UniqueAnnotations.create())).toProvider(
          new ServletDefinition(pattern, servletKey, UriPatternType
              .get(uriPatternType, pattern), initParams, servletInstance));
    }
  }
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:14,代码来源:ServletsModuleBuilder.java


示例20: through

import com.google.inject.internal.UniqueAnnotations; //导入依赖的package包/类
private void through(Key<? extends Filter> filterKey,
    Map<String, String> initParams,
    Filter filterInstance) {
  for (String pattern : uriPatterns) {
    binder.bind(FilterDefinition.class).annotatedWith(UniqueAnnotations.create()).toProvider(
        new FilterDefinition(pattern, filterKey, UriPatternType.get(uriPatternType, pattern),
            initParams, filterInstance));
  }
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:10,代码来源:FiltersModuleBuilder.java



注:本文中的com.google.inject.internal.UniqueAnnotations类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BasicFormattedTextFieldUI类代码示例发布时间:2022-05-22
下一篇:
Java ClientDatanodeProtocolTranslatorPB类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap