當前位置: 首頁>>代碼示例>>Java>>正文


Java Injector.getProvider方法代碼示例

本文整理匯總了Java中com.google.inject.Injector.getProvider方法的典型用法代碼示例。如果您正苦於以下問題:Java Injector.getProvider方法的具體用法?Java Injector.getProvider怎麽用?Java Injector.getProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.inject.Injector的用法示例。


在下文中一共展示了Injector.getProvider方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAjaxFilters

import com.google.inject.Injector; //導入方法依賴的package包/類
private void addAjaxFilters()
{
    Injector injector = getInjector();
    for (Key<?> key : injector.getBindings().keySet())
    {
        Class<?> atype = key.getAnnotationType();
        if (atype != null && Filtering.class.isAssignableFrom(atype))
        {
            String scriptName = Filtering.class.cast(key.getAnnotation()).value();
            Provider<AjaxFilter> provider = injector.getProvider((Key<AjaxFilter>) key);
            if ("".equals(scriptName))
            {
                addAjaxFilter(new InternalAjaxFilter(provider));
            }
            else
            {
                addAjaxFilter(new InternalAjaxFilter(provider), scriptName);
            }
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:InternalAjaxFilterManager.java

示例2: addConverters

import com.google.inject.Injector; //導入方法依賴的package包/類
private void addConverters()
{
    Injector injector = getInjector();
    for (Key<?> key : injector.getBindings().keySet())
    {
        Class<?> atype = key.getAnnotationType();
        if (atype != null && Converting.class.isAssignableFrom(atype))
        {
            Converting ann = Converting.class.cast(key.getAnnotation());
            
            String match = ann.match();
            Class type = ann.type();
            Class impl = ann.impl();
            
            if ("".equals(match))
            {
                // Use the type name as a match string
                match = type.getName();
            }

            Provider<Converter> provider = null;
            Class cvtType;
            
            if (impl.equals(Void.class))
            {
                // No impl specified, so there should be a Converter
                // for this key.
                
                provider = injector.getProvider((Key<Converter>) key);
                cvtType = type;
            }
            else
            {
                // Impl class specified, so the Converter for key is
                // bogus (the injected constructor InternalConverter
                // is just to keep Guice happy); see the two-arg 
                // bindConversion method in AbstractDwrModule.
                
                try 
                {
                    // First try looking for a Converter for impl in the bindings.
                 
                    Key<Converter> ikey = Key.get(Converter.class, new ConvertingImpl(impl));
                    provider = injector.getProvider(ikey);
                }
                catch (RuntimeException e)
                {
                    // Ignore any trouble we have looking things up.
                }
                
                if (provider == null)
                {
                    // It wasn't in the bindings, so use a Provider that
                    // looks in the underlying ConverterManager.
                
                    final String implMatch = impl.getName();
                    provider = new Provider<Converter>()
                    {
                        public Converter get()
                        {
                            return getConverterByMatchString(implMatch);
                        }
                    };
                }
                
                cvtType = impl;
            }
            addConverter(match, new InternalConverter(cvtType, provider));
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:72,代碼來源:InternalConverterManager.java


注:本文中的com.google.inject.Injector.getProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。