The [Old]ReferencingObjectCache
classes have not been ported.
They have been fully rewritten as the Cache
class with a different design.
This commit moves the findPool
cache from ReferencingObjectCache
to this class.
The same change applies naturally to SIS because Cache
is a general-purpose class with nothing
specific to the referencing module. Consequently the same move needs to be apply in SIS too, independently
to this commit.
Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r26023:26059 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/ThreadedAuthorityFactory.java
Revision 26023 | Revision 26059 |
---|---|
import java.util.Iterator; import java.util.Collection; import java.util.Collections; import java.util.logging.LogRecord; import java.util.logging.Level; import javax.units.Unit; |
import java.util.Iterator;
import java.util.Collection;
import java.util.Collections;
import java.util.WeakHashMap;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import javax.units.Unit; |
/**
* The cache for referencing objects.
*/
private final ReferencingObjectCache objectCache;
/**
* Constructs an instance wrapping the specified factory with a default number
* of entries to keep by strong reference.
* <p> |
/** * The cache for referencing objects. */ private final OldReferencingObjectCache objectCache; /** * The pool of objects identified by {@link find}. */ private final Map findPool = new WeakHashMap(); /** * Constructs an instance wrapping the specified factory with a default number * of entries to keep by strong reference. * <p> |
factory = ((ThreadedAuthorityFactory) factory).backingStore;
}
this.backingStore = factory;
this.objectCache = new DefaultReferencingObjectCache(maxStrongReferences);
completeHints();
} |
factory = ((ThreadedAuthorityFactory) factory).backingStore;
}
this.backingStore = factory;
this.objectCache = new OldReferencingObjectCache(maxStrongReferences);
completeHints();
} |
*/
ThreadedAuthorityFactory(final int priority, final int maxStrongReferences) {
super(priority);
this.objectCache = new DefaultReferencingObjectCache(maxStrongReferences);
// completeHints() will be invoked by DeferredAuthorityFactory.getBackingStore()
} |
*/
ThreadedAuthorityFactory(final int priority, final int maxStrongReferences) {
super(priority);
this.objectCache = new OldReferencingObjectCache(maxStrongReferences);
// completeHints() will be invoked by DeferredAuthorityFactory.getBackingStore()
} |
* waste of CPU.
*/
IdentifiedObject candidate;
final Map findPool = objectCache.findPool();
synchronized (findPool) {
candidate = (IdentifiedObject) findPool.get(object);
} |
* waste of CPU. */ IdentifiedObject candidate; synchronized (findPool) { candidate = (IdentifiedObject) findPool.get(object); } |
//@Override
public String findIdentifier(final IdentifiedObject object) throws FactoryException {
IdentifiedObject candidate;
final Map findPool = objectCache.findPool();
synchronized (findPool) {
candidate = (IdentifiedObject) findPool.get(object);
} |
//@Override public String findIdentifier(final IdentifiedObject object) throws FactoryException { IdentifiedObject candidate; synchronized (findPool) { candidate = (IdentifiedObject) findPool.get(object); } |