Java Code Examples for com.google.inject.Scopes#isCircularProxy()
The following examples show how to use
com.google.inject.Scopes#isCircularProxy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BiomedicusScopes.java From biomedicus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected <T> T get(Key<T> key, Provider<T> unscoped) { T t = (T) objectsMap.get(key); if (t == null) { synchronized (lock) { t = (T) objectsMap.get(key); if (t == null) { t = unscoped.get(); if (!Scopes.isCircularProxy(t)) { objectsMap.put(key, t); } } } } return t; }
Example 2
Source File: SimpleScope.java From datakernel with Apache License 2.0 | 6 votes |
@Override public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) { return () -> { Map<Key<?>, Object> scopedObjects = getScopedObjectMap(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; }; }
Example 3
Source File: LinStorScope.java From linstor-server with GNU General Public License v3.0 | 5 votes |
@Override public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) { return new Provider<T>() { @SuppressWarnings("unchecked") @Override public T get() { Map<Key<?>, Object> scopedObjects = getScopedObjectMap(key); T current = null; if (scopedObjects != null) { 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)) { scopedObjects.put(key, current); } } } return current; } }; }
Example 4
Source File: InjectionStore.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; }