当前位置: 首页>>代码示例>>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;未经允许,请勿转载。