本文整理匯總了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;
}
};
}