当前位置: 首页>>代码示例>>Java>>正文


Java Binding.getProvider方法代码示例

本文整理汇总了Java中com.google.inject.Binding.getProvider方法的典型用法代码示例。如果您正苦于以下问题:Java Binding.getProvider方法的具体用法?Java Binding.getProvider怎么用?Java Binding.getProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.inject.Binding的用法示例。


在下文中一共展示了Binding.getProvider方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.google.inject.Binding; //导入方法依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                log.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
            	log.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-resteasy-webapp,代码行数:25,代码来源:GuiceRestEasyFilterDispatcher.java

示例2: logCollectors

import com.google.inject.Binding; //导入方法依赖的package包/类
private void logCollectors(Injector injector) {
  List<Binding<TestEventCollector>> bindings =
      injector.findBindingsByType(TypeLiteral.get(TestEventCollector.class));
  if (LOG.isInfoEnabled()) {
    LOG.info("bound test event collectors: {}", bindings.size());
  }
  if (LOG.isDebugEnabled()) {
    for (Binding<TestEventCollector> binding : bindings) {
      Provider<TestEventCollector> provider = binding.getProvider();
      TestEventCollector collector = provider.get();
      LOG.debug("collector: '{}'", collector);
    }
  }
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:15,代码来源:ReportingRule.java

示例3: closeBinding

import com.google.inject.Binding; //导入方法依赖的package包/类
private static void closeBinding(Key<?> key, Binding<?> binding,
        Class<? extends Annotation> scopeAnnotationToClose, Closer closer,
        CloseErrors errors) {
    Provider<?> provider = binding.getProvider();

    Class<? extends Annotation> scopeAnnotation = getScopeAnnotation(binding);
    if ((scopeAnnotation != null)
            && scopeAnnotation.equals(scopeAnnotationToClose)) {
        Object value = provider.get();
        if (value != null) {
            Closers.close(key, value, closer, errors);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:Injectors.java

示例4: init

import com.google.inject.Binding; //导入方法依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
    logger.entry();
    servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);

    if (injector == null)
        injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());

    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                logger.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
                logger.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:webshooters,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例5: createInternalFactory

import com.google.inject.Binding; //导入方法依赖的package包/类
static <T> InternalFactory<Provider<T>> createInternalFactory(Binding<T> providedBinding) {
  final Provider<T> provider = providedBinding.getProvider();
  return new InternalFactory<Provider<T>>() {
    @Override
    public Provider<T> get(InternalContext context, Dependency<?> dependency, boolean linked) {
      return provider;
    }
  };
}
 
开发者ID:google,项目名称:guice,代码行数:10,代码来源:InjectorImpl.java

示例6: init

import com.google.inject.Binding; //导入方法依赖的package包/类
@Override
public void init(FilterConfig servletConfig) throws ServletException {
	logger.entry();
	servletContainerDispatcher = new ServletContainerDispatcher();
    FilterBootstrap bootstrap = new FilterBootstrap(servletConfig);
    servletContext = servletConfig.getServletContext();
    servletContainerDispatcher.init(servletContext, bootstrap, this, this);
    servletContainerDispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, servletConfig);
    
    if(injector == null)
    	injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());
    
    Registry registry = getDispatcher().getRegistry();
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();

    for (final Binding<?> binding : injector.getBindings().values()) {
        Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            Class<?> beanClass = (Class<?>) type;
            if (GetRestful.isRootResource(beanClass)) {
                ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
                logger.info("registering factory for {}", beanClass.getName());
                registry.addResourceFactory(resourceFactory);
            }

            if (beanClass.isAnnotationPresent(Provider.class)) {
            	logger.info("registering provider instance for {}", beanClass.getName());
                providerFactory.registerProviderInstance(binding.getProvider().get());
            }
        }
    }
    logger.exit();
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:34,代码来源:GuiceRestEasyFilterDispatcher.java

示例7: createInternalFactory

import com.google.inject.Binding; //导入方法依赖的package包/类
static <T> InternalFactory<Provider<T>> createInternalFactory(Binding<T> providedBinding) {
  final Provider<T> provider = providedBinding.getProvider();
  return new InternalFactory<Provider<T>>() {
    public Provider<T> get(Errors errors, InternalContext context, Dependency dependency, boolean linked) {
      return provider;
    }
  };
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:9,代码来源:InjectorImpl.java


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