本文整理汇总了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());
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
示例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;
}
};
}
示例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();
}
示例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;
}
};
}