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