mirror of https://github.com/apache/openjpa.git
[OPENJPA-2748] commons-collection is updated to most recent version
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1841941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f399f912cf
commit
4709f38ba2
|
@ -5,3 +5,5 @@ target
|
|||
velocity.log
|
||||
derby.log
|
||||
*.iml
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-el_1.0_spec/1.0.1</bundle>
|
||||
<bundle dependency="true">mvn:org.apache.commons/commons-pool2/2.6.0</bundle>
|
||||
<bundle dependency="true">mvn:org.apache.commons/commons-dbcp2/2.5.0</bundle>
|
||||
<bundle dependency="true">mvn:commons-collections/commons-collections/3.2.2</bundle>
|
||||
<bundle dependency="true">mvn:commons-collections/commons-collections4/4.3</bundle>
|
||||
<bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.serp/1.14.1_1</bundle>
|
||||
<bundle dependency="true">mvn:org.apache.xbean/xbean-asm6-shaded/4.9</bundle>
|
||||
<bundle>mvn:org.apache.openjpa/openjpa/${project.version}</bundle>
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
|
||||
import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
|
||||
import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
|
||||
|
@ -84,7 +85,7 @@ public class InformixDictionary
|
|||
protected boolean useJCC = false;
|
||||
// weak set of connections we've already executed lock mode sql on
|
||||
private final Collection _seenConnections = Collections.synchronizedSet(
|
||||
new ReferenceHashSet(ReferenceHashSet.WEAK));
|
||||
new ReferenceHashSet(ReferenceStrength.WEAK));
|
||||
|
||||
public boolean disableRetainUpdateLocksSQL=false;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.util.SortedMap;
|
|||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.collections.iterators.EmptyIterator;
|
||||
import org.apache.commons.collections4.iterators.EmptyIterator;
|
||||
import org.apache.openjpa.lib.util.StringUtil;
|
||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||
import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.event.RemoteCommitEvent;
|
||||
import org.apache.openjpa.event.RemoteCommitListener;
|
||||
|
@ -397,7 +398,7 @@ public abstract class AbstractQueryCache
|
|||
* the only reference is held by the list of expiration listeners.
|
||||
*/
|
||||
protected Collection newListenerCollection() {
|
||||
return new ConcurrentReferenceHashSet (ConcurrentReferenceHashSet.WEAK);
|
||||
return new ConcurrentReferenceHashSet(ReferenceStrength.WEAK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -493,12 +494,12 @@ public abstract class AbstractQueryCache
|
|||
|
||||
private void initializeMaps() {
|
||||
ConcurrentReferenceHashMap statsMap =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
statsMap.setMaxSize(FIXED_SIZE);
|
||||
stats = statsMap;
|
||||
|
||||
ConcurrentReferenceHashMap aStatsMap =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
aStatsMap.setMaxSize(FIXED_SIZE);
|
||||
astats = aStatsMap;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.openjpa.datacache.AbstractQueryCache.EvictPolicy;
|
||||
import org.apache.openjpa.kernel.FetchConfiguration;
|
||||
import org.apache.openjpa.kernel.LockLevels;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
|
||||
|
@ -40,14 +41,14 @@ public class PCRegistry {
|
|||
private static final Localizer _loc = Localizer.forPackage(PCRegistry.class);
|
||||
|
||||
// map of persistent classes to meta structures; weak so the VM can GC classes
|
||||
private static final Map<Class<?>,Meta> _metas = new ConcurrentReferenceHashMap(ReferenceMap.WEAK,
|
||||
ReferenceMap.HARD);
|
||||
private static final Map<Class<?>,Meta> _metas = new ConcurrentReferenceHashMap(ReferenceStrength.WEAK,
|
||||
ReferenceStrength.HARD);
|
||||
|
||||
// register class listeners
|
||||
// Weak reference prevents OutOfMemeoryError as described in OPENJPA-2042
|
||||
private static final Collection<RegisterClassListener> _listeners =
|
||||
new ConcurrentReferenceHashSet<RegisterClassListener>(
|
||||
ConcurrentReferenceHashSet.WEAK);
|
||||
ReferenceStrength.WEAK);
|
||||
|
||||
/**
|
||||
* Register a {@link RegisterClassListener}.
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.openjpa.lib.util.StringUtil;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.J2DoPrivHelper;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
|
@ -52,11 +53,11 @@ public class Reflection {
|
|||
|
||||
// Weak HashMap caches of getter/setter/beanProperty methods
|
||||
private static Map<Class<?>, Map<String, Method>> getterMethodCache =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
private static Map<Class<?>, Map<String, Method>> setterMethodCache =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
private static Map<Class<?>, Set<String>> beanPropertiesNameCache =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
|
||||
private static Method getGetterMethod(Class<?> cls, String prop) {
|
||||
Method rtnMethod = null;
|
||||
|
@ -71,8 +72,8 @@ public class Reflection {
|
|||
Method method) {
|
||||
Map<String, Method> clsMap = getterMethodCache.get(cls);
|
||||
if (clsMap == null) {
|
||||
clsMap = new ConcurrentReferenceHashMap(ReferenceMap.HARD,
|
||||
ReferenceMap.WEAK);
|
||||
clsMap = new ConcurrentReferenceHashMap(ReferenceStrength.HARD,
|
||||
ReferenceStrength.WEAK);
|
||||
getterMethodCache.put(cls, clsMap);
|
||||
}
|
||||
clsMap.put(prop, method);
|
||||
|
@ -91,8 +92,8 @@ public class Reflection {
|
|||
Method method) {
|
||||
Map<String, Method> clsMap = setterMethodCache.get(cls);
|
||||
if (clsMap == null) {
|
||||
clsMap = new ConcurrentReferenceHashMap(ReferenceMap.HARD,
|
||||
ReferenceMap.WEAK);
|
||||
clsMap = new ConcurrentReferenceHashMap(ReferenceStrength.HARD,
|
||||
ReferenceStrength.WEAK);
|
||||
setterMethodCache.put(cls, clsMap);
|
||||
}
|
||||
clsMap.put(prop, method);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.openjpa.event;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
|
||||
|
||||
/**
|
||||
|
@ -37,8 +38,7 @@ import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
|
|||
public class SingleJVMRemoteCommitProvider
|
||||
extends AbstractRemoteCommitProvider {
|
||||
|
||||
private static Set s_providers = new ConcurrentReferenceHashSet(
|
||||
ConcurrentReferenceHashSet.HARD);
|
||||
private static Set s_providers = new ConcurrentReferenceHashSet(ReferenceStrength.HARD);
|
||||
|
||||
public SingleJVMRemoteCommitProvider() {
|
||||
s_providers.add(this);
|
||||
|
|
|
@ -39,7 +39,8 @@ import javax.transaction.Synchronization;
|
|||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.commons.collections4.set.MapBackedSet;
|
||||
import org.apache.openjpa.lib.util.StringUtil;
|
||||
import org.apache.openjpa.audit.Auditor;
|
||||
import org.apache.openjpa.conf.BrokerValue;
|
||||
|
@ -489,9 +490,9 @@ public abstract class AbstractBrokerFactory
|
|||
bv = (BrokerValue) _conf.getValue(BrokerValue.KEY);
|
||||
|
||||
if (FinalizingBrokerImpl.class.isAssignableFrom(bv.getTemplateBrokerType(_conf))) {
|
||||
return MapBackedSet.decorate(new ConcurrentHashMap(), new Object() { });
|
||||
return MapBackedSet.mapBackedSet(new ConcurrentHashMap(), new Object() { });
|
||||
} else {
|
||||
return new ConcurrentReferenceHashSet<Broker>(ConcurrentReferenceHashSet.WEAK);
|
||||
return new ConcurrentReferenceHashSet<Broker>(ReferenceStrength.WEAK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -829,7 +830,7 @@ public abstract class AbstractBrokerFactory
|
|||
*/
|
||||
private Collection<ClassLoader> getPcClassLoaders() {
|
||||
if (_pcClassLoaders == null)
|
||||
_pcClassLoaders = new ConcurrentReferenceHashSet<ClassLoader>(ConcurrentReferenceHashSet.WEAK);
|
||||
_pcClassLoaders = new ConcurrentReferenceHashSet<ClassLoader>(ReferenceStrength.WEAK);
|
||||
|
||||
return _pcClassLoaders;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.openjpa.kernel;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.openjpa.datacache.DataCache;
|
||||
import org.apache.openjpa.kernel.exps.AggregateListener;
|
||||
import org.apache.openjpa.kernel.exps.FilterListener;
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.map.IdentityMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||
import org.apache.openjpa.event.CallbackModes;
|
||||
import org.apache.openjpa.event.LifecycleEvent;
|
||||
|
@ -59,7 +59,7 @@ public class AttachManager {
|
|||
private final OpCallbacks _call;
|
||||
private final boolean _copyNew;
|
||||
private final boolean _failFast;
|
||||
private final IdentityMap _attached = new IdentityMap();
|
||||
private final IdentityHashMap _attached = new IdentityHashMap();
|
||||
private final Collection<StateManagerImpl> _visitedNodes = new ArrayList();
|
||||
|
||||
// reusable strategies
|
||||
|
|
|
@ -44,9 +44,10 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.apache.commons.collections.iterators.IteratorChain;
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.collections4.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.commons.collections4.set.MapBackedSet;
|
||||
import org.apache.openjpa.lib.util.StringUtil;
|
||||
import org.apache.openjpa.conf.Compatibility;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
|
@ -404,7 +405,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
private void initializeOperatingSet() {
|
||||
if(_operatingDirty) {
|
||||
_operatingDirty = false;
|
||||
_operating = MapBackedSet.decorate(new IdentityHashMap<Object, Object>());
|
||||
_operating = MapBackedSet.mapBackedSet(new IdentityHashMap<Object, Object>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -430,7 +431,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
* {@link ReferenceMap} with soft values.
|
||||
*/
|
||||
protected Map<?,?> newManagedObjectCache() {
|
||||
return new ReferenceHashMap(ReferenceMap.HARD, ReferenceMap.SOFT);
|
||||
return new ReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.SOFT);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
@ -3749,7 +3750,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
try {
|
||||
ExtentImpl extent = new ExtentImpl(this, type, subclasses, fetch);
|
||||
if (_extents == null)
|
||||
_extents = new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
_extents = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
_extents.add(extent);
|
||||
|
||||
return extent;
|
||||
|
@ -3800,7 +3801,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
|
||||
// track queries
|
||||
if (_queries == null)
|
||||
_queries = new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
_queries = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
_queries.add(q);
|
||||
return q;
|
||||
} catch (OpenJPAException ke) {
|
||||
|
@ -4906,7 +4907,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
|
||||
private boolean addCleanInternal(StateManagerImpl sm) {
|
||||
if (_clean == null)
|
||||
_clean = new ReferenceHashSet(ReferenceHashSet.SOFT);
|
||||
_clean = new ReferenceHashSet(ReferenceStrength.SOFT);
|
||||
return _clean.add(sm);
|
||||
}
|
||||
|
||||
|
@ -4916,7 +4917,7 @@ public class BrokerImpl implements Broker, FindCallbacks, Cloneable, Serializabl
|
|||
public void addDirty(StateManagerImpl sm) {
|
||||
if (_dirty == null) {
|
||||
if (_orderDirty)
|
||||
_dirty = MapBackedSet.decorate(new LinkedMap());
|
||||
_dirty = MapBackedSet.mapBackedSet(new LinkedMap());
|
||||
else
|
||||
_dirty = new HashSet<StateManagerImpl>();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.openjpa.kernel;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.openjpa.kernel.exps.AggregateListener;
|
||||
import org.apache.openjpa.kernel.exps.FilterListener;
|
||||
import org.apache.openjpa.lib.util.OrderedMap;
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.IdentityMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import org.apache.openjpa.conf.Compatibility;
|
||||
import org.apache.openjpa.conf.DetachOptions;
|
||||
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||
|
@ -75,7 +75,7 @@ public class DetachManager
|
|||
// if we're not detaching full, we need to track all detached objects;
|
||||
// if we are, then we use a special field manager for more efficient
|
||||
// detachment than the standard one
|
||||
private final IdentityMap _detached;
|
||||
private final IdentityHashMap _detached;
|
||||
private final DetachFieldManager _fullFM;
|
||||
|
||||
/**
|
||||
|
@ -279,7 +279,7 @@ public class DetachManager
|
|||
_detached = null;
|
||||
_fullFM = new DetachFieldManager();
|
||||
} else {
|
||||
_detached = new IdentityMap();
|
||||
_detached = new IdentityHashMap();
|
||||
_fullFM = null;
|
||||
}
|
||||
Compatibility compatibility =
|
||||
|
|
|
@ -23,9 +23,10 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.collections.iterators.FilterIterator;
|
||||
import org.apache.commons.collections.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
import org.apache.commons.collections4.iterators.FilterIterator;
|
||||
import org.apache.commons.collections4.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.rop.ResultObjectProvider;
|
||||
import org.apache.openjpa.lib.rop.ResultObjectProviderIterator;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
|
@ -156,7 +157,7 @@ public class ExtentImpl<T>
|
|||
lock();
|
||||
try {
|
||||
if (_openItrs == null)
|
||||
_openItrs = new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
_openItrs = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
_openItrs.add(citr);
|
||||
} finally {
|
||||
unlock();
|
||||
|
@ -263,7 +264,7 @@ public class ExtentImpl<T>
|
|||
}
|
||||
|
||||
_closed = true;
|
||||
for (Iterator itr = getIterators().iterator(); itr.hasNext();)
|
||||
for (Iterator itr = this; itr.hasNext();)
|
||||
((Closeable) itr.next()).close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.ReferenceHashSet;
|
||||
import org.apache.openjpa.util.Exceptions;
|
||||
|
@ -105,7 +106,7 @@ class ManagedCache implements Serializable {
|
|||
|
||||
if (!sm.isPersistent() || sm.isEmbedded()) {
|
||||
if (_embeds == null)
|
||||
_embeds = new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
_embeds = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
_embeds.add(sm);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.openjpa.kernel;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.openjpa.kernel.exps.AggregateListener;
|
||||
import org.apache.openjpa.kernel.exps.Constant;
|
||||
import org.apache.openjpa.kernel.exps.FilterListener;
|
||||
|
|
|
@ -32,7 +32,8 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.openjpa.lib.util.StringUtil;
|
||||
|
@ -129,7 +130,7 @@ public class QueryImpl
|
|||
// remember the list of all the results we have returned so we
|
||||
// can free their resources when close or closeAll is called
|
||||
private transient final Collection<RemoveOnCloseResultList> _resultLists =
|
||||
new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
|
||||
private boolean _printParameters = false;
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Date;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
|
||||
|
||||
|
@ -165,12 +166,12 @@ public interface QueryStatistics<T> extends Serializable {
|
|||
|
||||
private void initializeMaps() {
|
||||
ConcurrentReferenceHashMap statsMap =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
statsMap.setMaxSize(FIXED_SIZE);
|
||||
stats = statsMap;
|
||||
|
||||
ConcurrentReferenceHashMap aStatsMap =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.HARD, CONCURRENCY, LOAD_FACTOR);
|
||||
aStatsMap.setMaxSize(FIXED_SIZE);
|
||||
astats = aStatsMap;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.Serializable;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.map.LinkedMap;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.apache.openjpa.kernel.exps.AggregateListener;
|
||||
import org.apache.openjpa.kernel.exps.Constant;
|
||||
import org.apache.openjpa.kernel.exps.FilterListener;
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.collections.comparators.ComparatorChain;
|
||||
import org.apache.commons.collections4.comparators.ComparatorChain;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.kernel.OpenJPAStateManager;
|
||||
import org.apache.openjpa.kernel.StoreContext;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.apache.openjpa.meta;
|
||||
|
||||
import org.apache.commons.collections.bidimap.TreeBidiMap;
|
||||
import org.apache.commons.collections4.bidimap.TreeBidiMap;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.StringDistance;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.HashSet;
|
|||
import java.util.IdentityHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.collections4.set.MapBackedSet;
|
||||
|
||||
/**
|
||||
* Base class that provides utilities to change trackers.
|
||||
|
@ -186,7 +186,7 @@ public abstract class AbstractChangeTracker
|
|||
*/
|
||||
protected Set newSet() {
|
||||
if (_identity == Boolean.TRUE)
|
||||
return MapBackedSet.decorate(new IdentityHashMap());
|
||||
return MapBackedSet.mapBackedSet(new IdentityHashMap());
|
||||
return new HashSet();
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ public abstract class AbstractChangeTracker
|
|||
if (identity && cur instanceof HashSet) {
|
||||
if (cur.isEmpty())
|
||||
return null;
|
||||
Set replace = MapBackedSet.decorate(new IdentityHashMap());
|
||||
Set replace = MapBackedSet.mapBackedSet(new IdentityHashMap());
|
||||
replace.addAll(cur);
|
||||
return replace;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.util.List;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.collections.iterators.FilterIterator;
|
||||
import org.apache.commons.collections.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
import org.apache.commons.collections4.iterators.FilterIterator;
|
||||
import org.apache.commons.collections4.iterators.IteratorChain;
|
||||
import org.apache.openjpa.kernel.OpenJPAStateManager;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
|
@ -410,10 +410,8 @@ public abstract class AbstractLRSProxyCollection
|
|||
if (_state != OPEN)
|
||||
return;
|
||||
|
||||
List itrs = _itr.getIterators();
|
||||
Iterator itr;
|
||||
for (int i = 0; i < itrs.size(); i++) {
|
||||
itr = (Iterator) itrs.get(i);
|
||||
for (Iterator itr = _itr; itr.hasNext();) {
|
||||
itr.next();
|
||||
if (itr instanceof FilterIterator)
|
||||
itr = ((FilterIterator) itr).getIterator();
|
||||
ImplHelper.close(itr);
|
||||
|
|
|
@ -30,9 +30,9 @@ import java.util.Map;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.collections.iterators.FilterIterator;
|
||||
import org.apache.commons.collections.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
import org.apache.commons.collections4.iterators.FilterIterator;
|
||||
import org.apache.commons.collections4.iterators.IteratorChain;
|
||||
import org.apache.openjpa.kernel.OpenJPAStateManager;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
|
@ -507,10 +507,8 @@ public abstract class AbstractLRSProxyMap<K,V>
|
|||
if (_state != OPEN)
|
||||
return;
|
||||
|
||||
List itrs = _itr.getIterators();
|
||||
Iterator itr;
|
||||
for (int i = 0; i < itrs.size(); i++) {
|
||||
itr = (Iterator) itrs.get(i);
|
||||
for (Iterator itr = _itr; itr.hasNext();) {
|
||||
itr.next();
|
||||
if (itr instanceof FilterIterator)
|
||||
itr = ((FilterIterator) itr).getIterator();
|
||||
ImplHelper.close(itr);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlacklistClassResolver {
|
|||
public static final BlacklistClassResolver DEFAULT = new BlacklistClassResolver(
|
||||
toArray(System.getProperty(
|
||||
"openjpa.serialization.class.blacklist",
|
||||
"org.codehaus.groovy.runtime.,org.apache.commons.collections.functors.,org.apache.xalan")),
|
||||
"org.codehaus.groovy.runtime.,org.apache.commons.collections4.functors.,org.apache.xalan")),
|
||||
toArray(System.getProperty("openjpa.serialization.class.whitelist")));
|
||||
|
||||
private final String[] blacklist;
|
||||
|
@ -59,6 +59,3 @@ public class BlacklistClassResolver {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.collections.iterators.FilterIterator;
|
||||
import org.apache.commons.collections.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
import org.apache.commons.collections4.iterators.FilterIterator;
|
||||
import org.apache.commons.collections4.iterators.IteratorChain;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.LRUMap;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
import org.apache.openjpa.lib.util.SizedMap;
|
||||
|
@ -112,8 +113,8 @@ public class CacheMap
|
|||
if (size < 0)
|
||||
size = 500;
|
||||
|
||||
softMap = new ConcurrentReferenceHashMap(ReferenceMap.HARD,
|
||||
ReferenceMap.SOFT, size, load) {
|
||||
softMap = new ConcurrentReferenceHashMap(ReferenceStrength.HARD,
|
||||
ReferenceStrength.SOFT, size, load) {
|
||||
public void overflowRemoved(Object key, Object value) {
|
||||
softMapOverflowRemoved(key, value);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.openjpa.meta.FieldMetaData;
|
|||
import org.apache.openjpa.meta.JavaTypes;
|
||||
import org.apache.openjpa.meta.SequenceMetaData;
|
||||
import org.apache.openjpa.meta.ValueStrategies;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -58,11 +59,11 @@ public class ImplHelper {
|
|||
|
||||
// Cache for from/to type assignments
|
||||
private static final Map _assignableTypes =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
|
||||
// map of all new unenhanced instances active in this classloader
|
||||
public static final Map _unenhancedInstanceMap =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD) {
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD) {
|
||||
|
||||
protected boolean eq(Object x, Object y) {
|
||||
// the Entries in ConcurrentReferenceHashMap delegate back to
|
||||
|
@ -252,8 +253,8 @@ public class ImplHelper {
|
|||
Boolean isAssignable = null;
|
||||
Map assignableTo = (Map) _assignableTypes.get(from);
|
||||
if (assignableTo == null) { // "to" cache doesn't exist, so create it...
|
||||
assignableTo = new ConcurrentReferenceHashMap(ReferenceMap.WEAK,
|
||||
ReferenceMap.HARD);
|
||||
assignableTo = new ConcurrentReferenceHashMap(ReferenceStrength.WEAK,
|
||||
ReferenceStrength.HARD);
|
||||
_assignableTypes.put(from, assignableTo);
|
||||
} else { // "to" cache exists...
|
||||
isAssignable = (Boolean) assignableTo.get(to);
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.openjpa.util;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
|
||||
|
||||
|
@ -35,7 +36,7 @@ public abstract class OpenJPAId
|
|||
|
||||
// cache the types' generated hash codes
|
||||
private static ConcurrentReferenceHashMap _typeCache =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
|
||||
protected Class type;
|
||||
protected boolean subs = true;
|
||||
|
|
|
@ -66,8 +66,8 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.serp</groupId>
|
||||
|
|
|
@ -35,6 +35,7 @@ import javax.naming.Context;
|
|||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.log.Log;
|
||||
import org.apache.openjpa.lib.util.ClassUtil;
|
||||
import org.apache.openjpa.lib.util.J2DoPrivHelper;
|
||||
|
@ -53,12 +54,10 @@ import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
|
|||
*/
|
||||
public class Configurations {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(Configurations.class);
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage(Configurations.class);
|
||||
|
||||
private static final ConcurrentReferenceHashMap _loaders = new
|
||||
ConcurrentReferenceHashMap(ConcurrentReferenceHashMap.WEAK,
|
||||
ConcurrentReferenceHashMap.HARD);
|
||||
ConcurrentReferenceHashMap(ReferenceStrength.WEAK, ReferenceStrength.HARD);
|
||||
|
||||
private static final Object NULL_LOADER = "null-loader";
|
||||
|
||||
|
@ -195,8 +194,8 @@ public class Configurations {
|
|||
Map<String,Class<?>> loaderCache = (Map<String,Class<?>>) _loaders.get(key);
|
||||
if (loaderCache == null) { // We don't have a cache for this loader.
|
||||
//OPENJPA-2636: Changed to HARD/WEAK to avoid Classloader leak:
|
||||
loaderCache = new ConcurrentReferenceHashMap(ConcurrentReferenceHashMap.HARD,
|
||||
ConcurrentReferenceHashMap.WEAK);
|
||||
loaderCache = new ConcurrentReferenceHashMap(ReferenceStrength.HARD,
|
||||
ReferenceStrength.WEAK);
|
||||
_loaders.put(key, loaderCache);
|
||||
} else { // We have a cache for this loader.
|
||||
cls = (Class<?>) loaderCache.get(clsName);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.openjpa.lib.conf;
|
|||
import java.security.AccessController;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.J2DoPrivHelper;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
|
@ -38,7 +39,7 @@ public class ObjectValue extends Value {
|
|||
|
||||
// cache the types' classloader
|
||||
private static ConcurrentReferenceHashMap _classloaderCache =
|
||||
new ConcurrentReferenceHashMap(ReferenceMap.HARD, ReferenceMap.WEAK);
|
||||
new ConcurrentReferenceHashMap(ReferenceStrength.HARD, ReferenceStrength.WEAK);
|
||||
|
||||
private Object _value = null;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.openjpa.lib.rop;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.ReferenceMap;
|
||||
import org.apache.commons.collections4.map.ReferenceMap;
|
||||
|
||||
/**
|
||||
* Specialization of the {@link RandomAccessResultList} that only maintains
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
public class LRUMap extends org.apache.commons.collections.map.LRUMap
|
||||
public class LRUMap extends org.apache.commons.collections4.map.LRUMap
|
||||
implements SizedMap {
|
||||
|
||||
private int _max = -1;
|
||||
|
|
|
@ -30,33 +30,18 @@ import java.lang.ref.Reference;
|
|||
* @since 0.4.0
|
||||
*/
|
||||
public class ReferenceHashMap
|
||||
extends org.apache.commons.collections.map.ReferenceMap
|
||||
extends org.apache.commons.collections4.map.ReferenceMap
|
||||
implements ReferenceMap, SizedMap {
|
||||
|
||||
private int _maxSize = Integer.MAX_VALUE;
|
||||
|
||||
public ReferenceHashMap(int keyType, int valueType) {
|
||||
super(toReferenceConstant(keyType), toReferenceConstant(valueType));
|
||||
public ReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType) {
|
||||
super(keyType, valueType);
|
||||
}
|
||||
|
||||
public ReferenceHashMap(int keyType, int valueType, int capacity,
|
||||
public ReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType, int capacity,
|
||||
float loadFactor) {
|
||||
super(toReferenceConstant(keyType), toReferenceConstant(valueType),
|
||||
capacity, loadFactor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Concver our reference constants to Apache's.
|
||||
*/
|
||||
private static int toReferenceConstant(int type) {
|
||||
switch (type) {
|
||||
case ReferenceMap.HARD:
|
||||
return org.apache.commons.collections.map.ReferenceMap. HARD;
|
||||
case ReferenceMap.SOFT:
|
||||
return org.apache.commons.collections.map.ReferenceMap. SOFT;
|
||||
default:
|
||||
return org.apache.commons.collections.map.ReferenceMap. WEAK;
|
||||
}
|
||||
super(keyType, valueType, capacity, loadFactor);
|
||||
}
|
||||
|
||||
public int getMaxSize() {
|
||||
|
@ -104,63 +89,11 @@ public class ReferenceHashMap
|
|||
super.addMapping(hashIndex, hashCode, key, value);
|
||||
}
|
||||
|
||||
protected HashEntry createEntry(HashEntry next, int hashCode, Object key,
|
||||
protected ReferenceEntry createEntry(HashEntry next, int hashCode, Object key,
|
||||
Object value) {
|
||||
return new AccessibleEntry(this, next, hashCode, key, value);
|
||||
}
|
||||
|
||||
protected void purge(Reference ref) {
|
||||
// the logic for this method is taken from the original purge method
|
||||
// we're overriding, with added logic to track the expired key/value
|
||||
int index = hashIndex(ref.hashCode(), data.length);
|
||||
AccessibleEntry entry = (AccessibleEntry) data[index];
|
||||
AccessibleEntry prev = null;
|
||||
Object key = null, value = null;
|
||||
while (entry != null) {
|
||||
if (purge(entry, ref)) {
|
||||
if (isHard(keyType))
|
||||
key = entry.key();
|
||||
else if (isHard(valueType))
|
||||
value = entry.value();
|
||||
|
||||
if (prev == null)
|
||||
data[index] = entry.nextEntry();
|
||||
else
|
||||
prev.setNextEntry(entry.nextEntry());
|
||||
size--;
|
||||
break;
|
||||
}
|
||||
prev = entry;
|
||||
entry = entry.nextEntry();
|
||||
}
|
||||
|
||||
if (key != null)
|
||||
valueExpired(key);
|
||||
else if (value != null)
|
||||
keyExpired(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* See the code for <code>ReferenceMap.ReferenceEntry.purge</code>.
|
||||
*/
|
||||
private boolean purge(AccessibleEntry entry, Reference ref) {
|
||||
boolean match = (!isHard(keyType) && entry.key() == ref)
|
||||
|| (!isHard(valueType) && entry.value() == ref);
|
||||
if (match) {
|
||||
if (!isHard(keyType))
|
||||
((Reference) entry.key()).clear();
|
||||
if (!isHard(valueType))
|
||||
((Reference) entry.value()).clear();
|
||||
else if (purgeValues)
|
||||
entry.nullValue();
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
private static boolean isHard(int type) {
|
||||
return type == org.apache.commons.collections.map. ReferenceMap.HARD;
|
||||
}
|
||||
|
||||
protected void doWriteObject(ObjectOutputStream out) throws IOException {
|
||||
out.writeInt(_maxSize);
|
||||
super.doWriteObject(out);
|
||||
|
@ -177,11 +110,13 @@ public class ReferenceHashMap
|
|||
* protected state.
|
||||
*/
|
||||
private static class AccessibleEntry extends ReferenceEntry {
|
||||
private final ReferenceHashMap parent;
|
||||
|
||||
public AccessibleEntry(org.apache.commons.collections.map.
|
||||
public AccessibleEntry(org.apache.commons.collections4.map.
|
||||
AbstractReferenceMap map, HashEntry next,
|
||||
int hashCode, Object key, Object value) {
|
||||
super(map, next, hashCode, key, value);
|
||||
parent = (ReferenceHashMap)map;
|
||||
}
|
||||
|
||||
public Object key() {
|
||||
|
@ -192,10 +127,6 @@ public class ReferenceHashMap
|
|||
return value;
|
||||
}
|
||||
|
||||
public void nullValue() {
|
||||
value = null;
|
||||
}
|
||||
|
||||
public AccessibleEntry nextEntry() {
|
||||
return (AccessibleEntry) next;
|
||||
}
|
||||
|
@ -203,5 +134,14 @@ public class ReferenceHashMap
|
|||
public void setNextEntry(AccessibleEntry next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPurge() {
|
||||
if (parent.isKeyType(ReferenceStrength.HARD)) {
|
||||
parent.valueExpired(key);
|
||||
} else if (parent.isValueType(ReferenceStrength.HARD)) {
|
||||
parent.keyExpired(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.commons.collections4.set.MapBackedSet;
|
||||
|
||||
/**
|
||||
* A set whose values may be stored as weak or soft references.
|
||||
|
@ -32,22 +33,6 @@ import org.apache.commons.collections.set.MapBackedSet;
|
|||
* @author Abe White
|
||||
*/
|
||||
public class ReferenceHashSet implements Set, Serializable {
|
||||
|
||||
/**
|
||||
* Hard reference marker.
|
||||
*/
|
||||
public static final int HARD = 0;
|
||||
|
||||
/**
|
||||
* Soft reference marker.
|
||||
*/
|
||||
public static final int SOFT = 1;
|
||||
|
||||
/**
|
||||
* Weak reference marker.
|
||||
*/
|
||||
public static final int WEAK = 2;
|
||||
|
||||
private static final Object DUMMY_VAL = new Serializable() {
|
||||
public String toString() {
|
||||
return ReferenceHashSet.class.getName() + ".DUMMY_VAL";
|
||||
|
@ -59,17 +44,12 @@ public class ReferenceHashSet implements Set, Serializable {
|
|||
/**
|
||||
* Construct a set with the given reference type.
|
||||
*/
|
||||
public ReferenceHashSet(int refType) {
|
||||
if (refType == HARD)
|
||||
public ReferenceHashSet(ReferenceStrength refType) {
|
||||
if (refType == ReferenceStrength.HARD)
|
||||
_set = new HashSet();
|
||||
else {
|
||||
int mapRefType = (refType == WEAK) ? org.apache.commons.
|
||||
collections.map.ReferenceMap.WEAK : org.apache.
|
||||
commons.collections.map.ReferenceMap.SOFT;
|
||||
_set = MapBackedSet.decorate(new org.apache.commons.
|
||||
collections.map.ReferenceMap(mapRefType,
|
||||
org.apache.commons.collections.map.
|
||||
ReferenceMap.HARD), DUMMY_VAL);
|
||||
_set = MapBackedSet.mapBackedSet(new org.apache.commons.
|
||||
collections4.map.ReferenceMap(refType, ReferenceStrength.HARD), DUMMY_VAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,6 @@ import java.util.Map;
|
|||
* @author Abe White
|
||||
*/
|
||||
public interface ReferenceMap extends Map {
|
||||
|
||||
public static final int HARD = 0;
|
||||
public static final int WEAK = 1;
|
||||
public static final int SOFT = 2;
|
||||
|
||||
/**
|
||||
* Purge stale entries.
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.NoSuchElementException;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.openjpa.lib.util.ReferenceMap;
|
||||
import org.apache.openjpa.lib.util.SizedMap;
|
||||
|
||||
|
@ -83,12 +84,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
/**
|
||||
* The key reference type.
|
||||
*/
|
||||
private int keyType;
|
||||
private ReferenceStrength keyType;
|
||||
|
||||
/**
|
||||
* The value reference type.
|
||||
*/
|
||||
private int valueType;
|
||||
private ReferenceStrength valueType;
|
||||
|
||||
/**
|
||||
* Reference queue for cleared Entries
|
||||
|
@ -138,7 +139,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* references, if the initial capacity is less than or equal to zero, or if
|
||||
* the load factor is less than or equal to zero
|
||||
*/
|
||||
public ConcurrentReferenceHashMap(int keyType, int valueType,
|
||||
public ConcurrentReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType,
|
||||
int initialCapacity, float loadFactor) {
|
||||
if (initialCapacity < 0) {
|
||||
throw new IllegalArgumentException("Illegal Initial Capacity: " +
|
||||
|
@ -148,7 +149,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
throw new IllegalArgumentException("Illegal Load factor: " +
|
||||
loadFactor);
|
||||
}
|
||||
if (keyType != HARD && valueType != HARD) {
|
||||
if (keyType != ReferenceStrength.HARD && valueType != ReferenceStrength.HARD) {
|
||||
throw new IllegalArgumentException("Either keys or values must " +
|
||||
"use hard references.");
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* @param valueType the reference type of map values
|
||||
* @param initialCapacity the initial capacity of the HashMap.
|
||||
*/
|
||||
public ConcurrentReferenceHashMap(int keyType, int valueType,
|
||||
public ConcurrentReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType,
|
||||
int initialCapacity) {
|
||||
this(keyType, valueType, initialCapacity, 0.75f);
|
||||
}
|
||||
|
@ -178,7 +179,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* @param keyType the reference type of map keys
|
||||
* @param valueType the reference type of map values
|
||||
*/
|
||||
public ConcurrentReferenceHashMap(int keyType, int valueType) {
|
||||
public ConcurrentReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType) {
|
||||
this(keyType, valueType, 11, 0.75f);
|
||||
}
|
||||
|
||||
|
@ -191,7 +192,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* @param keyType the reference type of map keys
|
||||
* @param valueType the reference type of map values
|
||||
*/
|
||||
public ConcurrentReferenceHashMap(int keyType, int valueType, Map t) {
|
||||
public ConcurrentReferenceHashMap(ReferenceStrength keyType, ReferenceStrength valueType, Map t) {
|
||||
this(keyType, valueType, Math.max(3 * t.size(), 11), 0.75f);
|
||||
putAll(t);
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
Entry[] tab = table;
|
||||
|
||||
if (value == null) {
|
||||
if (valueType != HARD)
|
||||
if (valueType != ReferenceStrength.HARD)
|
||||
return false;
|
||||
for (int i = tab.length; i-- > 0;)
|
||||
for (Entry e = tab[i]; e != null; e = e.getNext())
|
||||
|
@ -264,7 +265,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* @param key key whose presence in this Map is to be tested.
|
||||
*/
|
||||
public boolean containsKey(Object key) {
|
||||
if (key == null && keyType != HARD)
|
||||
if (key == null && keyType != ReferenceStrength.HARD)
|
||||
return false;
|
||||
|
||||
Entry[] tab = table;
|
||||
|
@ -283,7 +284,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* @param key key whose associated value is to be returned.
|
||||
*/
|
||||
public Object get(Object key) {
|
||||
if (key == null && keyType != HARD)
|
||||
if (key == null && keyType != ReferenceStrength.HARD)
|
||||
return null;
|
||||
|
||||
Entry[] tab = table;
|
||||
|
@ -311,8 +312,8 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
|
||||
for (int i = oldCapacity; i-- > 0;) {
|
||||
for (Entry old = oldMap[i]; old != null;) {
|
||||
if ((keyType != HARD && old.getKey() == null)
|
||||
|| valueType != HARD && old.getValue() == null) {
|
||||
if ((keyType != ReferenceStrength.HARD && old.getKey() == null)
|
||||
|| valueType != ReferenceStrength.HARD && old.getValue() == null) {
|
||||
Entry e = old;
|
||||
old = old.getNext();
|
||||
e.setNext(null);
|
||||
|
@ -344,8 +345,8 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* the HashMap previously associated null with the specified key.
|
||||
*/
|
||||
public Object put(Object key, Object value) {
|
||||
if ((key == null && keyType != HARD)
|
||||
|| (value == null && valueType != HARD))
|
||||
if ((key == null && keyType != ReferenceStrength.HARD)
|
||||
|| (value == null && valueType != ReferenceStrength.HARD))
|
||||
throw new IllegalArgumentException("Null references not supported");
|
||||
|
||||
int hash = hc(key);
|
||||
|
@ -360,7 +361,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
e = e.getNext()) {
|
||||
if ((e.getHash() == hash) && eq(key, e.getKey())) {
|
||||
Object old = e.getValue();
|
||||
if (valueType == HARD)
|
||||
if (valueType == ReferenceStrength.HARD)
|
||||
e.setValue(value);
|
||||
else {
|
||||
e = newEntry(hash, e.getKey(), value, e.getNext());
|
||||
|
@ -393,7 +394,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* Creates a new entry.
|
||||
*/
|
||||
private Entry newEntry(int hash, Object key, Object value, Entry next) {
|
||||
int refType = (keyType != HARD) ? keyType : valueType;
|
||||
ReferenceStrength refType = (keyType != ReferenceStrength.HARD) ? keyType : valueType;
|
||||
switch (refType) {
|
||||
case WEAK:
|
||||
return new WeakEntry(hash, key, value, refType == keyType, next,
|
||||
|
@ -427,7 +428,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
* the HashMap previously associated null with the specified key.
|
||||
*/
|
||||
public Object remove(Object key) {
|
||||
if (key == null && keyType != HARD)
|
||||
if (key == null && keyType != ReferenceStrength.HARD)
|
||||
return null;
|
||||
|
||||
int hash = hc(key);
|
||||
|
@ -748,7 +749,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap
|
|||
tab[index] = e.getNext();
|
||||
|
||||
count--;
|
||||
if (keyType == HARD)
|
||||
if (keyType == ReferenceStrength.HARD)
|
||||
valueExpired(e.getKey());
|
||||
else
|
||||
keyExpired(e.getValue());
|
||||
|
|
|
@ -24,7 +24,8 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
import org.apache.commons.collections4.set.MapBackedSet;
|
||||
|
||||
/**
|
||||
* A concurrent set whose values may be stored as weak or soft references. If
|
||||
|
@ -36,22 +37,6 @@ import org.apache.commons.collections.set.MapBackedSet;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ConcurrentReferenceHashSet<E> implements Set<E>, Serializable {
|
||||
|
||||
/**
|
||||
* Hard reference marker.
|
||||
*/
|
||||
public static final int HARD = 0;
|
||||
|
||||
/**
|
||||
* Soft reference marker.
|
||||
*/
|
||||
public static final int SOFT = 1;
|
||||
|
||||
/**
|
||||
* Weak reference marker.
|
||||
*/
|
||||
public static final int WEAK = 2;
|
||||
|
||||
private static final Object DUMMY_VAL = new Object();
|
||||
|
||||
private final Set<E> _set;
|
||||
|
@ -59,14 +44,12 @@ public class ConcurrentReferenceHashSet<E> implements Set<E>, Serializable {
|
|||
/**
|
||||
* Construct a set with the given reference type.
|
||||
*/
|
||||
public ConcurrentReferenceHashSet(int refType) {
|
||||
if (refType == HARD)
|
||||
_set = MapBackedSet.decorate(new ConcurrentHashMap(), DUMMY_VAL);
|
||||
public ConcurrentReferenceHashSet(ReferenceStrength refType) {
|
||||
if (refType == ReferenceStrength.HARD)
|
||||
_set = MapBackedSet.mapBackedSet(new ConcurrentHashMap(), DUMMY_VAL);
|
||||
else {
|
||||
int mapRefType = (refType == WEAK) ? ConcurrentReferenceHashMap.WEAK
|
||||
: ConcurrentReferenceHashMap.SOFT;
|
||||
_set = MapBackedSet.decorate(new ConcurrentReferenceHashMap
|
||||
(mapRefType, ConcurrentReferenceHashMap.HARD), DUMMY_VAL);
|
||||
_set = MapBackedSet.mapBackedSet(new ConcurrentReferenceHashMap
|
||||
(refType, ReferenceStrength.HARD), DUMMY_VAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.apache.openjpa.lib.util;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
@ -30,8 +32,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public class TestReferenceSet extends TestCase {
|
||||
|
||||
private ReferenceHashSet _coll = new ReferenceHashSet
|
||||
(ReferenceHashSet.WEAK);
|
||||
private ReferenceHashSet _coll = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
|
||||
private Object _heldValue = new Integer(2);
|
||||
|
||||
|
@ -48,7 +49,7 @@ public class TestReferenceSet extends TestCase {
|
|||
* Tests basic add/contains/remove functionality.
|
||||
*/
|
||||
public void testBasics() {
|
||||
Collection coll = new ReferenceHashSet(ReferenceHashSet.WEAK);
|
||||
Collection coll = new ReferenceHashSet(ReferenceStrength.WEAK);
|
||||
assertEquals(0, coll.size());
|
||||
assertTrue(!coll.contains("foo"));
|
||||
|
||||
|
|
|
@ -852,8 +852,8 @@
|
|||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -18,12 +18,16 @@
|
|||
*/
|
||||
package org.apache.openjpa.persistence.jdbc.common.apps;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.apache.commons.collections.*;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
|
||||
/**
|
||||
* Normal class that has relations to and from various horizontal
|
||||
|
@ -107,7 +111,7 @@ public class HorizRelation
|
|||
private ArrayList cHorizInterVerticalD = new ArrayList();
|
||||
|
||||
public Map getCollections() {
|
||||
Map map = new SequencedHashMap();
|
||||
Map map = new LinkedMap();
|
||||
map.put("HorizA", cHorizA);
|
||||
map.put("HorizB", cHorizB);
|
||||
map.put("HorizC", cHorizC);
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.TreeSet;
|
|||
|
||||
|
||||
import org.apache.openjpa.persistence.kernel.common.apps.ProxiesPC;
|
||||
import org.apache.commons.collections.comparators.ComparableComparator;
|
||||
import org.apache.commons.collections4.comparators.ComparableComparator;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.util.Proxy;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.openjpa.persistence.jdbc.KeyColumn;
|
||||
import org.apache.commons.collections.comparators.ComparableComparator;
|
||||
import org.apache.commons.collections4.comparators.ComparableComparator;
|
||||
import org.apache.openjpa.persistence.PersistentCollection;
|
||||
import org.apache.openjpa.persistence.PersistentMap;
|
||||
|
||||
|
|
|
@ -133,8 +133,7 @@
|
|||
<include>net.sourceforge.serp:serp</include>
|
||||
<include>org.apache.derby:derby</include>
|
||||
|
||||
<include>commons-lang:commons-lang</include>
|
||||
<include>commons-collections:commons-collections</include>
|
||||
<include>org.apache.commons:commons-collections4</include>
|
||||
<include>org.apache.commons:commons-pool2</include>
|
||||
<include>commons-logging:commons-logging</include>
|
||||
<include>org.apache.commons:commons-dbcp2</include>
|
||||
|
|
|
@ -72,8 +72,7 @@
|
|||
<include>net.sourceforge.serp:serp</include>
|
||||
<include>org.apache.derby:derby</include>
|
||||
|
||||
<include>commons-lang:commons-lang</include>
|
||||
<include>commons-collections:commons-collections</include>
|
||||
<include>org.apache.commons:commons-collections4</include>
|
||||
<include>org.apache.commons:commons-pool2</include>
|
||||
<include>commons-logging:commons-logging</include>
|
||||
<include>org.apache.commons:commons-dbcp2</include>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -508,9 +508,9 @@
|
|||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.serp</groupId>
|
||||
|
|
Loading…
Reference in New Issue