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


Java Scopes.isCircularProxy方法代碼示例

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


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

示例1: scope

import com.google.inject.Scopes; //導入方法依賴的package包/類
@Override
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
  return () -> {
    Context context = contextRef.get();
    if (null != context) {
      @SuppressWarnings("unchecked")
      T t = (T) context.objectsMap.get(key);

      if (t == null) {
        t = unscoped.get();
        if (!Scopes.isCircularProxy(t)) {
          context.objectsMap.put(key, t);
        }
      }
      return t;
    } else {
      throw new OutOfScopeException("Not currently in a document scope");
    }
  };
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:21,代碼來源:BiomedicusScopes.java

示例2: scope

import com.google.inject.Scopes; //導入方法依賴的package包/類
public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) {
	return () -> {
		Map<Key<?>, Object> scopedObjects = getScopedObjects(key);

		@SuppressWarnings("unchecked")
		T current = (T) scopedObjects.get(key);
		if (current == null && !scopedObjects.containsKey(key)) {
			current = unscoped.get();

			// don't remember proxies; these exist only to serve circular dependencies
			if (Scopes.isCircularProxy(current)) {
				return current;
			}

			scopedObjects.put(key, current);
		}
		return current;
	};
}
 
開發者ID:stickfigure,項目名稱:gstrap,代碼行數:20,代碼來源:SimpleScope.java

示例3: provide

import com.google.inject.Scopes; //導入方法依賴的package包/類
public <T> T provide(Key<T> key, Provider<T> provider) {
    T t = (T) map.get(key);
    if(t != null) return t;

    t = provider.get();
    if(!Scopes.isCircularProxy(t)) {
        store(key, t);
    }

    return t;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:12,代碼來源:InjectionStore.java

示例4: scope

import com.google.inject.Scopes; //導入方法依賴的package包/類
@Override
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
    final String name = key.toString();
    return new Provider<T>() {

        @Override
        public T get() {
            final FacesContext facesContext = FacesContext.getCurrentInstance();
            final UIViewRoot viewRoot = facesContext.getViewRoot();

            // fallback if no view is active
            if (viewRoot == null) {
                return unscoped.get();
            }

            final Map<String, Object> viewMap = viewRoot.getViewMap(true);
            synchronized (viewMap) {
                Object obj = viewMap.get(name);
                if (obj == NullObject.INSTANCE) {
                    return null;
                }

                @SuppressWarnings("unchecked")
                T t = (T) obj;
                if (t == null) {
                    t = unscoped.get();
                    if (!Scopes.isCircularProxy(t)) {
                        viewRoot.getViewMap().put(name, t == null
                                ? NullObject.INSTANCE
                                : t);
                    }
                }
                return t;
            }
        }

        @Override
        public String toString() {
            return String.format("%s[%s]", unscoped, ViewScopeImpl.this);
        }
    };
}
 
開發者ID:skuzzle,項目名稱:guice-jsf,代碼行數:43,代碼來源:ViewScopeImpl.java


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